diff options
| author | Ulrich Drepper <drepper@redhat.com> | 2004-12-22 20:10:10 +0000 |
|---|---|---|
| committer | Ulrich Drepper <drepper@redhat.com> | 2004-12-22 20:10:10 +0000 |
| commit | a334319f6530564d22e775935d9c91663623a1b4 (patch) | |
| tree | b5877475619e4c938e98757d518bb1e9cbead751 /intl | |
| parent | 0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (diff) | |
| download | glibc-a334319f6530564d22e775935d9c91663623a1b4.tar.xz glibc-a334319f6530564d22e775935d9c91663623a1b4.zip | |
(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
Diffstat (limited to 'intl')
| -rw-r--r-- | intl/Makefile | 53 | ||||
| -rw-r--r-- | intl/bindtextdom.c | 28 | ||||
| -rw-r--r-- | intl/dcgettext.c | 3 | ||||
| -rw-r--r-- | intl/dcigettext.c | 595 | ||||
| -rw-r--r-- | intl/explodename.c | 4 | ||||
| -rw-r--r-- | intl/finddomain.c | 23 | ||||
| -rw-r--r-- | intl/gettextP.h | 45 | ||||
| -rw-r--r-- | intl/l10nflist.c | 7 | ||||
| -rw-r--r-- | intl/libintl.h | 10 | ||||
| -rw-r--r-- | intl/loadmsgcat.c | 172 | ||||
| -rw-r--r-- | intl/locale.alias | 2 | ||||
| -rw-r--r-- | intl/localealias.c | 7 | ||||
| -rw-r--r-- | intl/plural-exp.c | 4 | ||||
| -rw-r--r-- | intl/plural-exp.h | 4 | ||||
| -rw-r--r-- | intl/tst-codeset.sh | 9 | ||||
| -rw-r--r-- | intl/tst-gettext2.sh | 4 | ||||
| -rw-r--r-- | intl/tst-gettext3.c | 60 | ||||
| -rw-r--r-- | intl/tst-gettext3.sh | 44 | ||||
| -rw-r--r-- | intl/tst-gettext4-de.po | 8 | ||||
| -rw-r--r-- | intl/tst-gettext4-fr.po | 8 | ||||
| -rw-r--r-- | intl/tst-gettext4.c | 151 | ||||
| -rwxr-xr-x | intl/tst-gettext4.sh | 44 | ||||
| -rw-r--r-- | intl/tst-gettext5.c | 156 | ||||
| -rwxr-xr-x | intl/tst-gettext5.sh | 43 | ||||
| -rwxr-xr-x | intl/tst-translit.sh | 5 |
25 files changed, 415 insertions, 1074 deletions
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) - { - |
