| Since we do not use relocation (and it was not easy to get to compile on | |
| Windows) we have removed it, as well as OS/2 compatibility. Also, we | |
| do not install or use locale.alias, and charset.alias is compiled in | |
| (via charsetalias.h) rather than read at runtime. | |
| Since the packages will need libintl.h, we need to install it. We also | |
| need to ensure that we get our version and not, e.g. the Solaris version. | |
| Since this is made with visibility hidden, we need to add visibility | |
| to some entry points. | |
| On Windows we needed to override the way the locale_charset is found, | |
| and map some Windows locale names to XPG ones. And we use localeCP | |
| not getACP, since the latter refers to the default codepage | |
| irrespective of locales. | |
| Various small changes were made to avoid warnings. | |
| BDR | |
| One more change for macOS: the locale detection is simply off-loaded | |
| to locale2charset, because the built-in detection in gettext doesn't work. | |
| This also ensures that R and gettext are in sync wrt the charset used. | |
| SU | |
| diff -ru intl/dcigettext.c ../extra/intl/dcigettext.c | |
| --- intl/dcigettext.c 2007-10-21 19:41:41.000000000 +0100 | |
| +++ ../extra/intl/dcigettext.c 2008-01-13 14:39:54.703125000 +0000 | |
| @@ -152,7 +152,10 @@ | |
| # if VMS | |
| # define getcwd(buf, max) (getcwd) (buf, max, 0) | |
| # else | |
| +/* This is naughty if already declared, but harmful on Win64 */ | |
| +# ifndef _WIN64 | |
| char *getcwd (); | |
| +# endif | |
| # endif | |
| # endif | |
| # ifndef HAVE_STPCPY | |
| @@ -269,6 +272,9 @@ | |
| size_t translation_length; | |
| /* Pointer to the string in question. */ | |
| +#ifdef __GNUC__ | |
| + __extension__ | |
| +#endif | |
| char msgid[ZERO]; | |
| }; | |
| @@ -1535,6 +1541,22 @@ | |
| locale_defaulted = 1; | |
| } | |
| } | |
| +# ifdef _WIN32 | |
| + /* Need to translate some Windows locale names */ | |
| + if(strcmp(locale, "chs") == 0) locale = "zh_CN"; | |
| + if(strcmp(locale, "chinese") == 0) locale = "zh_TW"; | |
| + if(strcmp(locale, "cht") == 0) locale = "zh_TW"; | |
| + if(strcmp(locale, "ptb") == 0) locale = "pt_BR"; | |
| + /* Vista has got a lot pickier, so e.g. 'LC_ALL=ru' does not work */ | |
| + if(strncmp(locale, "de", 2) == 0) locale = "de_DE"; | |
| + if(strcmp(locale, "esp") == 0) locale = "es_ES"; | |
| + if(strncmp(locale, "fr", 2) == 0) locale = "fr_FR"; | |
| + if(strncmp(locale, "it", 2) == 0) locale = "it_IT"; | |
| + if(strncmp(locale, "ko", 2) == 0) locale = "ko_KO"; | |
| + if(strcmp(locale, "jpn") == 0) locale = "ja_JP"; | |
| + if(strncmp(locale, "rus", 3) == 0) locale = "ru_RU"; | |
| + if(strcmp(locale, "spanish") == 0) locale = "es_ES"; | |
| +# endif | |
| # endif | |
| #endif | |
| diff -ru intl/dgettext.c ../extra/intl/dgettext.c | |
| --- intl/dgettext.c 2005-05-20 22:05:58.000000000 +0100 | |
| +++ ../extra/intl/dgettext.c 2007-05-12 05:55:38.000000000 +0100 | |
| @@ -46,7 +46,10 @@ | |
| /* Look up MSGID in the DOMAINNAME message catalog of the current | |
| LC_MESSAGES locale. */ | |
| -char * | |
| +#ifdef HAVE_VISIBILITY_ATTRIBUTE | |
| +__attribute__ ((visibility ("default"))) | |
| +#endif | |
| +char * | |
| DGETTEXT (const char *domainname, const char *msgid) | |
| { | |
| return DCGETTEXT (domainname, msgid, LC_MESSAGES); | |
| diff -ru intl/finddomain.c ../extra/intl/finddomain.c | |
| --- intl/finddomain.c 2007-10-13 16:55:41.000000000 +0100 | |
| +++ ../extra/intl/finddomain.c 2008-01-13 15:02:30.468750000 +0000 | |
| @@ -67,7 +67,9 @@ | |
| const char *territory; | |
| const char *codeset; | |
| const char *normalized_codeset; | |
| +#ifdef NOT_USED | |
| const char *alias_value; | |
| +#endif | |
| int mask; | |
| /* LOCALE can consist of up to four recognized parts for the XPG syntax: | |
| @@ -120,6 +122,7 @@ | |
| /* NOTREACHED */ | |
| } | |
| +#ifdef NOT_USED /* R change */ | |
| /* See whether the locale value is an alias. If yes its value | |
| *overwrites* the alias name. No test for the original value is | |
| done. */ | |
| @@ -139,6 +142,7 @@ | |
| memcpy (locale, alias_value, len); | |
| #endif | |
| } | |
| +#endif | |
| /* Now we determine the single parts of the locale name. First | |
| look for the language. Termination symbols are `_', '.', and `@'. */ | |
| @@ -178,9 +182,12 @@ | |
| } | |
| } | |
| + | |
| +#ifdef NOT_USED | |
| /* The room for an alias was dynamically allocated. Free it now. */ | |
| if (alias_value != NULL) | |
| free (locale); | |
| +#endif | |
| out: | |
| /* The space for normalized_codeset is dynamically allocated. Free it. */ | |
| diff -ru intl/gettext.c ../extra/intl/gettext.c | |
| --- intl/gettext.c 2005-05-20 22:05:58.000000000 +0100 | |
| +++ ../extra/intl/gettext.c 2007-05-12 05:56:24.000000000 +0100 | |
| @@ -51,6 +51,9 @@ | |
| /* Look up MSGID in the current default message catalog for the current | |
| LC_MESSAGES locale. If not found, returns MSGID itself (the default | |
| text). */ | |
| +#ifdef HAVE_VISIBILITY_ATTRIBUTE | |
| +__attribute__ ((visibility ("default"))) | |
| +#endif | |
| char * | |
| GETTEXT (const char *msgid) | |
| { | |
| diff -ru intl/gettextP.h ../extra/intl/gettextP.h | |
| --- intl/gettextP.h 2007-10-13 17:18:11.000000000 +0100 | |
| +++ ../extra/intl/gettextP.h 2008-01-13 14:36:23.671875000 +0000 | |
| @@ -214,6 +214,9 @@ | |
| struct binding *next; | |
| char *dirname; | |
| char *codeset; | |
| +#ifdef __GNUC__ | |
| + __extension__ | |
| +#endif | |
| char domainname[ZERO]; | |
| }; | |
| diff -ru intl/l10nflist.c ../extra/intl/l10nflist.c | |
| --- intl/l10nflist.c 2006-06-23 17:29:25.000000000 +0100 | |
| +++ ../extra/intl/l10nflist.c 2007-08-21 09:38:31.656250000 +0100 | |
| @@ -318,10 +318,9 @@ | |
| if (dirlist_count > 1) | |
| { | |
| /* Iterate over all elements of the DIRLIST. */ | |
| - char *dir = NULL; | |
| + char *dir = NULL, *nd = (char *) dirlist; | |
| - while ((dir = __argz_next ((char *) dirlist, dirlist_len, dir)) | |
| - != NULL) | |
| + while ((dir = __argz_next (nd, dirlist_len, dir)) != NULL) | |
| retval->successor[entries++] | |
| = _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1, | |
| cnt, language, territory, codeset, | |
| diff -ru intl/localcharset.c ../extra/intl/localcharset.c | |
| --- intl/localcharset.c 2006-10-18 12:56:41.000000000 +0100 | |
| +++ ../extra/intl/localcharset.c 2008-01-13 14:36:25.171875000 +0000 | |
| @@ -19,7 +19,9 @@ | |
| /* Written by Bruno Haible <bruno@clisp.org>. */ | |
| -#include <config.h> | |
| +#ifdef HAVE_CONFIG_H | |
| +# include <config.h> | |
| +#endif | |
| /* Specification. */ | |
| #include "localcharset.h" | |
| @@ -65,10 +67,12 @@ | |
| # define relocate(pathname) (pathname) | |
| #endif | |
| +#if 0 | |
| /* Get LIBDIR. */ | |
| #ifndef LIBDIR | |
| # include "configmake.h" | |
| #endif | |
| +#endif | |
| #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ | |
| /* Win32, Cygwin, OS/2, DOS */ | |
| @@ -112,6 +116,9 @@ | |
| if (cp == NULL) | |
| { | |
| #if !(defined VMS || defined WIN32_NATIVE || defined __CYGWIN__) | |
| +/* we convert charset.alias to a header file at compile time */ | |
| +#include "charsetalias.h" | |
| +#if 0 | |
| FILE *fp; | |
| const char *dir; | |
| const char *base = "charset.alias"; | |
| @@ -209,7 +216,7 @@ | |
| if (file_name != NULL) | |
| free (file_name); | |
| - | |
| +#endif | |
| #else | |
| # if defined VMS | |
| @@ -280,6 +287,8 @@ | |
| If the canonical name cannot be determined, the result is a non-canonical | |
| name. */ | |
| +extern unsigned int localeCP; /* from Defn.h */ | |
| + | |
| #ifdef STATIC | |
| STATIC | |
| #endif | |
| @@ -377,8 +386,9 @@ | |
| static char buf[2 + 10 + 1]; | |
| - /* Woe32 has a function returning the locale's codepage as a number. */ | |
| - sprintf (buf, "CP%u", GetACP ()); | |
| + /* Woe32 has a function returning the locale's codepage as a number. | |
| + sprintf (buf, "CP%u", GetACP ()); */ | |
| + sprintf (buf, "CP%u", localeCP); | |
| codeset = buf; | |
| #elif defined OS2 | |
| diff -ru intl/localename.c ../extra/intl/localename.c | |
| --- intl/localename.c 2007-06-07 20:49:32.000000000 +0100 | |
| +++ ../extra/intl/localename.c 2008-01-13 14:36:26.000000000 +0000 | |
| @@ -20,7 +20,9 @@ | |
| /* Win32 code written by Tor Lillqvist <tml@iki.fi>. */ | |
| /* MacOS X code written by Bruno Haible <bruno@clisp.org>. */ | |
| -#include <config.h> | |
| +#ifdef HAVE_CONFIG_H | |
| +# include <config.h> | |
| +#endif | |
| /* Specification. */ | |
| #ifdef IN_LIBINTL | |
| diff -ru intl/lock.c ../extra/intl/lock.c | |
| --- intl/lock.c 2006-10-09 13:00:44.000000000 +0100 | |
| +++ ../extra/intl/lock.c 2007-09-02 04:56:00.338369300 +0100 | |
| @@ -359,7 +359,7 @@ | |
| /* -------------------------- gl_once_t datatype -------------------------- */ | |
| -static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT; | |
| +static const pthread_once_t fresh_once = {PTHREAD_ONCE_INIT}; | |
| int | |
| glthread_once_singlethreaded (pthread_once_t *once_control) | |
| diff -ru intl/ngettext.c ../extra/intl/ngettext.c | |
| --- intl/ngettext.c 2005-05-20 22:05:58.000000000 +0100 | |
| +++ ../extra/intl/ngettext.c 2007-05-12 07:34:56.562500000 +0100 | |
| @@ -53,6 +53,9 @@ | |
| /* Look up MSGID in the current default message catalog for the current | |
| LC_MESSAGES locale. If not found, returns MSGID itself (the default | |
| text). */ | |
| +#ifdef HAVE_VISIBILITY_ATTRIBUTE | |
| +__attribute__ ((visibility ("default"))) | |
| +#endif | |
| char * | |
| NGETTEXT (const char *msgid1, const char *msgid2, unsigned long int n) | |
| { | |
| Index: localcharset.c | |
| =================================================================== | |
| --- localcharset.c (revision 44486) | |
| +++ localcharset.c (working copy) | |
| @@ -288,6 +288,9 @@ | |
| name. */ | |
| extern unsigned int localeCP; /* from Defn.h */ | |
| +#if __APPLE__ /* others could use this, too ... */ | |
| +extern const char *locale2charset(char*); | |
| +#endif | |
| #ifdef STATIC | |
| STATIC | |
| @@ -295,6 +298,9 @@ | |
| const char * | |
| locale_charset (void) | |
| { | |
| +#if __APPLE__ | |
| + return locale2charset(NULL); | |
| +#else | |
| const char *codeset; | |
| const char *aliases; | |
| @@ -468,4 +474,5 @@ | |
| codeset = "ASCII"; | |
| return codeset; | |
| +#endif /* ! __APPLE__ */ | |
| } |