From: Bruno Haible Date: Mon, 16 Dec 2002 15:15:24 +0000 (+0000) Subject: Merge with glibc/intl. X-Git-Tag: v0.12~1199 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bca9d4974f6c4e71ba9ed600b138bef086a277bb;p=thirdparty%2Fgettext.git Merge with glibc/intl. --- diff --git a/intl/ChangeLog b/intl/ChangeLog index d08872acc..233f72b66 100644 --- a/intl/ChangeLog +++ b/intl/ChangeLog @@ -1,3 +1,65 @@ +2002-12-12 Bruno Haible + + * dcigettext.c (INTVARDEF): Correct fallback definition. + +2002-11-19 Ulrich Drepper + + * localealias.c (read_alias_file): Use only about 400 bytes of stack + space instead of 16k. + +2002-10-30 Jakub Jelinek + + * finddomain.c (free_mem): Use libc_freeres_fn macro, remove + text_set_element. + * dcigettext.c (free_mem): Likewise. + +2002-10-25 Jakub Jelinek + + * localealias.c (libc_freeres_ptr): Define if !_LIBC. + (string_space, map): Add libc_freeres_ptr. + (free_mem): Remove. + +2002-09-19 Bruno Haible + + * dcigettext.c (DCIGETTEXT): Restore errno only right before + returning. + +2002-09-01 Roland McGrath + + * localealias.c [__GNUC__]: #undef alloca before #define. + +2002-08-30 Roland McGrath + + * dcigettext.c (DCIGETTEXT) [_LIBC]: Check for bogus CATEGORY. + [_LIBC] (category_to_name): Don't define the function. Instead define + a macro using _nl_category_names. + +2002-08-04 Ulrich Drepper + + * dcigettext.c: Define _nl_default_dirname_internal as hidden alias + and use it. + * bindtextdom.c: Use _nl_default_dirname_internal. + +2002-08-03 Roland McGrath + + * dcigettext.c (guess_category_value): Use __current_locale_name + instead of calling setlocale. + +2002-08-02 Roland McGrath + + * loadmsgcat.c (_nl_init_domain_conv): Use _NL_CURRENT. + +2002-07-30 Roland McGrath + + * loadmsgcat.c [__GNUC__]: #undef alloca before defining it. + +2002-05-01 Ulrich Drepper + + Revert 2002-04-09 change. + * dcngettext.c (__dcngettext_internal): Remove alias. + * dngettext.c: Use __dcngettext instead of __dcngettext_internal. + * ngettext.c: Likewise. + 2002-11-07 Bruno Haible * Makefile.in (mostlyclean): Remove object files on OS/2 as well. @@ -181,6 +243,7 @@ __argz_stringify. 2002-04-08 Ulrich Drepper + * dcgettext.c (__dcgettext): Use INTDEF to define alias. * dgettext.c: Call __dcgettext_internal instead of __dcgettext. * gettext.c: Likewise. diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c index d582ce11d..250f5e863 100644 --- a/intl/bindtextdom.c +++ b/intl/bindtextdom.c @@ -58,6 +58,11 @@ /* Contains the default location of the message catalogs. */ extern const char _nl_default_dirname[]; +#ifdef _LIBC +extern const char _nl_default_dirname_internal[] attribute_hidden; +#else +# define INTUSE(name) name +#endif /* List with bindings of specific domains. */ extern struct binding *_nl_domain_bindings; @@ -146,8 +151,8 @@ set_binding_values (domainname, dirnamep, codesetp) char *result = binding->dirname; if (strcmp (dirname, result) != 0) { - if (strcmp (dirname, _nl_default_dirname) == 0) - result = (char *) _nl_default_dirname; + if (strcmp (dirname, INTUSE(_nl_default_dirname)) == 0) + result = (char *) INTUSE(_nl_default_dirname); else { #if defined _LIBC || defined HAVE_STRDUP @@ -162,7 +167,7 @@ set_binding_values (domainname, dirnamep, codesetp) if (__builtin_expect (result != NULL, 1)) { - if (binding->dirname != _nl_default_dirname) + if (binding->dirname != INTUSE(_nl_default_dirname)) free (binding->dirname); binding->dirname = result; @@ -216,7 +221,7 @@ set_binding_values (domainname, dirnamep, codesetp) { /* Simply return the default values. */ if (dirnamep) - *dirnamep = _nl_default_dirname; + *dirnamep = INTUSE(_nl_default_dirname); if (codesetp) *codesetp = NULL; } @@ -238,11 +243,11 @@ set_binding_values (domainname, dirnamep, codesetp) if (dirname == NULL) /* The default value. */ - dirname = _nl_default_dirname; + dirname = INTUSE(_nl_default_dirname); else { - if (strcmp (dirname, _nl_default_dirname) == 0) - dirname = _nl_default_dirname; + if (strcmp (dirname, INTUSE(_nl_default_dirname)) == 0) + dirname = INTUSE(_nl_default_dirname); else { char *result; @@ -265,7 +270,7 @@ set_binding_values (domainname, dirnamep, codesetp) } else /* The default value. */ - new_binding->dirname = (char *) _nl_default_dirname; + new_binding->dirname = (char *) INTUSE(_nl_default_dirname); new_binding->codeset_cntr = 0; @@ -321,7 +326,7 @@ set_binding_values (domainname, dirnamep, codesetp) if (0) { failed_codeset: - if (new_binding->dirname != _nl_default_dirname) + if (new_binding->dirname != INTUSE(_nl_default_dirname)) free (new_binding->dirname); failed_dirname: free (new_binding); diff --git a/intl/dcigettext.c b/intl/dcigettext.c index f2f01524c..55aaa060f 100644 --- a/intl/dcigettext.c +++ b/intl/dcigettext.c @@ -271,6 +271,13 @@ transcmp (p1, p2) } #endif +#ifndef INTVARDEF +# define INTVARDEF(name) +#endif +#ifndef INTUSE +# define INTUSE(name) name +#endif + /* Name of the default domain used for gettext(3) prior any call to textdomain(3). The default value for this is "messages". */ const char _nl_default_default_domain[] attribute_hidden = "messages"; @@ -284,6 +291,7 @@ const char *_nl_current_default_domain attribute_hidden extern const char _nl_default_dirname[]; #else const char _nl_default_dirname[] = LOCALEDIR; +INTVARDEF (_nl_default_dirname) #endif /* List with bindings of specific domains created by bindtextdomain() @@ -296,10 +304,15 @@ static char *plural_lookup PARAMS ((struct loaded_l10nfile *domain, const char *translation, size_t translation_len)) internal_function; -static const char *category_to_name PARAMS ((int category)) internal_function; static const char *guess_category_value PARAMS ((int category, const char *categoryname)) internal_function; +#ifdef _LIBC +# include "../locale/localeinfo.h" +# define category_to_name(category) _nl_category_names[category] +#else +static const char *category_to_name PARAMS ((int category)) internal_function; +#endif /* For those loosing systems which don't have `alloca' we have to add @@ -437,6 +450,15 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) if (msgid1 == NULL) return NULL; +#ifdef _LIBC + if (category < 0 || category >= __LC_LAST || category == LC_ALL) + /* Bogus. */ + return (plural == 0 + ? (char *) msgid1 + /* Use the Germanic plural rule. */ + : n == 1 ? (char *) msgid1 : (char *) msgid2); +#endif + __libc_rwlock_rdlock (_nl_state_lock); /* If DOMAINNAME is NULL, we are interested in the default domain. If @@ -500,7 +522,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) } if (binding == NULL) - dirname = (char *) _nl_default_dirname; + dirname = (char *) INTUSE(_nl_default_dirname); else if (IS_ABSOLUTE_PATH (binding->dirname)) dirname = binding->dirname; else @@ -636,7 +658,6 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) /* Found the translation of MSGID1 in domain DOMAIN: starting at RETVAL, RETLEN bytes. */ FREE_BLOCKS (block_list); - __set_errno (saved_errno); #if defined HAVE_TSEARCH || defined _LIBC if (foundp == NULL) { @@ -675,6 +696,8 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) (*foundp)->translation_length = retlen; } #endif + __set_errno (saved_errno); + /* Now deal with plural. */ if (plural) retval = plural_lookup (domain, n, retval, retlen); @@ -1038,7 +1061,7 @@ plural_lookup (domain, n, translation, translation_len) return (char *) p; } - +#ifndef _LIBC /* Return string representation of locale CATEGORY. */ static const char * internal_function @@ -1098,6 +1121,7 @@ category_to_name (category) return retval; } +#endif /* Guess value of current locale from value of the environment variables. */ static const char * @@ -1120,7 +1144,7 @@ guess_category_value (category, categoryname) `LC_xxx', and `LANG'. On some systems this can be done by the `setlocale' function itself. */ #ifdef _LIBC - retval = setlocale (category, NULL); + retval = __current_locale_name (category); #else retval = _nl_locale_name (category, categoryname); #endif @@ -1170,8 +1194,7 @@ mempcpy (dest, src, n) #ifdef _LIBC /* If we want to free all resources we have to do some work at program's end. */ -static void __attribute__ ((unused)) -free_mem (void) +libc_freeres_fn (free_mem) { void *old; @@ -1179,7 +1202,7 @@ free_mem (void) { struct binding *oldp = _nl_domain_bindings; _nl_domain_bindings = _nl_domain_bindings->next; - if (oldp->dirname != _nl_default_dirname) + if (oldp->dirname != INTUSE(_nl_default_dirname)) /* Yes, this is a pointer comparison. */ free (oldp->dirname); free (oldp->codeset); @@ -1201,6 +1224,4 @@ free_mem (void) free (old); } } - -text_set_element (__libc_subfreeres, free_mem); #endif diff --git a/intl/dcngettext.c b/intl/dcngettext.c index 17d9ce3e2..3a3404e2c 100644 --- a/intl/dcngettext.c +++ b/intl/dcngettext.c @@ -56,6 +56,5 @@ DCNGETTEXT (domainname, msgid1, msgid2, n, category) #ifdef _LIBC /* Alias for function name in GNU C Library. */ -INTDEF(__dcngettext) weak_alias (__dcngettext, dcngettext); #endif diff --git a/intl/dngettext.c b/intl/dngettext.c index 0afbd2e10..67fd030f2 100644 --- a/intl/dngettext.c +++ b/intl/dngettext.c @@ -37,7 +37,7 @@ prefix. So we have to make a difference here. */ #ifdef _LIBC # define DNGETTEXT __dngettext -# define DCNGETTEXT INTUSE(__dcngettext) +# define DCNGETTEXT __dcngettext #else # define DNGETTEXT libintl_dngettext # define DCNGETTEXT libintl_dcngettext diff --git a/intl/finddomain.c b/intl/finddomain.c index 2f103d556..d24276442 100644 --- a/intl/finddomain.c +++ b/intl/finddomain.c @@ -178,8 +178,7 @@ _nl_find_domain (dirname, locale, domainname, domainbinding) #ifdef _LIBC -static void __attribute__ ((unused)) -free_mem (void) +libc_freeres_fn (free_mem) { struct loaded_l10nfile *runp = _nl_loaded_domains; @@ -193,6 +192,4 @@ free_mem (void) free (here); } } - -text_set_element (__libc_subfreeres, free_mem); #endif diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c index 516f5211b..a07d9de8a 100644 --- a/intl/loadmsgcat.c +++ b/intl/loadmsgcat.c @@ -34,6 +34,7 @@ #include #ifdef __GNUC__ +# undef alloca # define alloca __builtin_alloca # define HAVE_ALLOCA 1 #else @@ -820,7 +821,7 @@ _nl_init_domain_conv (domain_file, domain, domainbinding) if (outcharset == NULL || outcharset[0] == '\0') { # ifdef _LIBC - outcharset = (*_nl_current[LC_CTYPE])->values[_NL_ITEM_INDEX (CODESET)].string; + outcharset = _NL_CURRENT (LC_CTYPE, CODESET); # else # if HAVE_ICONV extern const char *locale_charset PARAMS ((void)); diff --git a/intl/localealias.c b/intl/localealias.c index 456e41e37..785540307 100644 --- a/intl/localealias.c +++ b/intl/localealias.c @@ -35,6 +35,7 @@ #include #ifdef __GNUC__ +# undef alloca # define alloca __builtin_alloca # define HAVE_ALLOCA 1 #else @@ -115,10 +116,14 @@ struct alias_map }; -static char *string_space; +#ifndef _LIBC +# define libc_freeres_ptr(decl) decl +#endif + +libc_freeres_ptr (static char *string_space); static size_t string_space_act; static size_t string_space_max; -static struct alias_map *map; +libc_freeres_ptr (static struct alias_map *map); static size_t nmap; static size_t maxmap; @@ -234,8 +239,10 @@ read_alias_file (fname, fname_len) a) we are only interested in the first two fields b) these fields must be usable as file names and so must not be that long - */ - char buf[BUFSIZ]; + We avoid a multi-kilobyte buffer here since this would use up + stack space which we might not have if the program ran out of + memory. */ + char buf[400]; char *alias; char *value; char *cp; @@ -244,19 +251,6 @@ read_alias_file (fname, fname_len) /* EOF reached. */ break; - /* Possibly not the whole line fits into the buffer. Ignore - the rest of the line. */ - if (strchr (buf, '\n') == NULL) - { - char altbuf[BUFSIZ]; - do - if (FGETS (altbuf, sizeof altbuf, fp) == NULL) - /* Make sure the inner loop will be left. The outer loop - will exit at the `feof' test. */ - break; - while (strchr (altbuf, '\n') == NULL); - } - cp = buf; /* Ignore leading white space. */ while (isspace ((unsigned char) cp[0])) @@ -340,6 +334,14 @@ read_alias_file (fname, fname_len) ++added; } } + + /* Possibly not the whole line fits into the buffer. Ignore + the rest of the line. */ + while (strchr (buf, '\n') == NULL) + if (FGETS (buf, sizeof buf, fp) == NULL) + /* Make sure the inner loop will be left. The outer loop + will exit at the `feof' test. */ + break; } /* Should we test for ferror()? I think we have to silently ignore @@ -373,19 +375,6 @@ extend_alias_table () } -#ifdef _LIBC -static void __attribute__ ((unused)) -free_mem (void) -{ - if (string_space != NULL) - free (string_space); - if (map != NULL) - free (map); -} -text_set_element (__libc_subfreeres, free_mem); -#endif - - static int alias_compare (map1, map2) const struct alias_map *map1; diff --git a/intl/ngettext.c b/intl/ngettext.c index 69fe1f747..17a27f4aa 100644 --- a/intl/ngettext.c +++ b/intl/ngettext.c @@ -44,7 +44,7 @@ prefix. So we have to make a difference here. */ #ifdef _LIBC # define NGETTEXT __ngettext -# define DCNGETTEXT INTUSE(__dcngettext) +# define DCNGETTEXT __dcngettext #else # define NGETTEXT libintl_ngettext # define DCNGETTEXT libintl_dcngettext