[PATCH 1/4] Consistently define _(Str) using dgettext ("elfutils", Str)

Dmitry V. Levin ldv@altlinux.org
Wed Dec 16 09:54:09 GMT 2020


Move the definition of _(Str) macro to lib/eu-config.h which already
provides a definition of N_(Str) macro.  Since lib/eu-config.h is
appended to config.h, it is included into every compilation unit
and therefore both macros are now universally available.

Remove all other definitions of N_(Str) and _(Str) macros from other files
to avoid conflicts and redundancies.

The next step is to replace all uses of gettext(Str) with _(Str).

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 lib/ChangeLog       | 5 +++++
 lib/eu-config.h     | 3 ++-
 lib/xmalloc.c       | 4 ----
 libasm/ChangeLog    | 4 ++++
 libasm/libasmP.h    | 3 ---
 libdw/ChangeLog     | 4 ++++
 libdw/libdwP.h      | 4 ----
 libdwfl/ChangeLog   | 5 +++++
 libdwfl/argp-std.c  | 3 ---
 libdwfl/libdwflP.h  | 3 ---
 libebl/ChangeLog    | 4 ++++
 libebl/libeblP.h    | 5 -----
 libelf/ChangeLog    | 4 ++++
 libelf/libelfP.h    | 3 ---
 src/ChangeLog       | 4 ++++
 src/unstrip.c       | 4 ----
 tests/ChangeLog     | 4 ++++
 tests/dwflmodtest.c | 4 ----
 18 files changed, 36 insertions(+), 34 deletions(-)

diff --git a/lib/ChangeLog b/lib/ChangeLog
index 663a7aa5..48b496ce 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,8 @@
+2020-12-16  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* eu-config.h (_): New macro.
+	* xmalloc.c (_): Remove.
+
 2020-11-01  Érico N. Rolim  <erico.erc@gmail.com>
 
 	* system.h (ACCESSPERMS): Define macro if it doesn't exist.
diff --git a/lib/eu-config.h b/lib/eu-config.h
index 84b22d7c..f0e3d07a 100644
--- a/lib/eu-config.h
+++ b/lib/eu-config.h
@@ -52,8 +52,9 @@
 # define rwlock_unlock(lock) ((void) (lock))
 #endif	/* USE_LOCKS */
 
-/* gettext helper macro.  */
+/* gettext helper macros.  */
 #define N_(Str) Str
+#define _(Str) dgettext ("elfutils", Str)
 
 /* Compiler-specific definitions.  */
 #define strong_alias(name, aliasname) \
diff --git a/lib/xmalloc.c b/lib/xmalloc.c
index 0424afc8..7c094985 100644
--- a/lib/xmalloc.c
+++ b/lib/xmalloc.c
@@ -36,10 +36,6 @@
 #include <sys/types.h>
 #include "system.h"
 
-#ifndef _
-# define _(str) gettext (str)
-#endif
-
 
 /* Allocate N bytes of memory dynamically, with error checking.  */
 void *
diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index 78f1baa4..98ac3315 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,3 +1,7 @@
+2020-12-16  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* libasmP.h (_): Remove.
+
 2020-12-12  Dmitry V. Levin  <ldv@altlinux.org>
 
 	* asm_begin.c (prepare_binary_output): Fix spelling typo in comment.
diff --git a/libasm/libasmP.h b/libasm/libasmP.h
index 53d8f3a0..8b72f32b 100644
--- a/libasm/libasmP.h
+++ b/libasm/libasmP.h
@@ -36,9 +36,6 @@
 
 #include "libdwelf.h"
 
-/* gettext helper macros.  */
-#define _(Str) dgettext ("elfutils", Str)
-
 
 /* Known error codes.  */
 enum
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index ab568f55..20fec602 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,7 @@
+2020-12-16  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* libdwP.h (_): Remove.
+
 2020-12-12  Dmitry V. Levin  <ldv@altlinux.org>
 
 	* dwarf.h: Fix spelling typo in comment.
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index c18eea43..7174ea93 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -38,10 +38,6 @@
 #include "atomics.h"
 
 
-/* gettext helper macros.  */
-#define _(Str) dgettext ("elfutils", Str)
-
-
 /* Known location expressions already decoded.  */
 struct loc_s
 {
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index fc64eafd..f9f6f01f 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2020-12-16  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* argp-std.c (_): Remove.
+	* libdwflP.h (_): Likewise.
+
 2020-12-12  Dmitry V. Levin  <ldv@altlinux.org>
 
 	* libdwfl.h: Fix spelling typos in comments.
diff --git a/libdwfl/argp-std.c b/libdwfl/argp-std.c
index 2aa1b5e0..01ec18e2 100644
--- a/libdwfl/argp-std.c
+++ b/libdwfl/argp-std.c
@@ -38,9 +38,6 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-/* gettext helper macros.  */
-#define _(Str) dgettext ("elfutils", Str)
-
 
 #define OPT_DEBUGINFO	0x100
 #define OPT_COREFILE	0x101
diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h
index 4c6fcb28..4344e356 100644
--- a/libdwfl/libdwflP.h
+++ b/libdwfl/libdwflP.h
@@ -47,9 +47,6 @@
 
 typedef struct Dwfl_Process Dwfl_Process;
 
-/* gettext helper macros.  */
-#define _(Str) dgettext ("elfutils", Str)
-
 #define DWFL_ERRORS							      \
   DWFL_ERROR (NOERROR, N_("no error"))					      \
   DWFL_ERROR (UNKNOWN_ERROR, N_("unknown error"))			      \
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index e0862ec3..33208f0d 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,7 @@
+2020-12-16  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* libeblP.h (_): Remove.
+
 2020-12-15  Dmitry V. Levin  <ldv@altlinux.org>
 
 	* eblbackendname.c (ebl_backend_name): Replace gettext(...) with _(...).
diff --git a/libebl/libeblP.h b/libebl/libeblP.h
index 599f6378..fa1c2c9f 100644
--- a/libebl/libeblP.h
+++ b/libebl/libeblP.h
@@ -86,11 +86,6 @@ struct ebl
 typedef Ebl *(*ebl_bhinit_t) (Elf *, GElf_Half, Ebl *);
 
 
-/* gettext helper macros.  */
-#undef _
-#define _(Str) dgettext ("elfutils", Str)
-
-
 /* LEB128 constant helper macros.  */
 #define ULEB128_7(x)	(BUILD_BUG_ON_ZERO ((x) >= (1U << 7)) + (x))
 
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 41727fbd..acd9f8f0 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2020-12-16  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* libelfP.h (_): Remove.
+
 2020-12-12  Dmitry V. Levin  <ldv@altlinux.org>
 
 	* common.h: Fix spelling typo in comment.
diff --git a/libelf/libelfP.h b/libelf/libelfP.h
index b8ffa18d..fc1aebec 100644
--- a/libelf/libelfP.h
+++ b/libelf/libelfP.h
@@ -39,9 +39,6 @@
 #include <stdio.h>
 #include <string.h>
 
-/* gettext helper macros.  */
-#define _(Str) dgettext ("elfutils", Str)
-
 
 /* Helper Macros to write 32 bit and 64 bit functions.  */
 #define __elfw2_(Bits, Name) __elf##Bits##_##Name
diff --git a/src/ChangeLog b/src/ChangeLog
index 72f70343..27e64384 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2020-12-16  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* unstrip.c (_): Remove.
+
 2020-12-15  Mark Wielaard  <mark@klomp.org>
 
 	* elflint.c (check_symtab): Always print symbol name (if known)
diff --git a/src/unstrip.c b/src/unstrip.c
index 231b941d..85803295 100644
--- a/src/unstrip.c
+++ b/src/unstrip.c
@@ -52,10 +52,6 @@
 #include "libeu.h"
 #include "printversion.h"
 
-#ifndef _
-# define _(str) gettext (str)
-#endif
-
 /* Name and version of program.  */
 ARGP_PROGRAM_VERSION_HOOK_DEF = print_version;
 
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 2c83f690..119cf8e7 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2020-12-16  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* dwflmodtest.c (N_): Remove.
+
 2020-12-12  Dmitry V. Levin  <ldv@altlinux.org>
 
 	* dwarf-die-addr-die.c (main): Fix spelling typo in error diagnostics.
diff --git a/tests/dwflmodtest.c b/tests/dwflmodtest.c
index 9251d158..bec8a07c 100644
--- a/tests/dwflmodtest.c
+++ b/tests/dwflmodtest.c
@@ -204,10 +204,6 @@ print_module (Dwfl_Module *mod __attribute__ ((unused)),
 
 static bool show_functions;
 
-/* gettext helper macro.  */
-#undef	N_
-#define N_(Str) Str
-
 static const struct argp_option options[] =
   {
     { "functions", 'f', NULL, 0, N_("Additionally show function names"), 0 },
-- 
ldv


More information about the Elfutils-devel mailing list