From a334319f6530564d22e775935d9c91663623a1b4 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 22 Dec 2004 20:10:10 +0000 Subject: (CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4. --- intl/Makefile | 53 +---- intl/bindtextdom.c | 28 ++- intl/dcgettext.c | 3 +- intl/dcigettext.c | 595 ++++++++++++++---------------------------------- intl/explodename.c | 4 +- intl/finddomain.c | 23 +- intl/gettextP.h | 45 ++-- intl/l10nflist.c | 7 +- intl/libintl.h | 10 +- intl/loadmsgcat.c | 172 ++++++++++++-- intl/locale.alias | 2 + intl/localealias.c | 7 +- intl/plural-exp.c | 4 +- intl/plural-exp.h | 4 +- intl/tst-codeset.sh | 9 +- intl/tst-gettext2.sh | 4 +- intl/tst-gettext3.c | 60 ----- intl/tst-gettext3.sh | 44 ---- intl/tst-gettext4-de.po | 8 - intl/tst-gettext4-fr.po | 8 - intl/tst-gettext4.c | 151 ------------ intl/tst-gettext4.sh | 44 ---- intl/tst-gettext5.c | 156 ------------- intl/tst-gettext5.sh | 43 ---- intl/tst-translit.sh | 5 +- 25 files changed, 415 insertions(+), 1074 deletions(-) delete mode 100644 intl/tst-gettext3.c delete mode 100644 intl/tst-gettext3.sh delete mode 100644 intl/tst-gettext4-de.po delete mode 100644 intl/tst-gettext4-fr.po delete mode 100644 intl/tst-gettext4.c delete mode 100755 intl/tst-gettext4.sh delete mode 100644 intl/tst-gettext5.c delete mode 100755 intl/tst-gettext5.sh (limited to 'intl') diff --git a/intl/Makefile b/intl/Makefile index 9da445aa38..32212c0e29 100644 --- a/intl/Makefile +++ b/intl/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1995-2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 1995-2002, 2003 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -25,22 +25,11 @@ routines = bindtextdom dcgettext dgettext gettext \ finddomain loadmsgcat localealias textdomain aux = l10nflist explodename plural plural-exp hash-string distribute = gmo.h gettextP.h hash-string.h loadinfo.h locale.alias \ - plural.y plural-exp.h plural-eval.c po2test.sed \ - tst-gettext.sh \ - tst-translit.sh translit.po \ - tst-gettext2.sh tstlang1.po tstlang2.po \ - tst-codeset.sh tstcodeset.po \ - tst-gettext3.sh \ - tst-gettext4.sh tst-gettext4-de.po tst-gettext4-fr.po \ - tst-gettext5.sh + plural.y plural-exp.h po2test.sed tst-gettext.sh tst-translit.sh \ + translit.po tst-gettext2.sh tstlang1.po tstlang2.po tstcodeset.po\ + tst-codeset.sh plural-eval.c -include ../Makeconfig - -multithread-test-srcs := tst-gettext4 tst-gettext5 -test-srcs := tst-gettext tst-translit tst-gettext2 tst-codeset tst-gettext3 -ifeq ($(have-thread-library),yes) -test-srcs += $(multithread-test-srcs) -endif +test-srcs := tst-gettext tst-translit tst-gettext2 tst-codeset tests = tst-ngettext before-compile = $(objpfx)msgs.h @@ -50,6 +39,8 @@ install-others = $(inst_msgcatdir)/locale.alias generated = msgs.h mtrace-tst-gettext tst-gettext.mtrace generated-dirs := domaindir localedir +include ../Makeconfig + ifneq (no,$(BISON)) plural.c: plural.y $(BISON) $(BISONFLAGS) $@ $^ @@ -65,10 +56,7 @@ ifeq (no,$(cross-compiling)) ifeq (yes,$(build-shared)) ifneq ($(strip $(MSGFMT)),:) tests: $(objpfx)tst-translit.out $(objpfx)tst-gettext2.out \ - $(objpfx)tst-codeset.out $(objpfx)tst-gettext3.out -ifeq ($(have-thread-library),yes) -tests: $(objpfx)tst-gettext4.out $(objpfx)tst-gettext5.out -endif + $(objpfx)tst-codeset.out ifneq (no,$(PERL)) tests: $(objpfx)mtrace-tst-gettext endif @@ -84,12 +72,6 @@ $(objpfx)tst-gettext2.out: tst-gettext2.sh $(objpfx)tst-gettext2 $(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/ $(objpfx)tst-codeset.out: tst-codeset.sh $(objpfx)tst-codeset $(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/ -$(objpfx)tst-gettext3.out: tst-gettext3.sh $(objpfx)tst-gettext3 - $(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/ -$(objpfx)tst-gettext4.out: tst-gettext4.sh $(objpfx)tst-gettext4 - $(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)intl/ -$(objpfx)tst-gettext5.out: tst-gettext5.sh $(objpfx)tst-gettext5 - $(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)intl/ endif endif @@ -98,30 +80,13 @@ $(objpfx)msgs.h: po2test.sed ../po/de.po LC_ALL=C sed -f $^ > $@ CFLAGS-tst-gettext.c = -DTESTSTRS_H=\"$(objpfx)msgs.h\" -CFLAGS-tst-translit.c = -DOBJPFX=\"$(objpfx)\" CFLAGS-tst-gettext2.c = -DOBJPFX=\"$(objpfx)\" +CFLAGS-tst-translit.c = -DOBJPFX=\"$(objpfx)\" CFLAGS-tst-codeset.c = -DOBJPFX=\"$(objpfx)\" -CFLAGS-tst-gettext3.c = -DOBJPFX=\"$(objpfx)\" -CFLAGS-tst-gettext4.c = -DOBJPFX=\"$(objpfx)\" -CFLAGS-tst-gettext5.c = -DOBJPFX=\"$(objpfx)\" - -ifeq ($(have-thread-library),yes) -ifeq (yes,$(build-shared)) -$(addprefix $(objpfx),$(multithread-test-srcs)): $(shared-thread-library) -else -$(addprefix $(objpfx),$(multithread-test-srcs)): $(static-thread-library) -endif -ifeq (yes,$(build-bounded)) -$(multithread-test-srcs:%=$(objpfx)%-bp): $(bounded-thread-library) -endif -endif $(objpfx)tst-translit.out: $(objpfx)tst-gettext.out $(objpfx)tst-gettext2.out: $(objpfx)tst-gettext.out $(objpfx)tst-codeset.out: $(objpfx)tst-gettext.out -$(objpfx)tst-gettext3.out: $(objpfx)tst-gettext.out -$(objpfx)tst-gettext4.out: $(objpfx)tst-gettext.out -$(objpfx)tst-gettext5.out: $(objpfx)tst-gettext.out CPPFLAGS += -D'LOCALEDIR="$(msgcatdir)"' \ -D'LOCALE_ALIAS_PATH="$(msgcatdir)"' diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c index fd527a180a..39256ed566 100644 --- a/intl/bindtextdom.c +++ b/intl/bindtextdom.c @@ -1,5 +1,5 @@ /* Implementation of the bindtextdomain(3) function - Copyright (C) 1995-1998, 2000, 2001, 2002, 2005 Free Software Foundation, Inc. + Copyright (C) 1995-1998, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -60,7 +60,9 @@ /* Contains the default location of the message catalogs. */ extern const char _nl_default_dirname[]; #ifdef _LIBC -libc_hidden_proto (_nl_default_dirname) +extern const char _nl_default_dirname_internal[] attribute_hidden; +#else +# define INTUSE(name) name #endif /* List with bindings of specific domains. */ @@ -150,8 +152,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 @@ -166,7 +168,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; @@ -207,6 +209,7 @@ set_binding_values (domainname, dirnamep, codesetp) free (binding->codeset); binding->codeset = result; + ++binding->codeset_cntr; modified = 1; } } @@ -219,7 +222,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; } @@ -241,11 +244,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; @@ -268,7 +271,9 @@ 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; if (codesetp) { @@ -290,6 +295,7 @@ set_binding_values (domainname, dirnamep, codesetp) memcpy (result, codeset, len); #endif codeset = result; + ++new_binding->codeset_cntr; } *codesetp = codeset; new_binding->codeset = (char *) codeset; @@ -321,7 +327,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/dcgettext.c b/intl/dcgettext.c index edf98b6973..55f81eb887 100644 --- a/intl/dcgettext.c +++ b/intl/dcgettext.c @@ -1,5 +1,5 @@ /* Implementation of the dcgettext(3) function. - Copyright (C) 1995-2002, 2005 Free Software Foundation, Inc. + Copyright (C) 1995-1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -57,5 +57,4 @@ DCGETTEXT (domainname, msgid, category) /* Alias for function name in GNU C Library. */ INTDEF(__dcgettext) weak_alias (__dcgettext, dcgettext); -libc_hidden_def (__dcgettext) #endif diff --git a/intl/dcigettext.c b/intl/dcigettext.c index cb2b1813a7..d7111729b9 100644 --- a/intl/dcigettext.c +++ b/intl/dcigettext.c @@ -1,5 +1,5 @@ /* Implementation of the internal dcigettext function. - Copyright (C) 1995-2005, 2006 Free Software Foundation, Inc. + Copyright (C) 1995-2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -172,26 +172,16 @@ static void *mempcpy PARAMS ((void *dest, const void *src, size_t n)); # define PATH_MAX _POSIX_PATH_MAX #endif -/* Whether to support different locales in different threads. */ -#if defined _LIBC || HAVE_NL_LOCALE_NAME -# define HAVE_PER_THREAD_LOCALE -#endif - /* This is the type used for the search tree where known translations are stored. */ struct known_translation_t { /* Domain in which to search. */ - const char *domainname; + char *domainname; /* The category. */ int category; -#ifdef HAVE_PER_THREAD_LOCALE - /* Name of the relevant locale category, or "" for the global locale. */ - const char *localename; -#endif - /* State of the catalog counter at the point the string was found. */ int counter; @@ -236,22 +226,23 @@ transcmp (p1, p2) { result = strcmp (s1->domainname, s2->domainname); if (result == 0) - { -#ifdef HAVE_PER_THREAD_LOCALE - result = strcmp (s1->localename, s2->localename); - if (result == 0) -#endif - /* We compare the category last (though this is the cheapest - operation) since it is hopefully always the same (namely - LC_MESSAGES). */ - result = s1->category - s2->category; - } + /* We compare the category last (though this is the cheapest + operation) since it is hopefully always the same (namely + LC_MESSAGES). */ + result = s1->category - s2->category; } return result; } #endif +#ifndef INTVARDEF +# define INTVARDEF +#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"; @@ -261,15 +252,8 @@ const char *_nl_current_default_domain attribute_hidden = _nl_default_default_domain; /* Contains the default location of the message catalogs. */ - -#ifdef _LIBC -extern const char _nl_default_dirname[]; -libc_hidden_proto (_nl_default_dirname) -#endif const char _nl_default_dirname[] = LOCALEDIR; -#ifdef _LIBC -libc_hidden_data_def (_nl_default_dirname) -#endif +INTVARDEF (_nl_default_dirname) /* List with bindings of specific domains created by bindtextdomain() calls. */ @@ -286,8 +270,7 @@ static const char *guess_category_value PARAMS ((int category, internal_function; #ifdef _LIBC # include "../locale/localeinfo.h" -# define category_to_name(category) \ - _nl_category_names.str + _nl_category_name_idxs[category] +# define category_to_name(category) _nl_category_names[category] #else static const char *category_to_name PARAMS ((int category)) internal_function; #endif @@ -343,10 +326,6 @@ static struct transmem_list *transmem_list; #else typedef unsigned char transmem_block_t; #endif -#if defined _LIBC || HAVE_ICONV -static const char *get_output_charset PARAMS ((struct binding *domainbinding)) - internal_function; -#endif /* Names for the libintl functions are a problem. They must not clash @@ -425,9 +404,6 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) struct known_translation_t *search; struct known_translation_t **foundp = NULL; size_t msgid_len; -# ifdef HAVE_PER_THREAD_LOCALE - const char *localename; -# endif #endif size_t domainname_len; @@ -460,14 +436,8 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) search = (struct known_translation_t *) alloca (offsetof (struct known_translation_t, msgid) + msgid_len); memcpy (search->msgid, msgid1, msgid_len); - search->domainname = domainname; + search->domainname = (char *) domainname; search->category = category; -# ifdef HAVE_PER_THREAD_LOCALE -# ifdef _LIBC - localename = __current_locale_name (category); -# endif - search->localename = localename; -# endif /* Since tfind/tsearch manage a balanced tree, concurrent tfind and tsearch calls can be fatal. */ @@ -515,7 +485,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) } if (binding == NULL) - dirname = (char *) _nl_default_dirname; + dirname = (char *) INTUSE(_nl_default_dirname); else if (binding->dirname[0] == '/') dirname = binding->dirname; else @@ -611,7 +581,6 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) if (strcmp (single_locale, "C") == 0 || strcmp (single_locale, "POSIX") == 0) { - no_translation: FREE_BLOCKS (block_list); __libc_rwlock_unlock (_nl_state_lock); __set_errno (saved_errno); @@ -628,7 +597,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) if (domain != NULL) { - retval = _nl_find_msg (domain, binding, msgid1, 1, &retlen); + retval = _nl_find_msg (domain, binding, msgid1, &retlen); if (retval == NULL) { @@ -637,7 +606,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) for (cnt = 0; domain->successor[cnt] != NULL; ++cnt) { retval = _nl_find_msg (domain->successor[cnt], binding, - msgid1, 1, &retlen); + msgid1, &retlen); if (retval != NULL) { @@ -647,12 +616,6 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) } } - /* Returning -1 means that some resource problem exists - (likely memory) and that the strings could not be - converted. Return the original strings. */ - if (__builtin_expect (retval == (char *) -1, 0)) - goto no_translation; - if (retval != NULL) { /* Found the translation of MSGID1 in domain DOMAIN: @@ -662,33 +625,17 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) if (foundp == NULL) { /* Create a new entry and add it to the search tree. */ - size_t size; struct known_translation_t *newp; - size = offsetof (struct known_translation_t, msgid) - + msgid_len + domainname_len + 1; -# ifdef HAVE_PER_THREAD_LOCALE - size += strlen (localename) + 1; -# endif - newp = (struct known_translation_t *) malloc (size); + newp = (struct known_translation_t *) + malloc (offsetof (struct known_translation_t, msgid) + + msgid_len + domainname_len + 1); if (newp != NULL) { - char *new_domainname; -# ifdef HAVE_PER_THREAD_LOCALE - char *new_localename; -# endif - - new_domainname = mempcpy (newp->msgid, msgid1, msgid_len); - memcpy (new_domainname, domainname, domainname_len + 1); -# ifdef HAVE_PER_THREAD_LOCALE - new_localename = new_domainname + domainname_len + 1; - strcpy (new_localename, localename); -# endif - newp->domainname = new_domainname; + newp->domainname = + mempcpy (newp->msgid, msgid1, msgid_len); + memcpy (newp->domainname, domainname, domainname_len + 1); newp->category = category; -# ifdef HAVE_PER_THREAD_LOCALE - newp->localename = new_localename; -# endif newp->counter = _nl_msg_cat_cntr; newp->domain = domain; newp->translation = retval; @@ -734,11 +681,10 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) char * internal_function -_nl_find_msg (domain_file, domainbinding, msgid, convert, lengthp) +_nl_find_msg (domain_file, domainbinding, msgid, lengthp) struct loaded_l10nfile *domain_file; struct binding *domainbinding; const char *msgid; - int convert; size_t *lengthp; { struct loaded_domain *domain; @@ -845,331 +791,195 @@ _nl_find_msg (domain_file, domainbinding, msgid, convert, lengthp) } #if defined _LIBC || HAVE_ICONV - if (convert) + if (domain->codeset_cntr + != (domainbinding != NULL ? domainbinding->codeset_cntr : 0)) { - /* We are supposed to do a conversion. */ - const char *encoding = get_output_charset (domainbinding); - - /* Search whether a table with converted translations for this - encoding has already been allocated. */ - size_t nconversions = domain->nconversions; - struct converted_domain *convd = NULL; - size_t i; - - for (i = nconversions; i > 0; ) - { - i--; - if (strcmp (domain->conversions[i].encoding, encoding) == 0) - { - convd = &domain->conversions[i]; - break; - } - } - - if (convd == NULL) - { - /* Allocate a table for the converted translations for this - encoding. */ - struct converted_domain *new_conversions = - (struct converted_domain *) - realloc (domain->conversions, - (nconversions + 1) * sizeof (struct converted_domain)); - - if (__builtin_expect (new_conversions == NULL, 0)) - /* Nothing we can do, no more memory. We cannot use the - translation because it might be encoded incorrectly. */ - return (char *) -1; - - domain->conversions = new_conversions; - - /* Copy the 'encoding' string to permanent storage. */ - encoding = strdup (encoding); - if (__builtin_expect (encoding == NULL, 0)) - /* Nothing we can do, no more memory. We cannot use the - translation because it might be encoded incorrectly. */ - return (char *) -1; - - convd = &new_conversions[nconversions]; - convd->encoding = encoding; - - /* Find out about the character set the file is encoded with. - This can be found (in textual form) in the entry "". If this - entry does not exist or if this does not contain the 'charset=' - information, we will assume the charset matches the one the - current locale and we don't have to perform any conversion. */ -# ifdef _LIBC - convd->conv = (__gconv_t) -1; -# else -# if HAVE_ICONV - convd->conv = (iconv_t) -1; -# endif -# endif - { - char *nullentry; - size_t nullentrylen; - - /* Get the header entry. This is a recursion, but it doesn't - reallocate domain->conversions because we pass convert = 0. */ - nullentry = - _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen); - - if (nullentry != NULL) - { - const char *charsetstr; - - charsetstr = strstr (nullentry, "charset="); - if (charsetstr != NULL) - { - size_t len; - char *charset; - const char *outcharset; - - charsetstr += strlen ("charset="); - len = strcspn (charsetstr, " \t\n"); - - charset = (char *) alloca (len + 1); -# if defined _LIBC || HAVE_MEMPCPY - *((char *) mempcpy (charset, charsetstr, len)) = '\0'; -# else - memcpy (charset, charsetstr, len); - charset[len] = '\0'; -# endif - - outcharset = encoding; - -# ifdef _LIBC - /* We always want to use transliteration. */ - outcharset = norm_add_slashes (outcharset, "TRANSLIT"); - charset = norm_add_slashes (charset, ""); - int r = __gconv_open (outcharset, charset, &convd->conv, - GCONV_AVOID_NOCONV); - if (__builtin_expect (r != __GCONV_OK, 0)) - { - /* If the output encoding is the same there is - nothing to do. Otherwise do not use the - translation at all. */ - if (__builtin_expect (r != __GCONV_NOCONV, 1)) - return NULL; - - convd->conv = (__gconv_t) -1; - } -# else -# if HAVE_ICONV - /* When using GNU libc >= 2.2 or GNU libiconv >= 1.5, - we want to use transliteration. */ -# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 \ - || _LIBICONV_VERSION >= 0x0105 - if (strchr (outcharset, '/') == NULL) - { - char *tmp; - - len = strlen (outcharset); - tmp = (char *) alloca (len + 10 + 1); - memcpy (tmp, outcharset, len); - memcpy (tmp + len, "//TRANSLIT", 10 + 1); - outcharset = tmp; - - convd->conv = iconv_open (outcharset, charset); - - freea (outcharset); - } - else -# endif - convd->conv = iconv_open (outcharset, charset); -# endif -# endif - - freea (charset); - } - } - } - convd->conv_tab = NULL; - /* Here domain->conversions is still == new_conversions. */ - domain->nconversions++; - } + /* The domain's codeset has changed through bind_textdomain_codeset() + since the message catalog was initialized or last accessed. We + have to reinitialize the converter. */ + _nl_free_domain_conv (domain); + _nl_init_domain_conv (domain_file, domain, domainbinding); + } - if ( + if ( # ifdef _LIBC - convd->conv != (__gconv_t) -1 + domain->conv != (__gconv_t) -1 # else # if HAVE_ICONV - convd->conv != (iconv_t) -1 + domain->conv != (iconv_t) -1 # endif # endif - ) + ) + { + /* We are supposed to do a conversion. First allocate an + appropriate table with the same structure as the table + of translations in the file, where we can put the pointers + to the converted strings in. + There is a slight complication with plural entries. They + are represented by consecutive NUL terminated strings. We + handle this case by converting RESULTLEN bytes, including + NULs. */ + + if (domain->conv_tab == NULL + && ((domain->conv_tab = + (char **) calloc (nstrings + domain->n_sysdep_strings, + sizeof (char *))) + == NULL)) + /* Mark that we didn't succeed allocating a table. */ + domain->conv_tab = (char **) -1; + + if (__builtin_expect (domain->conv_tab == (char **) -1, 0)) + /* Nothing we can do, no more memory. */ + goto converted; + + if (domain->conv_tab[act] == NULL) { - /* We are supposed to do a conversion. First allocate an - appropriate table with the same structure as the table - of translations in the file, where we can put the pointers - to the converted strings in. - There is a slight complication with plural entries. They - are represented by consecutive NUL terminated strings. We - handle this case by converting RESULTLEN bytes, including - NULs. */ - - if (convd->conv_tab == NULL - && ((convd->conv_tab = - (char **) calloc (nstrings + domain->n_sysdep_strings, - sizeof (char *))) - == NULL)) - /* Mark that we didn't succeed allocating a table. */ - convd->conv_tab = (char **) -1; - - if (__builtin_expect (convd->conv_tab == (char **) -1, 0)) - /* Nothing we can do, no more memory. We cannot use the - translation because it might be encoded incorrectly. */ - return (char *) -1; - - if (convd->conv_tab[act] == NULL) - { - /* We haven't used this string so far, so it is not - translated yet. Do this now. */ - /* We use a bit more efficient memory handling. - We allocate always larger blocks which get used over - time. This is faster than many small allocations. */ - __libc_lock_define_initialized (static, lock) + /* We haven't used this string so far, so it is not + translated yet. Do this now. */ + /* We use a bit more efficient memory handling. + We allocate always larger blocks which get used over + time. This is faster than many small allocations. */ + __libc_lock_define_initialized (static, lock) # define INITIAL_BLOCK_SIZE 4080 - static unsigned char *freemem; - static size_t freemem_size; + static unsigned char *freemem; + static size_t freemem_size; - const unsigned char *inbuf; - unsigned char *outbuf; - int malloc_count; + const unsigned char *inbuf; + unsigned char *outbuf; + int malloc_count; # ifndef _LIBC - transmem_block_t *transmem_list = NULL; + transmem_block_t *transmem_list = NULL; # endif - __libc_lock_lock (lock); + __libc_lock_lock (lock); - inbuf = (const unsigned char *) result; - outbuf = freemem + sizeof (size_t); + inbuf = (const unsigned char *) result; + outbuf = freemem + sizeof (size_t); - malloc_count = 0; - while (1) - { - transmem_block_t *newmem; + malloc_count = 0; + while (1) + { + transmem_block_t *newmem; # ifdef _LIBC - size_t non_reversible; - int res; + size_t non_reversible; + int res; - if (freemem_size < sizeof (size_t)) - goto resize_freemem; + if (freemem_size < sizeof (size_t)) + goto resize_freemem; - res = __gconv (convd->conv, - &inbuf, inbuf + resultlen, - &outbuf, - outbuf + freemem_size - sizeof (size_t), - &non_reversible); + res = __gconv (domain->conv, + &inbuf, inbuf + resultlen, + &outbuf, + outbuf + freemem_size - sizeof (size_t), + &non_reversible); - if (res == __GCONV_OK || res == __GCONV_EMPTY_INPUT) - break; + if (res == __GCONV_OK || res == __GCONV_EMPTY_INPUT) + break; - if (res != __GCONV_FULL_OUTPUT) - { - /* We should not use the translation at all, it - is incorrectly encoded. */ - __libc_lock_unlock (lock); - return NULL; - } + if (res != __GCONV_FULL_OUTPUT) + { + __libc_lock_unlock (lock); + goto converted; + } - inbuf = (const unsigned char *) result; + inbuf = result; # else # if HAVE_ICONV - const char *inptr = (const char *) inbuf; - size_t inleft = resultlen; - char *outptr = (char *) outbuf; - size_t outleft; - - if (freemem_size < sizeof (size_t)) - goto resize_freemem; - - outleft = freemem_size - sizeof (size_t); - if (iconv (convd->conv, - (ICONV_CONST char **) &inptr, &inleft, - &outptr, &outleft) - != (size_t) (-1)) - { - outbuf = (unsigned char *) outptr; - break; - } - if (errno != E2BIG) - { - __libc_lock_unlock (lock); - return NULL; - } + const char *inptr = (const char *) inbuf; + size_t inleft = resultlen; + char *outptr = (char *) outbuf; + size_t outleft; + + if (freemem_size < sizeof (size_t)) + goto resize_freemem; + + outleft = freemem_size - sizeof (size_t); + if (iconv (domain->conv, + (ICONV_CONST char **) &inptr, &inleft, + &outptr, &outleft) + != (size_t) (-1)) + { + outbuf = (unsigned char *) outptr; + break; + } + if (errno != E2BIG) + { + __libc_lock_unlock (lock); + goto converted; + } # endif # endif - resize_freemem: - /* We must allocate a new buffer or resize the old one. */ - if (malloc_count > 0) - { - ++malloc_count; - freemem_size = malloc_count * INITIAL_BLOCK_SIZE; - newmem = (transmem_block_t *) realloc (transmem_list, - freemem_size); + resize_freemem: + /* We must allocate a new buffer or resize the old one. */ + if (malloc_count > 0) + { + ++malloc_count; + freemem_size = malloc_count * INITIAL_BLOCK_SIZE; + newmem = (transmem_block_t *) realloc (transmem_list, + freemem_size); # ifdef _LIBC - if (newmem != NULL) - transmem_list = transmem_list->next; - else - { - struct transmem_list *old = transmem_list; - - transmem_list = transmem_list->next; - free (old); - } -# endif - } + if (newmem != NULL) + transmem_list = transmem_list->next; else { - malloc_count = 1; - freemem_size = INITIAL_BLOCK_SIZE; - newmem = (transmem_block_t *) malloc (freemem_size); - } - if (__builtin_expect (newmem == NULL, 0)) - { - freemem = NULL; - freemem_size = 0; - __libc_lock_unlock (lock); - return (char *) -1; + struct transmem_list *old = transmem_list; + + transmem_list = transmem_list->next; + free (old); } +# endif + } + else + { + malloc_count = 1; + freemem_size = INITIAL_BLOCK_SIZE; + newmem = (transmem_block_t *) malloc (freemem_size); + } + if (__builtin_expect (newmem == NULL, 0)) + { + freemem = NULL; + freemem_size = 0; + __libc_lock_unlock (lock); + goto converted; + } # ifdef _LIBC - /* Add the block to the list of blocks we have to free - at some point. */ - newmem->next = transmem_list; - transmem_list = newmem; + /* Add the block to the list of blocks we have to free + at some point. */ + newmem->next = transmem_list; + transmem_list = newmem; - freemem = (unsigned char *) newmem->data; - freemem_size -= offsetof (struct transmem_list, data); + freemem = newmem->data; + freemem_size -= offsetof (struct transmem_list, data); # else - transmem_list = newmem; - freemem = newmem; + transmem_list = newmem; + freemem = newmem; # endif - outbuf = freemem + sizeof (size_t); - } - - /* We have now in our buffer a converted string. Put this - into the table of conversions. */ - *(size_t *) freemem = outbuf - freemem - sizeof (size_t); - convd->conv_tab[act] = (char *) freemem; - /* Shrink freemem, but keep it aligned. */ - freemem_size -= outbuf - freemem; - freemem = outbuf; - freemem += freemem_size & (alignof (size_t) - 1); - freemem_size = freemem_size & ~ (alignof (size_t) - 1); - - __libc_lock_unlock (lock); + outbuf = freemem + sizeof (size_t); } - /* Now convd->conv_tab[act] contains the translation of all - the plural variants. */ - result = convd->conv_tab[act] + sizeof (size_t); - resultlen = *(size_t *) convd->conv_tab[act]; + /* We have now in our buffer a converted string. Put this + into the table of conversions. */ + *(size_t *) freemem = outbuf - freemem - sizeof (size_t); + domain->conv_tab[act] = (char *) freemem; + /* Shrink freemem, but keep it aligned. */ + freemem_size -= outbuf - freemem; + freemem = outbuf; + freemem += freemem_size & (alignof (size_t) - 1); + freemem_size = freemem_size & ~ (alignof (size_t) - 1); + + __libc_lock_unlock (lock); } + + /* Now domain->conv_tab[act] contains the translation of all + the plural variants. */ + result = domain->conv_tab[act] + sizeof (size_t); + resultlen = *(size_t *) domain->conv_tab[act]; } + converted: /* The result string is converted. */ #endif /* _LIBC || HAVE_ICONV */ @@ -1310,61 +1120,6 @@ guess_category_value (category, categoryname) return language != NULL && strcmp (retval, "C") != 0 ? language : retval; } -#if defined _LIBC || HAVE_ICONV -/* Returns the output charset. */ -static const char * -internal_function -get_output_charset (domainbinding) - struct binding *domainbinding; -{ - /* The output charset should normally be determined by the locale. But - sometimes the locale is not used or not correctly set up, so we provide - a possibility for the user to override this: the OUTPUT_CHARSET - environment variable. Moreover, the value specified through - bind_textdomain_codeset overrides both. */ - if (domainbinding != NULL && domainbinding->codeset != NULL) - return domainbinding->codeset; - else - { - /* For speed reasons, we look at the value of OUTPUT_CHARSET only - once. This is a user variable that is not supposed to change - during a program run. */ - static char *output_charset_cache; - static int output_charset_cached; - - if (!output_charset_cached) - { - const char *value = getenv ("OUTPUT_CHARSET"); - - if (value != NULL && value[0] != '\0') - { - size_t len = strlen (value) + 1; - char *value_copy = (char *) malloc (len); - - if (value_copy != NULL) - memcpy (value_copy, value, len); - output_charset_cache = value_copy; - } - output_charset_cached = 1; - } - - if (output_charset_cache != NULL) - return output_charset_cache; - else - { -# ifdef _LIBC - return _NL_CURRENT (LC_CTYPE, CODESET); -# else -# if HAVE_ICONV - extern const char *locale_charset PARAMS ((void); - return locale_charset (); -# endif -# endif - } - } -} -#endif - /* @@ begin of epilog @@ */ /* We don't want libintl.a to depend on any other library. So we @@ -1406,7 +1161,7 @@ libc_freeres_fn (free_mem) { 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); diff --git a/intl/explodename.c b/intl/explodename.c index 8e326ead53..f7bcfa5ff6 100644 --- a/intl/explodename.c +++ b/intl/explodename.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2002, 2003, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1995-2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1995. @@ -78,7 +78,7 @@ _nl_explode_name (name, language, modifier, territory, codeset, if (*language == cp) /* This does not make sense: language has to be specified. Use this entry as it is without exploding. Perhaps it is an alias. */ - cp = __rawmemchr (*language, '\0'); + cp = strchr (*language, '\0'); else if (cp[0] != '@') { if (cp[0] == '_') diff --git a/intl/finddomain.c b/intl/finddomain.c index 9806ba12cd..39e54755d2 100644 --- a/intl/finddomain.c +++ b/intl/finddomain.c @@ -1,5 +1,5 @@ /* Handle list of needed message catalogs - Copyright (C) 1995-1999, 2000, 2001, 2002, 2004, 2006 + Copyright (C) 1995-1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper , 1995. @@ -110,7 +110,7 @@ _nl_find_domain (dirname, locale, domainname, domainbinding) break; } - return retval; + return cnt >= 0 ? retval : NULL; /* NOTREACHED */ } @@ -119,7 +119,20 @@ _nl_find_domain (dirname, locale, domainname, domainbinding) done. */ alias_value = _nl_expand_alias (locale); if (alias_value != NULL) - locale = strdupa (alias_value); + { +#if defined _LIBC || defined HAVE_STRDUP + locale = strdup (alias_value); + if (locale == NULL) + return NULL; +#else + size_t len = strlen (alias_value) + 1; + locale = (char *) malloc (len); + if (locale == NULL) + return NULL; + + memcpy (locale, alias_value, len); +#endif + } /* Now we determine the single parts of the locale name. First look for the language. Termination symbols are `_' and `@' if @@ -156,6 +169,10 @@ _nl_find_domain (dirname, locale, domainname, domainbinding) } } + /* The room for an alias was dynamically allocated. Free it now. */ + if (alias_value != NULL) + free (locale); + /* The space for normalized_codeset is dynamically allocated. Free it. */ if (mask & XPG_NORM_CODESET) free ((void *) normalized_codeset); diff --git a/intl/gettextP.h b/intl/gettextP.h index f18535a5b3..46b51e1008 100644 --- a/intl/gettextP.h +++ b/intl/gettextP.h @@ -1,5 +1,5 @@ /* Header describing internals of libintl library. - Copyright (C) 1995-1999, 2000, 2001, 2004-2005 Free Software Foundation, Inc. + Copyright (C) 1995-1999, 2000, 2001, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper , 1995. @@ -88,26 +88,6 @@ struct sysdep_string_desc const char *pointer; }; -/* Cache of translated strings after charset conversion. - Note: The strings are converted to the target encoding only on an as-needed - basis. */ -struct converted_domain -{ - /* The target encoding name. */ - const char *encoding; - /* The descriptor for conversion from the message catalog's encoding to - this target encoding. */ -#ifdef _LIBC - __gconv_t conv; -#else -# if HAVE_ICONV - iconv_t conv; -# endif -#endif - /* The table of translated strings after charset conversion. */ - char **conv_tab; -}; - /* The representation of an opened message catalog. */ struct loaded_domain { @@ -143,9 +123,15 @@ struct loaded_domain /* 1 if the hash table uses a different endianness than this machine. */ int must_swap_hash_tab; - /* Cache of charset conversions of the translated strings. */ - struct converted_domain *conversions; - size_t nconversions; + int codeset_cntr; +#ifdef _LIBC + __gconv_t conv; +#else +# if HAVE_ICONV + iconv_t conv; +# endif +#endif + char **conv_tab; struct expression *plural; unsigned long int nplurals; @@ -165,6 +151,7 @@ struct binding { struct binding *next; char *dirname; + int codeset_cntr; /* Incremented each time codeset changes. */ char *codeset; char domainname[ZERO]; }; @@ -186,10 +173,16 @@ struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname, void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain, struct binding *__domainbinding)) internal_function; +const char *_nl_init_domain_conv PARAMS ((struct loaded_l10nfile *__domain_file, + struct loaded_domain *__domain, + struct binding *__domainbinding)) + internal_function; +void _nl_free_domain_conv PARAMS ((struct loaded_domain *__domain)) + internal_function; char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file, - struct binding *domainbinding, const char *msgid, - int convert, size_t *lengthp)) + struct binding *domainbinding, + const char *msgid, size_t *lengthp)) internal_function; #ifdef _LIBC diff --git a/intl/l10nflist.c b/intl/l10nflist.c index 2c06a91113..7ffb4ab590 100644 --- a/intl/l10nflist.c +++ b/intl/l10nflist.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2002, 2004, 2005 Free Software Foundation, Inc. +/* Copyright (C) 1995-2002, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1995. @@ -270,10 +270,7 @@ _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language, * (1 << pop (mask)) * sizeof (struct loaded_l10nfile *))); if (retval == NULL) - { - free (abs_filename); - return NULL; - } + return NULL; retval->filename = abs_filename; /* If more than one directory is in the list this is a pseudo-entry diff --git a/intl/libintl.h b/intl/libintl.h index 544dec3533..6561c78370 100644 --- a/intl/libintl.h +++ b/intl/libintl.h @@ -1,5 +1,5 @@ /* Message catalogs for internationalization. - Copyright (C) 1995-2002, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1995-1999, 2000-2002, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. This file is derived from the file libgettext.h in the GNU gettext package. @@ -37,21 +37,19 @@ __BEGIN_DECLS /* Look up MSGID in the current default message catalog for the current LC_MESSAGES locale. If not found, returns MSGID itself (the default text). */ -extern char *gettext (__const char *__msgid) - __THROW __attribute_format_arg__ (1); +extern char *gettext (__const char *__msgid) __THROW; /* Look up MSGID in the DOMAINNAME message catalog for the current LC_MESSAGES locale. */ extern char *dgettext (__const char *__domainname, __const char *__msgid) - __THROW __attribute_format_arg__ (2); + __THROW; extern char *__dgettext (__const char *__domainname, __const char *__msgid) __THROW __attribute_format_arg__ (2); /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY locale. */ extern char *dcgettext (__const char *__domainname, - __const char *__msgid, int __category) - __THROW __attribute_format_arg__ (2); + __const char *__msgid, int __category) __THROW; extern char *__dcgettext (__const char *__domainname, __const char *__msgid, int __category) __THROW __attribute_format_arg__ (2); diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c index 1f55531097..efefc69a43 100644 --- a/intl/loadmsgcat.c +++ b/intl/loadmsgcat.c @@ -1,5 +1,5 @@ /* Load needed message catalogs. - Copyright (C) 1995-2005 Free Software Foundation, Inc. + Copyright (C) 1995-2004 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -752,6 +752,146 @@ get_sysdep_segment_value (name) return NULL; } +/* Initialize the codeset dependent parts of an opened message catalog. + Return the header entry. */ +const char * +internal_function +_nl_init_domain_conv (domain_file, domain, domainbinding) + struct loaded_l10nfile *domain_file; + struct loaded_domain *domain; + struct binding *domainbinding; +{ + /* Find out about the character set the file is encoded with. + This can be found (in textual form) in the entry "". If this + entry does not exist or if this does not contain the `charset=' + information, we will assume the charset matches the one the + current locale and we don't have to perform any conversion. */ + char *nullentry; + size_t nullentrylen; + + /* Preinitialize fields, to avoid recursion during _nl_find_msg. */ + domain->codeset_cntr = + (domainbinding != NULL ? domainbinding->codeset_cntr : 0); +#ifdef _LIBC + domain->conv = (__gconv_t) -1; +#else +# if HAVE_ICONV + domain->conv = (iconv_t) -1; +# endif +#endif + domain->conv_tab = NULL; + + /* Get the header entry. */ + nullentry = _nl_find_msg (domain_file, domainbinding, "", &nullentrylen); + + if (nullentry != NULL) + { +#if defined _LIBC || HAVE_ICONV + const char *charsetstr; + + charsetstr = strstr (nullentry, "charset="); + if (charsetstr != NULL) + { + size_t len; + char *charset; + const char *outcharset; + + charsetstr += strlen ("charset="); + len = strcspn (charsetstr, " \t\n"); + + charset = (char *) alloca (len + 1); +# if defined _LIBC || HAVE_MEMPCPY + *((char *) mempcpy (charset, charsetstr, len)) = '\0'; +# else + memcpy (charset, charsetstr, len); + charset[len] = '\0'; +# endif + + /* The output charset should normally be determined by the + locale. But sometimes the locale is not used or not correctly + set up, so we provide a possibility for the user to override + this. Moreover, the value specified through + bind_textdomain_codeset overrides both. */ + if (domainbinding != NULL && domainbinding->codeset != NULL) + outcharset = domainbinding->codeset; + else + { + outcharset = getenv ("OUTPUT_CHARSET"); + if (outcharset == NULL || outcharset[0] == '\0') + { +# ifdef _LIBC + outcharset = _NL_CURRENT (LC_CTYPE, CODESET); +# else +# if HAVE_ICONV + extern const char *locale_charset PARAMS ((void)); + outcharset = locale_charset (); +# endif +# endif + } + } + +# ifdef _LIBC + /* We always want to use transliteration. */ + outcharset = norm_add_slashes (outcharset, "TRANSLIT"); + charset = norm_add_slashes (charset, ""); + if (__gconv_open (outcharset, charset, &domain->conv, + GCONV_AVOID_NOCONV) + != __GCONV_OK) + domain->conv = (__gconv_t) -1; +# else +# if HAVE_ICONV + /* When using GNU libc >= 2.2 or GNU libiconv >= 1.5, + we want to use transliteration. */ +# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 \ + || _LIBICONV_VERSION >= 0x0105 + if (strchr (outcharset, '/') == NULL) + { + char *tmp; + + len = strlen (outcharset); + tmp = (char *) alloca (len + 10 + 1); + memcpy (tmp, outcharset, len); + memcpy (tmp + len, "//TRANSLIT", 10 + 1); + outcharset = tmp; + + domain->conv = iconv_open (outcharset, charset); + + freea (outcharset); + } + else +# endif + domain->conv = iconv_open (outcharset, charset); +# endif +# endif + + freea (charset); + } +#endif /* _LIBC || HAVE_ICONV */ + } + + return nullentry; +} + +/* Frees the codeset dependent parts of an opened message catalog. */ +void +internal_function +_nl_free_domain_conv (domain) + struct loaded_domain *domain; +{ + if (domain->conv_tab != NULL && domain->conv_tab != (char **) -1) + free (domain->conv_tab); + +#ifdef _LIBC + if (domain->conv != (__gconv_t) -1) + __gconv_close (domain->conv); +#else +# if HAVE_ICONV + if (domain->conv != (iconv_t) -1) + iconv_close (domain->conv); +# endif +#endif +} + /* Load the message catalogs specified by FILENAME. If it is no valid message catalog do nothing. */ void @@ -773,7 +913,6 @@ _nl_load_domain (domain_file, domainbinding) struct loaded_domain *domain; int revision; const char *nullentry; - size_t nullentrylen; __libc_lock_lock_recursive (lock); if (domain_file->decided != 0) @@ -781,8 +920,8 @@ _nl_load_domain (domain_file, domainbinding) /* There are two possibilities: + is is the same thread calling again during this - initialization via _nl_find_msg. We have initialized - everything this call needs. + initialization via _nl_init_domain_conv and _nl_find_msg. We + have initialized everything this call needs. + this is another thread which tried to initialize this object. Not necessary anymore since if the lock is available this @@ -1249,12 +1388,12 @@ _nl_load_domain (domain_file, domainbinding) goto out; } - /* No caches of converted translations so far. */ - domain->conversions = NULL; - domain->nconversions = 0; + /* Now initialize the character set converter from the character set + the file is encoded with (found in the header entry) to the domain's + specified character set or the locale's character set. */ + nullentry = _nl_init_domain_conv (domain_file, domain, domainbinding); - /* Get the header entry and look for a plural specification. */ - nullentry = _nl_find_msg (domain_file, domainbinding, "", 0, &nullentrylen); + /* Also look for a plural specification. */ EXTRACT_PLURAL_EXPRESSION (nullentry, &domain->plural, &domain->nplurals); out: @@ -1273,23 +1412,10 @@ internal_function __libc_freeres_fn_section _nl_unload_domain (domain) struct loaded_domain *domain; { - size_t i; - if (domain->plural != &__gettext_germanic_plural) __gettext_free_exp (domain->plural); - for (i = 0; i < domain->nconversions; i++) - { - struct converted_domain *convd = &domain->conversions[i]; - - free ((char *) convd->encoding); - if (convd->conv_tab != NULL && convd->conv_tab != (char **) -1) - free (convd->conv_tab); - if (convd->conv != (__gconv_t) -1) - __gconv_close (convd->conv); - } - if (domain->conversions != NULL) - free (domain->conversions); + _nl_free_domain_conv (domain); if (domain->malloced) free (domain->malloced); diff --git a/intl/locale.alias b/intl/locale.alias index b43e79bbe5..1a24c9e614 100644 --- a/intl/locale.alias +++ b/intl/locale.alias @@ -58,6 +58,8 @@ korean ko_KR.eucKR korean.euc ko_KR.eucKR ko_KR ko_KR.eucKR lithuanian lt_LT.ISO-8859-13 +no_NO nb_NO.ISO-8859-1 +no_NO.ISO-8859-1 nb_NO.ISO-8859-1 norwegian nb_NO.ISO-8859-1 nynorsk nn_NO.ISO-8859-1 polish pl_PL.ISO-8859-2 diff --git a/intl/localealias.c b/intl/localealias.c index 735107abd3..32d05ff347 100644 --- a/intl/localealias.c +++ b/intl/localealias.c @@ -1,5 +1,5 @@ /* Handle aliases for locale names. - Copyright (C) 1995-2002, 2003, 2005 Free Software Foundation, Inc. + Copyright (C) 1995-2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -295,7 +295,7 @@ read_alias_file (fname, fname_len) if (nmap >= maxmap) if (__builtin_expect (extend_alias_table (), 0)) - goto out; + return added; alias_len = strlen (alias) + 1; value_len = strlen (value) + 1; @@ -308,7 +308,7 @@ read_alias_file (fname, fname_len) ? alias_len + value_len : 1024)); char *new_pool = (char *) realloc (string_space, new_size); if (new_pool == NULL) - goto out; + return added; if (__builtin_expect (string_space != new_pool, 0)) { @@ -349,7 +349,6 @@ read_alias_file (fname, fname_len) while (strchr (buf, '\n') == NULL); } -out: /* Should we test for ferror()? I think we have to silently ignore errors. --drepper */ fclose (fp); diff --git a/intl/plural-exp.c b/intl/plural-exp.c index 9cb7a4540a..ba5d455cd5 100644 --- a/intl/plural-exp.c +++ b/intl/plural-exp.c @@ -1,5 +1,5 @@ /* Expression parsing for plural form selection. - Copyright (C) 2000, 2001, 2005 Free Software Foundation, Inc. + Copyright (C) 2000, 2001 Free Software Foundation, Inc. Written by Ulrich Drepper , 2000. This file is part of the GNU C Library. @@ -47,7 +47,7 @@ static const struct expression plone = .num = 1 } }; -const struct expression GERMANIC_PLURAL = +struct expression GERMANIC_PLURAL = { .nargs = 2, .operation = not_equal, diff --git a/intl/plural-exp.h b/intl/plural-exp.h index f8a5c87ff0..75c702f79c 100644 --- a/intl/plural-exp.h +++ b/intl/plural-exp.h @@ -1,5 +1,5 @@ /* Expression parsing and evaluation for plural form selection. - Copyright (C) 2000, 2001, 2002, 2005 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. Written by Ulrich Drepper , 2000. This file is part of the GNU C Library. @@ -113,7 +113,7 @@ struct parse_args extern void FREE_EXPRESSION PARAMS ((struct expression *exp)) internal_function; extern int PLURAL_PARSE PARAMS ((void *arg)); -extern const struct expression GERMANIC_PLURAL attribute_hidden; +extern struct expression GERMANIC_PLURAL attribute_hidden; extern void EXTRACT_PLURAL_EXPRESSION PARAMS ((const char *nullentry, struct expression **pluralp, unsigned long int *npluralsp)) diff --git a/intl/tst-codeset.sh b/intl/tst-codeset.sh index 8b052168b2..3d9b9559b7 100644 --- a/intl/tst-codeset.sh +++ b/intl/tst-codeset.sh @@ -1,6 +1,6 @@ #! /bin/sh # Test of bind_textdomain_codeset. -# Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002 Free Software Foundation, Inc. # This file is part of the GNU C Library. # @@ -26,11 +26,12 @@ LC_ALL=C export LC_ALL # Generate the test data. -msgfmt -o ${objpfx}codeset.mo.$$ tstcodeset.po || exit +test -d ${objpfx}domaindir || mkdir ${objpfx}domaindir # Create the domain directories. -mkdir -p ${objpfx}domaindir/de_DE/LC_MESSAGES +test -d ${objpfx}domaindir/de_DE || mkdir ${objpfx}domaindir/de_DE +test -d ${objpfx}domaindir/de_DE/LC_MESSAGES || mkdir ${objpfx}domaindir/de_DE/LC_MESSAGES # Populate them. -mv -f ${objpfx}codeset.mo.$$ ${objpfx}domaindir/de_DE/LC_MESSAGES/codeset.mo +msgfmt -o ${objpfx}domaindir/de_DE/LC_MESSAGES/codeset.mo tstcodeset.po GCONV_PATH=${common_objpfx}iconvdata export GCONV_PATH diff --git a/intl/tst-gettext2.sh b/intl/tst-gettext2.sh index 68157f8a68..53f081a798 100644 --- a/intl/tst-gettext2.sh +++ b/intl/tst-gettext2.sh @@ -1,6 +1,6 @@ #! /bin/sh # Test of gettext functions. -# Copyright (C) 2000, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2000, 2003 Free Software Foundation, Inc. # This file is part of the GNU C Library. # @@ -26,7 +26,7 @@ LC_ALL=C export LC_ALL # Generate the test data. -mkdir -p ${objpfx}domaindir +test -d ${objpfx}domaindir || mkdir ${objpfx}domaindir # Create the locale directories. test -d ${objpfx}domaindir/lang1 || { mkdir ${objpfx}domaindir/lang1 diff --git a/intl/tst-gettext3.c b/intl/tst-gettext3.c deleted file mode 100644 index 917967b383..0000000000 --- a/intl/tst-gettext3.c +++ /dev/null @@ -1,60 +0,0 @@ -/* Test that the gettext() results come out in the correct encoding for - locales that differ only in their encoding. - Copyright (C) 2001, 2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Bruno Haible , 2001, 2005. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include -#include -#include -#include - -int -main (void) -{ - char *s; - int result = 0; - - unsetenv ("LANGUAGE"); - unsetenv ("OUTPUT_CHARSET"); - textdomain ("codeset"); - bindtextdomain ("codeset", OBJPFX "domaindir"); - - setlocale (LC_ALL, "de_DE.ISO-8859-1"); - - /* Here we expect output in ISO-8859-1. */ - s = gettext ("cheese"); - if (strcmp (s, "K\344se")) - { - printf ("call 1 returned: %s\n", s); - result = 1; - } - - setlocale (LC_ALL, "de_DE.UTF-8"); - - /* Here we expect output in UTF-8. */ - s = gettext ("cheese"); - if (strcmp (s, "K\303\244se")) - { - printf ("call 2 returned: %s\n", s); - result = 1; - } - - return result; -} diff --git a/intl/tst-gettext3.sh b/intl/tst-gettext3.sh deleted file mode 100644 index 185576886e..0000000000 --- a/intl/tst-gettext3.sh +++ /dev/null @@ -1,44 +0,0 @@ -#! /bin/sh -# Test that the gettext() results come out in the correct encoding for -# locales that differ only in their encoding. -# Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc. -# This file is part of the GNU C Library. -# - -# The GNU C Library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. - -# The GNU C Library 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 -# Lesser General Public License for more details. - -# You should have received a copy of the GNU Lesser General Public -# License along with the GNU C Library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -# 02111-1307 USA. - -common_objpfx=$1 -objpfx=$2 - -LC_ALL=C -export LC_ALL - -# Generate the test data. -msgfmt -o ${objpfx}codeset.mo.$$ tstcodeset.po || exit -# Create the domain directories. -mkdir -p ${objpfx}domaindir/de_DE/LC_MESSAGES -# Populate them. -mv -f ${objpfx}codeset.mo.$$ ${objpfx}domaindir/de_DE/LC_MESSAGES/codeset.mo - -GCONV_PATH=${common_objpfx}iconvdata -export GCONV_PATH -LOCPATH=${common_objpfx}localedata -export LOCPATH - -${common_objpfx}elf/ld.so --library-path $common_objpfx \ -${objpfx}tst-gettext3 > ${objpfx}tst-gettext3.out - -exit $? diff --git a/intl/tst-gettext4-de.po b/intl/tst-gettext4-de.po deleted file mode 100644 index 0a8d099398..0000000000 --- a/intl/tst-gettext4-de.po +++ /dev/null @@ -1,8 +0,0 @@ -msgid "" -msgstr "" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=ISO-8859-1\n" -"Content-Transfer-Encoding: 8-bit\n" - -msgid "beauty" -msgstr "Schönheit" diff --git a/intl/tst-gettext4-fr.po b/intl/tst-gettext4-fr.po deleted file mode 100644 index 8332c2d9f8..0000000000 --- a/intl/tst-gettext4-fr.po +++ /dev/null @@ -1,8 +0,0 @@ -msgid "" -msgstr "" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=ISO-8859-1\n" -"Content-Transfer-Encoding: 8-bit\n" - -msgid "beauty" -msgstr "beauté" diff --git a/intl/tst-gettext4.c b/intl/tst-gettext4.c deleted file mode 100644 index a82446d14c..0000000000 --- a/intl/tst-gettext4.c +++ /dev/null @@ -1,151 +0,0 @@ -/* Test that gettext() in multithreaded applications works correctly if - different threads operate in different locales with the same encoding. - Copyright (C) 2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Bruno Haible , 2005. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include -#include -#include -#include -#include - -/* Set to 1 if the program is not behaving correctly. */ -int result; - -/* Denotes which thread should run next. */ -int flipflop; -/* Lock and wait queue used to switch between the threads. */ -pthread_mutex_t lock; -pthread_cond_t waitqueue; - -/* Waits until the flipflop has a given value. - Before the call, the lock is unlocked. After the call, it is locked. */ -static void -waitfor (int value) -{ - if (pthread_mutex_lock (&lock)) - exit (10); - while (flipflop != value) - if (pthread_cond_wait (&waitqueue, &lock)) - exit (11); -} - -/* Sets the flipflop to a given value. - Before the call, the lock is locked. After the call, it is unlocked. */ -static void -setto (int value) -{ - flipflop = value; - if (pthread_cond_signal (&waitqueue)) - exit (20); - if (pthread_mutex_unlock (&lock)) - exit (21); -} - -void * -thread1_execution (void *arg) -{ - char *s; - - waitfor (1); - uselocale (newlocale (LC_ALL_MASK, "de_DE.ISO-8859-1", NULL)); - setto (2); - - waitfor (1); - s = gettext ("beauty"); - puts (s); - if (strcmp (s, "Sch\366nheit")) - { - fprintf (stderr, "thread 1 call 1 returned: %s\n", s); - result = 1; - } - setto (2); - - waitfor (1); - s = gettext ("beauty"); - puts (s); - if (strcmp (s, "Sch\366nheit")) - { - fprintf (stderr, "thread 1 call 2 returned: %s\n", s); - result = 1; - } - setto (2); - - return NULL; -} - -void * -thread2_execution (void *arg) -{ - char *s; - - waitfor (2); - uselocale (newlocale (LC_ALL_MASK, "fr_FR.ISO-8859-1", NULL)); - setto (1); - - waitfor (2); - s = gettext ("beauty"); - puts (s); - if (strcmp (s, "beaut\351")) - { - fprintf (stderr, "thread 2 call 1 returned: %s\n", s); - result = 1; - } - setto (1); - - waitfor (2); - s = gettext ("beauty"); - puts (s); - if (strcmp (s, "beaut\351")) - { - fprintf (stderr, "thread 2 call 2 returned: %s\n", s); - result = 1; - } - setto (1); - - return NULL; -} - -int -main (void) -{ - pthread_t thread1; - pthread_t thread2; - - unsetenv ("LANGUAGE"); - unsetenv ("OUTPUT_CHARSET"); - textdomain ("multithread"); - bindtextdomain ("multithread", OBJPFX "domaindir"); - result = 0; - - flipflop = 1; - if (pthread_mutex_init (&lock, NULL)) - exit (2); - if (pthread_cond_init (&waitqueue, NULL)) - exit (2); - if (pthread_create (&thread1, NULL, &thread1_execution, NULL)) - exit (2); - if (pthread_create (&thread2, NULL, &thread2_execution, NULL)) - exit (2); - if (pthread_join (thread2, NULL)) - exit (3); - - return result; -} diff --git a/intl/tst-gettext4.sh b/intl/tst-gettext4.sh deleted file mode 100755 index 68779be04d..0000000000 --- a/intl/tst-gettext4.sh +++ /dev/null @@ -1,44 +0,0 @@ -#! /bin/sh -# Test that gettext() in multithreaded applications works correctly if -# different threads operate in different locales with the same encoding. -# Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc. -# This file is part of the GNU C Library. -# - -# The GNU C Library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. - -# The GNU C Library 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 -# Lesser General Public License for more details. - -# You should have received a copy of the GNU Lesser General Public -# License along with the GNU C Library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -# 02111-1307 USA. - -common_objpfx=$1 -run_program_prefix=$2 -objpfx=$3 - -LC_ALL=C -export LC_ALL - -# Create the domain directories. -mkdir -p ${objpfx}domaindir/de_DE/LC_MESSAGES -mkdir -p ${objpfx}domaindir/fr_FR/LC_MESSAGES -# Populate them. -msgfmt -o ${objpfx}domaindir/de_DE/LC_MESSAGES/multithread.mo tst-gettext4-de.po -msgfmt -o ${objpfx}domaindir/fr_FR/LC_MESSAGES/multithread.mo tst-gettext4-fr.po - -GCONV_PATH=${common_objpfx}iconvdata -export GCONV_PATH -LOCPATH=${common_objpfx}localedata -export LOCPATH - -${run_program_prefix} ${objpfx}tst-gettext4 > ${objpfx}tst-gettext4.out - -exit $? diff --git a/intl/tst-gettext5.c b/intl/tst-gettext5.c deleted file mode 100644 index 498ecab790..0000000000 --- a/intl/tst-gettext5.c +++ /dev/null @@ -1,156 +0,0 @@ -/* Test that gettext() in multithreaded applications works correctly if - different threads operate in different locales referring to the same - catalog file but with different encodings. - Copyright (C) 2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Bruno Haible , 2005. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include -#include -#include -#include -#include - -/* Set to 1 if the program is not behaving correctly. */ -int result; - -/* Denotes which thread should run next. */ -int flipflop; -/* Lock and wait queue used to switch between the threads. */ -pthread_mutex_t lock; -pthread_cond_t waitqueue; - -/* Waits until the flipflop has a given value. - Before the call, the lock is unlocked. After the call, it is locked. */ -static void -waitfor (int value) -{ - if (pthread_mutex_lock (&lock)) - exit (10); - while (flipflop != value) - if (pthread_cond_wait (&waitqueue, &lock)) - exit (11); -} - -/* Sets the flipflop to a given value. - Before the call, the lock is locked. After the call, it is unlocked. */ -static void -setto (int value) -{ - flipflop = value; - if (pthread_cond_signal (&waitqueue)) - exit (20); - if (pthread_mutex_unlock (&lock)) - exit (21); -} - -void * -thread1_execution (void *arg) -{ - char *s; - - waitfor (1); - uselocale (newlocale (LC_ALL_MASK, "de_DE.ISO-8859-1", NULL)); - setto (2); - - /* Here we expect output in ISO-8859-1. */ - - waitfor (1); - s = gettext ("cheese"); - puts (s); - if (strcmp (s, "K\344se")) - { - fprintf (stderr, "thread 1 call 1 returned: %s\n", s); - result = 1; - } - setto (2); - - waitfor (1); - s = gettext ("cheese"); - puts (s); - if (strcmp (s, "K\344se")) - { - fprintf (stderr, "thread 1 call 2 returned: %s\n", s); - result = 1; - } - setto (2); - - return NULL; -} - -void * -thread2_execution (void *arg) -{ - char *s; - - waitfor (2); - uselocale (newlocale (LC_ALL_MASK, "de_DE.UTF-8", NULL)); - setto (1); - - /* Here we expect output in UTF-8. */ - - waitfor (2); - s = gettext ("cheese"); - puts (s); - if (strcmp (s, "K\303\244se")) - { - fprintf (stderr, "thread 2 call 1 returned: %s\n", s); - result = 1; - } - setto (1); - - waitfor (2); - s = gettext ("cheese"); - puts (s); - if (strcmp (s, "K\303\244se")) - { - fprintf (stderr, "thread 2 call 2 returned: %s\n", s); - result = 1; - } - setto (1); - - return NULL; -} - -int -main (void) -{ - pthread_t thread1; - pthread_t thread2; - - unsetenv ("LANGUAGE"); - unsetenv ("OUTPUT_CHARSET"); - textdomain ("codeset"); - bindtextdomain ("codeset", OBJPFX "domaindir"); - result = 0; - - flipflop = 1; - if (pthread_mutex_init (&lock, NULL)) - exit (2); - if (pthread_cond_init (&waitqueue, NULL)) - exit (2); - if (pthread_create (&thread1, NULL, &thread1_execution, NULL)) - exit (2); - if (pthread_create (&thread2, NULL, &thread2_execution, NULL)) - exit (2); - if (pthread_join (thread2, NULL)) - exit (3); - - return result; -} diff --git a/intl/tst-gettext5.sh b/intl/tst-gettext5.sh deleted file mode 100755 index 8c8d2170e4..0000000000 --- a/intl/tst-gettext5.sh +++ /dev/null @@ -1,43 +0,0 @@ -#! /bin/sh -# Test that gettext() in multithreaded applications works correctly if -# different threads operate in different locales referring to the same -# catalog file but with different encodings. -# Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc. -# This file is part of the GNU C Library. -# - -# The GNU C Library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. - -# The GNU C Library 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 -# Lesser General Public License for more details. - -# You should have received a copy of the GNU Lesser General Public -# License along with the GNU C Library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -# 02111-1307 USA. - -common_objpfx=$1 -run_program_prefix=$2 -objpfx=$3 - -LC_ALL=C -export LC_ALL - -# Create the domain directories. -mkdir -p ${objpfx}domaindir/de_DE/LC_MESSAGES -# Populate them. -msgfmt -o ${objpfx}domaindir/de_DE/LC_MESSAGES/codeset.mo tstcodeset.po - -GCONV_PATH=${common_objpfx}iconvdata -export GCONV_PATH -LOCPATH=${common_objpfx}localedata -export LOCPATH - -${run_program_prefix} ${objpfx}tst-gettext5 > ${objpfx}tst-gettext5.out - -exit $? diff --git a/intl/tst-translit.sh b/intl/tst-translit.sh index 22826e996c..e2508df4df 100755 --- a/intl/tst-translit.sh +++ b/intl/tst-translit.sh @@ -1,6 +1,6 @@ #! /bin/sh # Test of transliteration in gettext functions. -# Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc. +# Copyright (C) 2000, 2002 Free Software Foundation, Inc. # This file is part of the GNU C Library. # @@ -25,9 +25,6 @@ objpfx=$2 LC_ALL=C export LC_ALL -# Create the locale directories. -mkdir -p ${objpfx}localedir/existing-locale/LC_MESSAGES - msgfmt -o ${objpfx}domaindir/existing-locale/LC_MESSAGES/translit.mo \ translit.po -- cgit 1.4.1