lib: consistently use _(Str) instead of gettext(Str)
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 16 Dec 2020 08:00:00 +0000 (08:00 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 16 Dec 2020 10:01:52 +0000 (10:01 +0000)
eu-config.h defines _(Str) to dgettext ("elfutils", Str) instead of
a simple gettext (Str) for a reason: the library might be indirectly
used by clients that called bindtextdomain with a domain different
from "elfutils".

The change was made automatically using the following command:
$ git grep -l '\<gettext *(' lib |xargs sed -i 's/\<gettext *(/_(/g'

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
lib/ChangeLog
lib/color.c
lib/printversion.c
lib/system.h

index 48b496c..3b603bd 100644 (file)
@@ -1,5 +1,10 @@
 2020-12-16  Dmitry V. Levin  <ldv@altlinux.org>
 
+       * color.c (parse_opt): Replace gettext(...) and
+       dgettext("elfutils, ...) with _(...).
+       * printversion.c (print_version): Replace gettext(...) with _(...).
+       * system.h (sgettext): Likewise.
+
        * eu-config.h (_): New macro.
        * xmalloc.c (_): Remove.
 
index 2cb41eb..454cb7c 100644 (file)
@@ -126,7 +126,7 @@ parse_opt (int key, char *arg,
              }
          if (i == nvalues)
            {
-             error (0, 0, dgettext ("elfutils", "\
+             error (0, 0, _("\
 %s: invalid argument '%s' for '--color'\n\
 valid arguments are:\n\
   - 'always', 'yes', 'force'\n\
@@ -191,7 +191,7 @@ valid arguments are:\n\
                                if (asprintf (known[i].varp, "\e[%.*sm",
                                              (int) (env - val), val) < 0)
                                  error (EXIT_FAILURE, errno,
-                                        gettext ("cannot allocate memory"));
+                                        _("cannot allocate memory"));
                                break;
                              }
                        }
index 28981d2..1f3f3d1 100644 (file)
@@ -37,7 +37,7 @@ void
 print_version (FILE *stream, struct argp_state *state)
 {
   fprintf (stream, "%s (%s) %s\n", state->name, PACKAGE_NAME, PACKAGE_VERSION);
-  fprintf (stream, gettext ("\
+  fprintf (stream, _("\
 Copyright (C) %s The elfutils developers <%s>.\n\
 This is free software; see the source for copying conditions.  There is NO\n\
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
index 7b650f1..1c478e1 100644 (file)
@@ -71,7 +71,7 @@
 
 /* A special gettext function we use if the strings are too short.  */
 #define sgettext(Str) \
-  ({ const char *__res = strrchr (gettext (Str), '|');                       \
+  ({ const char *__res = strrchr (_(Str), '|');                              \
      __res ? __res + 1 : Str; })
 
 #define gettext_noop(Str) Str