libctf, binutils: initial work towards libctf gettextization
authorNick Alcock <nick.alcock@oracle.com>
Thu, 30 Jul 2020 16:43:12 +0000 (17:43 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Thu, 27 Aug 2020 12:14:10 +0000 (13:14 +0100)
We gettextize under our package name, which we change to a more
reasonable 'libctf'.  Our internationalization support is mostly
provided by ctf-intl.h, which is a copy of opcodes/opintl.h with
the non-gettext_noop N_() expansion debracketed to avoid pedantic
compiler warnings.

The libctf error strings returned by ctf_errmsg are marked up for
internationalization.

(We also adjust binutils's Makefile a tiny bit to allow for the
fact that libctf now uses functions from libintl.)

binutils/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* Makefile.am (readelf_LDADD): Move $(LIBINTL) after $(LIBCTF_NOBFD).
* Makefile.in: Regenerated.

libctf/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

* configure.ac: Adjust package name to simply 'libctf': arbitrarily
declare this to be version 1.2.0.
* Makefile.am (AM_CPPFLAGS): Add @INCINTL@.
* Makefile.in: Regenerated.
* configure: Regenerated.
* ctf-intl.h: New file, lightly modified from opcodes/opintl.h.
* ctf-impl.h: Include it.
* ctf-error.r (_ctf_errlist_t): Mark strings as noop-translatable.
(ctf_errmsg): Actually translate them.

binutils/ChangeLog
binutils/Makefile.am
binutils/Makefile.in
libctf/ChangeLog
libctf/Makefile.am
libctf/Makefile.in
libctf/configure
libctf/configure.ac
libctf/ctf-error.c
libctf/ctf-impl.h
libctf/ctf-intl.h [new file with mode: 0644]

index 7551db27d220ff077b50f4c751bb4db7ab18e8ff..1106c687e284b630bd70e1b91c042bd98d6cda18 100644 (file)
@@ -1,3 +1,8 @@
+2020-08-27  Nick Alcock  <nick.alcock@oracle.com>
+
+       * Makefile.am (readelf_LDADD): Move $(LIBINTL) after $(LIBCTF_NOBFD).
+       * Makefile.in: Regenerated.
+
 2020-08-26  Nick Clifton  <nickc@redhat.com>
 
        PR 26405
index 94d7616c2e35f197415a9dc636ccfc26f5590a73..24f8423ebc59a7225b9d25fe1699314d35ea8222 100644 (file)
@@ -253,7 +253,7 @@ objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
 strings_SOURCES = strings.c $(BULIBS)
 
 readelf_SOURCES = readelf.c version.c unwind-ia64.c dwarf.c $(ELFLIBS)
-readelf_LDADD   = $(LIBINTL) $(LIBCTF_NOBFD) $(LIBIBERTY) $(ZLIB) $(DEBUGINFOD_LIBS)
+readelf_LDADD   = $(LIBCTF_NOBFD) $(LIBINTL) $(LIBIBERTY) $(ZLIB) $(DEBUGINFOD_LIBS)
 
 elfedit_SOURCES = elfedit.c version.c $(ELFLIBS)
 elfedit_LDADD = $(LIBINTL) $(LIBIBERTY)
index 5ddae25558d0baf1555ee24aa3d7f21d7825dde1..fee05dfa84a8c8012c056a19068cd6bc9603873f 100644 (file)
@@ -720,7 +720,7 @@ size_SOURCES = size.c $(BULIBS)
 objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
 strings_SOURCES = strings.c $(BULIBS)
 readelf_SOURCES = readelf.c version.c unwind-ia64.c dwarf.c $(ELFLIBS)
-readelf_LDADD = $(LIBINTL) $(LIBCTF_NOBFD) $(LIBIBERTY) $(ZLIB) $(DEBUGINFOD_LIBS)
+readelf_LDADD = $(LIBCTF_NOBFD) $(LIBINTL) $(LIBIBERTY) $(ZLIB) $(DEBUGINFOD_LIBS)
 elfedit_SOURCES = elfedit.c version.c $(ELFLIBS)
 elfedit_LDADD = $(LIBINTL) $(LIBIBERTY)
 strip_new_SOURCES = objcopy.c is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
index bbd807dddfd2ae5322fb1bba9fa27fa52a79c8d4..34671a79431c4124d9d565f1604eefa569d382e1 100644 (file)
@@ -1,3 +1,15 @@
+2020-08-27  Nick Alcock  <nick.alcock@oracle.com>
+
+       * configure.ac: Adjust package name to simply 'libctf': arbitrarily
+       declare this to be version 1.2.0.
+       * Makefile.am (AM_CPPFLAGS): Add @INCINTL@.
+       * Makefile.in: Regenerated.
+       * configure: Regenerated.
+       * ctf-intl.h: New file, lightly modified from opcodes/opintl.h.
+       * ctf-impl.h: Include it.
+       * ctf-error.r (_ctf_errlist_t): Mark strings as noop-translatable.
+       (ctf_errmsg): Actually translate them.
+
 2020-07-26  Eli Zaretskii  <eliz@gnu.org>
 
        PR binutils/25155:
index 8b8f0a8cf83de2bb27981d65adfd4b5572911f27..d762b0abf11172f73f41d16b8dd6afc66bc0f079 100644 (file)
@@ -28,7 +28,7 @@ ZLIB = @zlibdir@ -lz
 ZLIBINC = @zlibinc@
 
 INCDIR = $(srcdir)/../include
-AM_CPPFLAGS = -D_GNU_SOURCE -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../bfd -I../bfd
+AM_CPPFLAGS = -D_GNU_SOURCE -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../bfd -I../bfd @INCINTL@
 AM_CFLAGS = -std=gnu99 @ac_libctf_warn_cflags@ @warn@ @c_warn@ @WARN_PEDANTIC@ @WERROR@ $(ZLIBINC)
 
 if INSTALL_LIBBFD
index 78de09ba10a40df868d3a3b49397e90bb002d09f..f43c0953e42971852adea5602ba104e24fe9ebda 100644 (file)
@@ -447,7 +447,7 @@ AUTOMAKE_OPTIONS = foreign no-texinfo.tex
 ZLIB = @zlibdir@ -lz
 ZLIBINC = @zlibinc@
 INCDIR = $(srcdir)/../include
-AM_CPPFLAGS = -D_GNU_SOURCE -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../bfd -I../bfd
+AM_CPPFLAGS = -D_GNU_SOURCE -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../bfd -I../bfd @INCINTL@
 AM_CFLAGS = -std=gnu99 @ac_libctf_warn_cflags@ @warn@ @c_warn@ @WARN_PEDANTIC@ @WERROR@ $(ZLIBINC)
 @INSTALL_LIBBFD_TRUE@lib_LTLIBRARIES = libctf.la libctf-nobfd.la
 @INSTALL_LIBBFD_FALSE@include_HEADERS = 
index a1f5b7ff09ffa609f2305c33b2c55d6065c93d60..b7ca7cd5003c29448a352b8c414950bc16146f68 100755 (executable)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libctf library 1.2.0-pre.
+# Generated by GNU Autoconf 2.69 for libctf 1.2.0.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -585,10 +585,10 @@ MFLAGS=
 MAKEFLAGS=
 
 # Identity of this package.
-PACKAGE_NAME='libctf library'
-PACKAGE_TARNAME='libctf-library'
-PACKAGE_VERSION='1.2.0-pre'
-PACKAGE_STRING='libctf library 1.2.0-pre'
+PACKAGE_NAME='libctf'
+PACKAGE_TARNAME='libctf'
+PACKAGE_VERSION='1.2.0'
+PACKAGE_STRING='libctf 1.2.0'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -1349,7 +1349,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures libctf library 1.2.0-pre to adapt to many kinds of systems.
+\`configure' configures libctf 1.2.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1397,7 +1397,7 @@ Fine tuning of the installation directories:
   --infodir=DIR           info documentation [DATAROOTDIR/info]
   --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
   --mandir=DIR            man documentation [DATAROOTDIR/man]
-  --docdir=DIR            documentation root [DATAROOTDIR/doc/libctf-library]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/libctf]
   --htmldir=DIR           html documentation [DOCDIR]
   --dvidir=DIR            dvi documentation [DOCDIR]
   --pdfdir=DIR            pdf documentation [DOCDIR]
@@ -1419,7 +1419,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of libctf library 1.2.0-pre:";;
+     short | recursive ) echo "Configuration of libctf 1.2.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1532,7 +1532,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-libctf library configure 1.2.0-pre
+libctf configure 1.2.0
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1943,7 +1943,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by libctf library $as_me 1.2.0-pre, which was
+It was created by libctf $as_me 1.2.0, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -4185,8 +4185,8 @@ fi
 
 
 # Define the identity of the package.
- PACKAGE='libctf-library'
- VERSION='1.2.0-pre'
+ PACKAGE='libctf'
+ VERSION='1.2.0'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -13944,7 +13944,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by libctf library $as_me 1.2.0-pre, which was
+This file was extended by libctf $as_me 1.2.0, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -14010,7 +14010,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-libctf library config.status 1.2.0-pre
+libctf config.status 1.2.0
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
index f5ed973b10ddac23a9308b243489eb6218513130..575da4677f3b8700a10ea8a077f6f2f85885c8be 100644 (file)
@@ -19,7 +19,7 @@ dnl <http://www.gnu.org/licenses/>.
 dnl
 
 AC_PREREQ(2.64)
-AC_INIT([libctf library], 1.2.0-pre)
+AC_INIT([libctf], 1.2.0)
 AC_CONFIG_SRCDIR(ctf-impl.h)
 AC_CONFIG_MACRO_DIR(../config)
 AC_CONFIG_MACRO_DIR(../bfd)
index 20971f4275b2fdf76f228229c59ba5c7006bc0a6..9611e367fde97f49d23236e459ffce5a2162d3dc 100644 (file)
@@ -45,7 +45,7 @@ static const union _ctf_errlist_t
 } _ctf_errlist =
   {
    {
-#define _CTF_STR(n, s) s,
+#define _CTF_STR(n, s) N_(s),
 #include "ctf-error.h"
 #undef _CTF_STR
    }
@@ -70,7 +70,7 @@ ctf_errmsg (int error)
   else
     str = (const char *) strerror (error);
 
-  return (str ? str : "Unknown error");
+  return (str ? gettext (str) : _("Unknown error"));
 }
 
 int
index 35320d46f6606aad578a5d50570d21058e0bdbf0..faee039adc85d181e064feb965c0786d0bfd721f 100644 (file)
@@ -36,6 +36,7 @@
 #include <elf.h>
 #include <bfd.h>
 #include "hashtab.h"
+#include "ctf-intl.h"
 
 #ifdef __cplusplus
 extern "C"
diff --git a/libctf/ctf-intl.h b/libctf/ctf-intl.h
new file mode 100644 (file)
index 0000000..af74872
--- /dev/null
@@ -0,0 +1,68 @@
+/* ctf-intl.h - libctf specific header for gettext code.
+   Copyright (C) 1998-2020 Free Software Foundation, Inc.
+
+   Written by Tom Tromey <tromey@cygnus.com>
+
+   This file is part of libctf.
+
+   This library is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   It is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this file; see the file COPYING.  If not, write to the
+   Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#ifndef _CTF_INTL_H
+#define _CTF_INTL_H
+
+#ifdef ENABLE_NLS
+# include <libintl.h>
+/* Note the redefinition of gettext and ngettext here to use PACKAGE.
+
+   This is because the code in this directory is used to build a
+   library which will be linked with code in other directories to form
+   programs.  We want to maintain a separate translation file for this
+   directory however, rather than being forced to merge it with that
+   of any program linked to libopcodes.  This is a library, so it
+   cannot depend on the catalog currently loaded.
+
+   In order to do this, we have to make sure that when we extract
+   messages we use the LIBCTF domain rather than the domain of the
+   program that included the opcodes library, (eg OBJDUMP).  Hence we
+   use dgettext (PACKAGE, String) and define PACKAGE to be 'libctf'.
+   (See the code in configure).  */
+# undef gettext
+# define gettext(Msgid) dgettext (PACKAGE, Msgid)
+# undef ngettext
+# define ngettext(Msgid1, Msgid2, n) dngettext (PACKAGE, Msgid1, Msgid2, n)
+# define _(String) gettext (String)
+# ifdef gettext_noop
+#  define N_(String) gettext_noop (String)
+# else
+#  define N_(String) String
+# endif
+#else
+# define gettext(Msgid) (Msgid)
+# define dgettext(Domainname, Msgid) (Msgid)
+# define dcgettext(Domainname, Msgid, Category) (Msgid)
+# define ngettext(Msgid1, Msgid2, n) \
+  (n == 1 ? Msgid1 : Msgid2)
+# define dngettext(Domainname, Msgid1, Msgid2, n) \
+  (n == 1 ? Msgid1 : Msgid2)
+# define dcngettext(Domainname, Msgid1, Msgid2, n, Category) \
+  (n == 1 ? Msgid1 : Msgid2)
+# define textdomain(Domainname) do {} while (0)
+# define bindtextdomain(Domainname, Dirname) do {} while (0)
+# define _(String) (String)
+# define N_(String) String
+#endif
+
+#endif /* _CTF_INTL_H */
This page took 0.033548 seconds and 4 git commands to generate.