# HG changeset patch # User Akos Ladanyi # Date 1215718733 -3600 # Node ID 390d05b2d25c3b3e5ecfc0750c01008d123bcee8 # Parent 244d8c60b997f711d9dfaf40805cbecf03b777a7 Upgrade gettext infrastructure. diff -r 244d8c60b997 -r 390d05b2d25c ChangeLog --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ChangeLog Thu Jul 10 20:38:53 2008 +0100 @@ -0,0 +1,7 @@ +2008-07-10 gettextize + + * Makefile.am (ACLOCAL_AMFLAGS): New variable. + (EXTRA_DIST): Add build-aux/config.rpath. + * configure.ac (AC_CONFIG_FILES): Add po/Makefile.in. + (AM_GNU_GETTEXT_VERSION): Bump to 0.17. + diff -r 244d8c60b997 -r 390d05b2d25c Makefile.am --- a/Makefile.am Thu Jul 10 18:53:00 2008 +0100 +++ b/Makefile.am Thu Jul 10 20:38:53 2008 +0100 @@ -1,5 +1,7 @@ AM_CPPFLAGS = -I$(top_srcdir) -DLOCALEDIR=\""$(datadir)/locale"\" +ACLOCAL_AMFLAGS = -I m4 + SUBDIRS = po m4 bin_PROGRAMS = glemon @@ -102,7 +104,8 @@ LICENSE \ NEWS \ README \ - ABOUT-NLS + ABOUT-NLS \ + build-aux/config.rpath MRPROPERFILES = \ Makefile.in \ diff -r 244d8c60b997 -r 390d05b2d25c configure.ac --- a/configure.ac Thu Jul 10 18:53:00 2008 +0100 +++ b/configure.ac Thu Jul 10 20:38:53 2008 +0100 @@ -20,7 +20,7 @@ dnl Checks for programs. AC_PROG_CXX AC_PROG_CC -AM_GNU_GETTEXT_VERSION([0.14.2]) +AM_GNU_GETTEXT_VERSION([0.17]) AM_GNU_GETTEXT([external]) dnl Checks for libraries. diff -r 244d8c60b997 -r 390d05b2d25c gettext.h --- a/gettext.h Thu Jul 10 18:53:00 2008 +0100 +++ b/gettext.h Thu Jul 10 20:38:53 2008 +0100 @@ -1,8 +1,8 @@ /* Convenience header for conditional use of GNU . - Copyright (C) 1995-1998, 2000-2002, 2004 Free Software Foundation, Inc. + Copyright (C) 1995-1998, 2000-2002, 2004-2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published + under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. @@ -11,7 +11,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Library General Public + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ @@ -25,6 +25,18 @@ /* Get declarations of GNU message catalog functions. */ # include +/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by + the gettext() and ngettext() macros. This is an alternative to calling + textdomain(), and is useful for libraries. */ +# ifdef DEFAULT_TEXT_DOMAIN +# undef gettext +# define gettext(Msgid) \ + dgettext (DEFAULT_TEXT_DOMAIN, Msgid) +# undef ngettext +# define ngettext(Msgid1, Msgid2, N) \ + dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N) +# endif + #else /* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which @@ -53,17 +65,22 @@ On pre-ANSI systems without 'const', the config.h file is supposed to contain "#define const". */ # define gettext(Msgid) ((const char *) (Msgid)) -# define dgettext(Domainname, Msgid) ((const char *) (Msgid)) -# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid)) +# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid)) +# define dcgettext(Domainname, Msgid, Category) \ + ((void) (Category), dgettext (Domainname, Msgid)) # define ngettext(Msgid1, Msgid2, N) \ - ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) + ((N) == 1 \ + ? ((void) (Msgid2), (const char *) (Msgid1)) \ + : ((void) (Msgid1), (const char *) (Msgid2))) # define dngettext(Domainname, Msgid1, Msgid2, N) \ - ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) + ((void) (Domainname), ngettext (Msgid1, Msgid2, N)) # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ - ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) + ((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N)) # define textdomain(Domainname) ((const char *) (Domainname)) -# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) -# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset)) +# define bindtextdomain(Domainname, Dirname) \ + ((void) (Domainname), (const char *) (Dirname)) +# define bind_textdomain_codeset(Domainname, Codeset) \ + ((void) (Domainname), (const char *) (Codeset)) #endif @@ -76,4 +93,179 @@ initializer for static 'char[]' or 'const char[]' variables. */ #define gettext_noop(String) String +/* The separator between msgctxt and msgid in a .mo file. */ +#define GETTEXT_CONTEXT_GLUE "\004" + +/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a + MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be + short and rarely need to change. + The letter 'p' stands for 'particular' or 'special'. */ +#ifdef DEFAULT_TEXT_DOMAIN +# define pgettext(Msgctxt, Msgid) \ + pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) +#else +# define pgettext(Msgctxt, Msgid) \ + pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) +#endif +#define dpgettext(Domainname, Msgctxt, Msgid) \ + pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) +#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \ + pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category) +#ifdef DEFAULT_TEXT_DOMAIN +# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ + npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) +#else +# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ + npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) +#endif +#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ + npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) +#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ + npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +pgettext_aux (const char *domain, + const char *msg_ctxt_id, const char *msgid, + int category) +{ + const char *translation = dcgettext (domain, msg_ctxt_id, category); + if (translation == msg_ctxt_id) + return msgid; + else + return translation; +} + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +npgettext_aux (const char *domain, + const char *msg_ctxt_id, const char *msgid, + const char *msgid_plural, unsigned long int n, + int category) +{ + const char *translation = + dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); + if (translation == msg_ctxt_id || translation == msgid_plural) + return (n == 1 ? msgid : msgid_plural); + else + return translation; +} + +/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID + can be arbitrary expressions. But for string literals these macros are + less efficient than those above. */ + +#include + +#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \ + (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \ + /* || __STDC_VERSION__ >= 199901L */ ) + +#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS +#include +#endif + +#define pgettext_expr(Msgctxt, Msgid) \ + dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES) +#define dpgettext_expr(Domainname, Msgctxt, Msgid) \ + dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +dcpgettext_expr (const char *domain, + const char *msgctxt, const char *msgid, + int category) +{ + size_t msgctxt_len = strlen (msgctxt) + 1; + size_t msgid_len = strlen (msgid) + 1; + const char *translation; +#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + char msg_ctxt_id[msgctxt_len + msgid_len]; +#else + char buf[1024]; + char *msg_ctxt_id = + (msgctxt_len + msgid_len <= sizeof (buf) + ? buf + : (char *) malloc (msgctxt_len + msgid_len)); + if (msg_ctxt_id != NULL) +#endif + { + memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); + msg_ctxt_id[msgctxt_len - 1] = '\004'; + memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); + translation = dcgettext (domain, msg_ctxt_id, category); +#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + if (msg_ctxt_id != buf) + free (msg_ctxt_id); +#endif + if (translation != msg_ctxt_id) + return translation; + } + return msgid; +} + +#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \ + dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) +#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ + dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +dcnpgettext_expr (const char *domain, + const char *msgctxt, const char *msgid, + const char *msgid_plural, unsigned long int n, + int category) +{ + size_t msgctxt_len = strlen (msgctxt) + 1; + size_t msgid_len = strlen (msgid) + 1; + const char *translation; +#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + char msg_ctxt_id[msgctxt_len + msgid_len]; +#else + char buf[1024]; + char *msg_ctxt_id = + (msgctxt_len + msgid_len <= sizeof (buf) + ? buf + : (char *) malloc (msgctxt_len + msgid_len)); + if (msg_ctxt_id != NULL) +#endif + { + memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); + msg_ctxt_id[msgctxt_len - 1] = '\004'; + memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); + translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); +#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + if (msg_ctxt_id != buf) + free (msg_ctxt_id); +#endif + if (!(translation == msg_ctxt_id || translation == msgid_plural)) + return translation; + } + return (n == 1 ? msgid : msgid_plural); +} + #endif /* _LIBGETTEXT_H */ diff -r 244d8c60b997 -r 390d05b2d25c graph-displayer.cc --- a/graph-displayer.cc Thu Jul 10 18:53:00 2008 +0100 +++ b/graph-displayer.cc Thu Jul 10 20:38:53 2008 +0100 @@ -25,7 +25,7 @@ #include #include -#include +#include "gettext.h" #define MAIN_PART diff -r 244d8c60b997 -r 390d05b2d25c m4/ChangeLog --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m4/ChangeLog Thu Jul 10 20:38:53 2008 +0100 @@ -0,0 +1,12 @@ +2008-07-10 gettextize + + * gettext.m4: New file, from gettext-0.17. + * iconv.m4: New file, from gettext-0.17. + * lib-ld.m4: New file, from gettext-0.17. + * lib-link.m4: New file, from gettext-0.17. + * lib-prefix.m4: New file, from gettext-0.17. + * nls.m4: New file, from gettext-0.17. + * po.m4: New file, from gettext-0.17. + * progtest.m4: New file, from gettext-0.17. + * Makefile.am (EXTRA_DIST): Add the new files. + diff -r 244d8c60b997 -r 390d05b2d25c m4/Makefile.am --- a/m4/Makefile.am Thu Jul 10 18:53:00 2008 +0100 +++ b/m4/Makefile.am Thu Jul 10 20:38:53 2008 +0100 @@ -1,30 +1,9 @@ EXTRA_DIST = \ - codeset.m4 \ gettext.m4 \ - glibc21.m4 \ - glibc2.m4 \ iconv.m4 \ - intdiv0.m4 \ - intmax.m4 \ - inttypes_h.m4 \ - inttypes.m4 \ - inttypes-pri.m4 \ - isc-posix.m4 \ - lcmessage.m4 \ lib-ld.m4 \ lib-link.m4 \ lib-prefix.m4 \ - longdouble.m4 \ - longlong.m4 \ nls.m4 \ po.m4 \ - printf-posix.m4 \ - progtest.m4 \ - signed.m4 \ - size_max.m4 \ - stdint_h.m4 \ - uintmax_t.m4 \ - ulonglong.m4 \ - wchar_t.m4 \ - wint_t.m4 \ - xsize.m4 + progtest.m4 diff -r 244d8c60b997 -r 390d05b2d25c po/ChangeLog --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/po/ChangeLog Thu Jul 10 20:38:53 2008 +0100 @@ -0,0 +1,11 @@ +2008-07-10 gettextize + + * Makefile.in.in: New file, from gettext-0.17. + * boldquot.sed: New file, from gettext-0.17. + * en@boldquot.header: New file, from gettext-0.17. + * en@quot.header: New file, from gettext-0.17. + * insert-header.sin: New file, from gettext-0.17. + * quot.sed: New file, from gettext-0.17. + * remove-potcdate.sin: New file, from gettext-0.17. + * Rules-quot: New file, from gettext-0.17. +