From 65b3308bb67777a8e42b0d5a4550a62562790e10 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 3 Jul 2019 06:35:34 +0200 Subject: [PATCH] argmatch: don't define _ in the header Reported by Jim Meyering. * lib/argmatch.h (N_, _): Don't define. Use gettext instead. * lib/argmatch.h (_): Define. * tests/test-argmatch.c (N_): Define. --- ChangeLog | 9 +++++++++ lib/argmatch.c | 2 ++ lib/argmatch.h | 12 +++++------- tests/test-argmatch.c | 2 ++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index b89fd5d9e5..c3e1978709 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2019-07-03 Akim Demaille + + argmatch: don't define _ in the header. + Reported by Jim Meyering. + * lib/argmatch.h (N_, _): Don't define. + Use gettext instead. + * lib/argmatch.h (_): Define. + * tests/test-argmatch.c (N_): Define. + 2019-07-02 Paul Eggert verify: document ‘assume’ better diff --git a/lib/argmatch.c b/lib/argmatch.c index 183a0ca941..9eeb4514d8 100644 --- a/lib/argmatch.c +++ b/lib/argmatch.c @@ -29,6 +29,8 @@ #include #include +#define _(msgid) gettext (msgid) + #include "error.h" #include "quotearg.h" #include "getprogname.h" diff --git a/lib/argmatch.h b/lib/argmatch.h index d185499423..57d131f32d 100644 --- a/lib/argmatch.h +++ b/lib/argmatch.h @@ -32,9 +32,6 @@ # include "quote.h" # include "verify.h" -# define _(Msgid) gettext (Msgid) -# define N_(Msgid) (Msgid) - # ifdef __cplusplus extern "C" { # endif @@ -223,7 +220,7 @@ char const *argmatch_to_argument (void const *value, \ /* Try to put synonyms on the same line. Synonyms are expected \ to follow each other. */ \ - fputs (_("Valid arguments are:"), out); \ + fputs (gettext ("Valid arguments are:"), out); \ for (int i = 0; g->args[i].arg; i++) \ if (i == 0 \ || memcmp (&g->args[i-1].val, &g->args[i].val, size)) \ @@ -284,7 +281,7 @@ char const *argmatch_to_argument (void const *value, large width. */ \ const int screen_width = getenv ("HELP2MAN") ? INT_MAX : 80; \ if (g->doc_pre) \ - fprintf (out, "%s\n", _(g->doc_pre)); \ + fprintf (out, "%s\n", gettext (g->doc_pre)); \ int doc_col = argmatch_##Name##_doc_col (); \ for (int i = 0; g->docs[i].arg; ++i) \ { \ @@ -321,10 +318,11 @@ char const *argmatch_to_argument (void const *value, fprintf (out, "\n"); \ col = 0; \ } \ - fprintf (out, "%*s%s\n", doc_col - col, "", _(g->docs[i].doc)); \ + fprintf (out, "%*s%s\n", \ + doc_col - col, "", gettext (g->docs[i].doc)); \ } \ if (g->doc_post) \ - fprintf (out, "%s\n", _(g->doc_post)); \ + fprintf (out, "%s\n", gettext (g->doc_post)); \ } # ifdef __cplusplus diff --git a/tests/test-argmatch.c b/tests/test-argmatch.c index 11b5819eaf..7b1b38a194 100644 --- a/tests/test-argmatch.c +++ b/tests/test-argmatch.c @@ -25,6 +25,8 @@ #include "macros.h" +# define N_(Msgid) (Msgid) + /* Some packages define ARGMATCH_DIE and ARGMATCH_DIE_DECL in , and thus must link with a definition of that function. Provide it here. */ #ifdef ARGMATCH_DIE_DECL -- 2.39.5