public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: "Dmitry V. Levin" <ldv@altlinux.org>
To: elfutils-devel@sourceware.org
Subject: [PATCH 2/4] lib: consistently use _(Str) instead of gettext(Str)
Date: Wed, 16 Dec 2020 12:54:18 +0300	[thread overview]
Message-ID: <20201216095417.GB26456@altlinux.org> (raw)
In-Reply-To: <20201216014759.GA21292@altlinux.org>

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      | 5 +++++
 lib/color.c        | 4 ++--
 lib/printversion.c | 2 +-
 lib/system.h       | 2 +-
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/ChangeLog b/lib/ChangeLog
index 48b496ce..3b603bd0 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -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.
 
diff --git a/lib/color.c b/lib/color.c
index 2cb41eba..454cb7ca 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -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;
 			      }
 			}
diff --git a/lib/printversion.c b/lib/printversion.c
index 28981d20..1f3f3d19 100644
--- a/lib/printversion.c
+++ b/lib/printversion.c
@@ -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\
diff --git a/lib/system.h b/lib/system.h
index 7b650f11..1c478e1c 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -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
-- 
ldv

  parent reply	other threads:[~2020-12-16  9:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16  1:48 [PATCH] libebl: " Dmitry V. Levin
2020-12-16  9:54 ` [PATCH 1/4] Consistently define _(Str) using dgettext ("elfutils", Str) Dmitry V. Levin
2020-12-16  9:54 ` Dmitry V. Levin [this message]
2020-12-16  9:54 ` [PATCH 3/4] libcpu: consistently use _(Str) instead of gettext(Str) Dmitry V. Levin
2020-12-16  9:54 ` [PATCH 4/4] src: " Dmitry V. Levin
2020-12-16 14:09 ` [PATCH] libebl: " Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201216095417.GB26456@altlinux.org \
    --to=ldv@altlinux.org \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).