diff options
34 files changed, 329 insertions, 53 deletions
@@ -1,3 +1,49 @@ +2001-04-06 Ulrich Drepper <drepper@redhat.com> + + * iconv/iconv_open.c: Move strip and upstr definitions... + * iconv/gconv_charset.h: ...here. New file. + * iconv/gconv_db.c (once): Move to file level. + (do_lookup_alias): Split out from __gconv_find_transform. + (__gconv_find_transform): Call do_lookup_alias. + (__gconv_loopup_alias): New function. + * locale/langinfo.h: Define _NL_*_CODESET values for all categories + but LC_CTYPE. + * locale/categories.def: Add entries for new _NL_*_CODESET values. + * locale/C-ctype.c: Use _nl_C_codeset to initialize CODESET entry. + * locale/C-address.c: Initialize _NL_*_CODESET element. + * locale/C-collate.c: Likewise. + * locale/C-identification.c: Likewise. + * locale/C-measurement.c: Likewise. + * locale/C-messages.c: Likewise. + * locale/C-monetary.c: Likewise. + * locale/C-name.c: Likewise. + * locale/C-numeric.c: Likewise. + * locale/C-paper.c: Likewise. + * locale/C-telephone.c: Likewise. + * locale/C-time.c: Likewise. + * locale/localeinfo.h: Declare _nl_C_codeset. + * locale/C_name.c: Define _nl_C_codeset. + * locale/findlocale.c: Before accepting locale check that the used + charset does not conflict with what the locale name said. + * locale/programs/ld-address.c: Emit codeset information. + * locale/programs/ld-collate.c: Likewise. + * locale/programs/ld-identification.c: Likewise. + * locale/programs/ld-measurement.c: Likewise. + * locale/programs/ld-messages.c: Likewise. + * locale/programs/ld-monetary.c: Likewise. + * locale/programs/ld-name.c: Likewise. + * locale/programs/ld-numeric.c: Likewise. + * locale/programs/ld-paper.c: Likewise. + * locale/programs/ld-telephone.c: Likewise. + * locale/programs/ld-time.c: Likewise. + + * localedata/tests-mbwc/tst_funcs.h (TST_HEAD_LOCALE): It is an error + if the locale data couldn't be found. + + * string/Makefile: Define tst-strxfrm-ENV. + + * ysdeps/unix/sysv/linux/ia64/getcontext.S: Fix comment. + 2001-04-06 Andreas Jaeger <aj@suse.de> * include/sys/profil.h: New file. diff --git a/iconv/gconv_charset.h b/iconv/gconv_charset.h new file mode 100644 index 0000000..334bb5f --- /dev/null +++ b/iconv/gconv_charset.h @@ -0,0 +1,60 @@ +/* Charset name normalization. + Copyright (C) 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 2001. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <ctype.h> + + +static inline void +strip (char *wp, const char *s) +{ + int slash_count = 0; + + while (*s != '\0') + { + if (isalnum (*s) || *s == '_' || *s == '-' || *s == '.') + *wp++ = toupper (*s); + else if (*s == '/') + { + if (++slash_count == 3) + break; + *wp++ = '/'; + } + ++s; + } + + while (slash_count++ < 2) + *wp++ = '/'; + + *wp = '\0'; +} + + +static char * +upstr (char *dst, const char *str) +{ + char *cp = dst; + while ((*cp++ = toupper (*str++)) != '\0') + /* nothing */; + return dst; +} + + +/* If NAME is an codeset alias expand it. */ +extern const char *__gconv_lookup_alias (const char *name); diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c index c4ebc4f..71d64b4 100644 --- a/iconv/gconv_db.c +++ b/iconv/gconv_db.c @@ -614,13 +614,38 @@ find_derivation (const char *toset, const char *toset_expand, } +/* Control of initialization. */ +__libc_once_define (static, once); + + +static const char * +do_lookup_alias (const char *name) +{ + struct gconv_alias key; + struct gconv_alias **found; + + key.fromname = (char *) name; + found = __tfind (&key, &__gconv_alias_db, __gconv_alias_compare); + return found != NULL ? (*found)->toname : NULL; +} + + +const char * +__gconv_lookup_alias (const char *name) +{ + /* Ensure that the configuration data is read. */ + __libc_once (once, __gconv_read_conf); + + return do_lookup_alias (name) ?: name; +} + + int internal_function __gconv_find_transform (const char *toset, const char *fromset, struct __gconv_step **handle, size_t *nsteps, int flags) { - __libc_once_define (static, once); const char *fromset_expand = NULL; const char *toset_expand = NULL; int result; @@ -641,16 +666,8 @@ __gconv_find_transform (const char *toset, const char *fromset, /* See whether the names are aliases. */ if (__gconv_alias_db != NULL) { - struct gconv_alias key; - struct gconv_alias **found; - - key.fromname = (char *) fromset; - found = __tfind (&key, &__gconv_alias_db, __gconv_alias_compare); - fromset_expand = found != NULL ? (*found)->toname : NULL; - - key.fromname = (char *) toset; - found = __tfind (&key, &__gconv_alias_db, __gconv_alias_compare); - toset_expand = found != NULL ? (*found)->toname : NULL; + fromset_expand = do_lookup_alias (fromset); + toset_expand = do_lookup_alias (toset); } if (__builtin_expect (flags & GCONV_AVOID_NOCONV, 0) diff --git a/locale/C-address.c b/locale/C-address.c index 75a51d2..0d93cb9 100644 --- a/locale/C-address.c +++ b/locale/C-address.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -31,7 +31,7 @@ const struct locale_data _nl_C_LC_ADDRESS = UNDELETABLE, 0, NULL, - 12, + 13, { { string: "%a%N%f%N%d%N%b%N%s %h %e %r%N%C-%z %T%N%c%N" }, { string: "" }, @@ -44,6 +44,7 @@ const struct locale_data _nl_C_LC_ADDRESS = { string: "" }, { string: "" }, { string: "" }, - { string: "" } + { string: "" }, + { string: _nl_C_codeset } } }; diff --git a/locale/C-collate.c b/locale/C-collate.c index 964ea50..575dda7 100644 --- a/locale/C-collate.c +++ b/locale/C-collate.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,1999,2000,2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995. @@ -105,7 +105,7 @@ const struct locale_data _nl_C_LC_COLLATE = UNDELETABLE, 0, NULL, - 18, + 19, { /* _NL_COLLATE_NRULES */ { word: 0 }, @@ -142,6 +142,8 @@ const struct locale_data _nl_C_LC_COLLATE = /* _NL_COLLATE_COLLSEQMB */ { string: collseqmb }, /* _NL_COLLATE_COLLSEQWC */ - { string: (const char *) collseqwc } + { string: (const char *) collseqwc }, + /* _NL_COLLATE_CODESET */ + { string: _nl_C_codeset } } }; diff --git a/locale/C-ctype.c b/locale/C-ctype.c index 6e036f6..12ac7c1 100644 --- a/locale/C-ctype.c +++ b/locale/C-ctype.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995. @@ -590,7 +590,7 @@ const struct locale_data _nl_C_LC_CTYPE = /* _NL_CTYPE_MB_CUR_MAX */ { word: 1 }, /* _NL_CTYPE_CODESET_NAME */ - { string: "ANSI_X3.4-1968" }, + { string: _nl_C_codeset }, /* _NL_CTYPE_TOUPPER32 */ { string: (const char *) &_nl_C_LC_CTYPE_toupper[128] }, /* _NL_CTYPE_TOLOWER32 */ diff --git a/locale/C-identification.c b/locale/C-identification.c index 89ebf31..6eef07d 100644 --- a/locale/C-identification.c +++ b/locale/C-identification.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -31,7 +31,7 @@ const struct locale_data _nl_C_LC_IDENTIFICATION = UNDELETABLE, 0, NULL, - 15, + 16, { { string: "ISO/IEC 14652 i18n FDCC-set" }, { string: "ISO/IEC JTC1/SC22/WG20 - internationalization" }, @@ -51,6 +51,7 @@ const struct locale_data _nl_C_LC_IDENTIFICATION = "i18n:1999\0" "i18n:1999\0" "\0" "i18n:1999\0" "i18n:1999\0" "i18n:1999\0" "i18n:1999\0" "i18n:1999\0" "i18n:1999\0" "i18n:1999\0" "i18n:1999\0" "i18n:1999\0" - "i18n:1999" } + "i18n:1999" }, + { string: _nl_C_codeset } } }; diff --git a/locale/C-measurement.c b/locale/C-measurement.c index 92de2a9..eddd549 100644 --- a/locale/C-measurement.c +++ b/locale/C-measurement.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -31,8 +31,9 @@ const struct locale_data _nl_C_LC_MEASUREMENT = UNDELETABLE, 0, NULL, - 1, + 2, { - { string: "\1" } + { string: "\1" }, + { string: _nl_C_codeset } } }; diff --git a/locale/C-messages.c b/locale/C-messages.c index 3f96bb0..c2d7cbe 100644 --- a/locale/C-messages.c +++ b/locale/C-messages.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996, 1997, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. @@ -31,11 +31,12 @@ const struct locale_data _nl_C_LC_MESSAGES = UNDELETABLE, 0, NULL, - 4, + 5, { { string: "^[yY]" }, { string: "^[nN]" }, { string: "" }, - { string: "" } + { string: "" }, + { string: _nl_C_codeset } } }; diff --git a/locale/C-monetary.c b/locale/C-monetary.c index e04b2de..6704aa1 100644 --- a/locale/C-monetary.c +++ b/locale/C-monetary.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995. @@ -35,7 +35,7 @@ const struct locale_data _nl_C_LC_MONETARY = UNDELETABLE, 0, NULL, - 45, + 46, { { string: "" }, { string: "" }, @@ -81,6 +81,7 @@ const struct locale_data _nl_C_LC_MONETARY = { word: 99991231 }, { word: 1 }, { word: (unsigned int) L'\0' }, - { word: (unsigned int) L'\0' } + { word: (unsigned int) L'\0' }, + { string: _nl_C_codeset } } }; diff --git a/locale/C-name.c b/locale/C-name.c index fdce4cb..a34f7dc 100644 --- a/locale/C-name.c +++ b/locale/C-name.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -31,13 +31,14 @@ const struct locale_data _nl_C_LC_NAME = UNDELETABLE, 0, NULL, - 6, + 7, { { string: "%p%t%g%t%m%t%f" }, { string: "" }, { string: "" }, { string: "" }, { string: "" }, - { string: "" } + { string: "" }, + { string: _nl_C_codeset } } }; diff --git a/locale/C-numeric.c b/locale/C-numeric.c index 822780d..6afcd68 100644 --- a/locale/C-numeric.c +++ b/locale/C-numeric.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996, 1997, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995. @@ -28,12 +28,13 @@ const struct locale_data _nl_C_LC_NUMERIC = UNDELETABLE, 0, NULL, - 5, + 6, { { string: "." }, { string: "" }, { string: "" }, { word: (unsigned int) L'.' }, - { word: (unsigned int) L'\0' } + { word: (unsigned int) L'\0' }, + { string: _nl_C_codeset } } }; diff --git a/locale/C-paper.c b/locale/C-paper.c index 19f847c..21f9c99 100644 --- a/locale/C-paper.c +++ b/locale/C-paper.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -31,9 +31,10 @@ const struct locale_data _nl_C_LC_PAPER = UNDELETABLE, 0, NULL, - 2, + 3, { { word: 297 }, - { word: 210 } + { word: 210 }, + { string: _nl_C_codeset } } }; diff --git a/locale/C-telephone.c b/locale/C-telephone.c index adf407d..6d40b6f 100644 --- a/locale/C-telephone.c +++ b/locale/C-telephone.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -31,11 +31,12 @@ const struct locale_data _nl_C_LC_TELEPHONE = UNDELETABLE, 0, NULL, - 4, + 5, { { string: "+%c %a %l" }, { string: "" }, { string: "" }, - { string: "" } + { string: "" }, + { string: _nl_C_codeset } } }; diff --git a/locale/C-time.c b/locale/C-time.c index 17eed63..184dde1 100644 --- a/locale/C-time.c +++ b/locale/C-time.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1995-2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org>, 1995. @@ -30,7 +30,7 @@ const struct locale_data _nl_C_LC_TIME = UNDELETABLE, 0, NULL, - 110, + 111, { { string: "Sun" }, { string: "Mon" }, @@ -141,6 +141,7 @@ const struct locale_data _nl_C_LC_TIME = { string: "\1" }, { string: "" }, { string: "%a %b %e %H:%M:%S %Z %Y" }, - { wstr: (const uint32_t *) L"%a %b %e %H:%M:%S %Z %Y" } + { wstr: (const uint32_t *) L"%a %b %e %H:%M:%S %Z %Y" }, + { string: _nl_C_codeset } } }; diff --git a/locale/C_name.c b/locale/C_name.c index fa2ac05..7612544 100644 --- a/locale/C_name.c +++ b/locale/C_name.c @@ -6,3 +6,6 @@ /* Name of our standard locale. */ const char _nl_C_name[] = "C"; const char _nl_POSIX_name[] = "POSIX"; + +/* The standard codeset. */ +const char _nl_C_codeset[] = "ANSI_X3.4-1968"; diff --git a/locale/categories.def b/locale/categories.def index 14b02df..24e5dad 100644 --- a/locale/categories.def +++ b/locale/categories.def @@ -1,5 +1,5 @@ /* Definition of all available locale categories and their items. -*- C -*- - Copyright (C) 1995, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. + Copyright (C) 1995-2000, 2001 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -57,6 +57,7 @@ DEFINE_CATEGORY DEFINE_ELEMENT (_NL_COLLATE_SYMB_EXTRAMB, "collate-symb-extramb", std, wstring) DEFINE_ELEMENT (_NL_COLLATE_COLLSEQMB, "collate-collseqmb", std, wstring) DEFINE_ELEMENT (_NL_COLLATE_COLLSEQWC, "collate-collseqwc", std, wstring) + DEFINE_ELEMENT (_NL_COLLATE_CODESET, "collate-codeset", std, string) ), NO_POSTLOAD) @@ -182,6 +183,7 @@ DEFINE_CATEGORY DEFINE_ELEMENT (_NL_MONETARY_CONVERSION_RATE, "conversion_rate", std, wordarray, 2, 2) DEFINE_ELEMENT (_NL_MONETARY_DECIMAL_POINT_WC, "monetary-decimal-point-wc", std, word) DEFINE_ELEMENT (_NL_MONETARY_THOUSANDS_SEP_WC, "monetary-thousands-sep-wc", std, word) + DEFINE_ELEMENT (_NL_MONETARY_CODESET, "monetary-codeset", std, string) ), NO_POSTLOAD) @@ -194,6 +196,7 @@ DEFINE_CATEGORY DEFINE_ELEMENT (GROUPING, "grouping", std, bytearray) DEFINE_ELEMENT (_NL_NUMERIC_DECIMAL_POINT_WC, "numeric-decimal-point-wc", std, word) DEFINE_ELEMENT (_NL_NUMERIC_THOUSANDS_SEP_WC, "numeric-thousands-sep-wc", std, word) + DEFINE_ELEMENT (_NL_NUMERIC_CODESET, "numeric-codeset", std, string) ), NO_POSTLOAD) @@ -242,6 +245,7 @@ DEFINE_CATEGORY DEFINE_ELEMENT (_NL_TIME_TIMEZONE, "timezone", std, string) DEFINE_ELEMENT (_DATE_FMT, "date_fmt", opt, string) DEFINE_ELEMENT (_NL_W_DATE_FMT, "wide-date_fmt", opt, wstring) + DEFINE_ELEMENT (_NL_TIME_CODESET, "time-codeset", std, string) ), _nl_postload_time) @@ -253,6 +257,7 @@ DEFINE_CATEGORY DEFINE_ELEMENT (NOEXPR, "noexpr", std, string) DEFINE_ELEMENT (YESSTR, "yesstr", opt, string) DEFINE_ELEMENT (NOSTR, "nostr", opt, string) + DEFINE_ELEMENT (_NL_MESSAGES_CODESET, "messages-codeset", std, string) ), NO_POSTLOAD) DEFINE_CATEGORY @@ -261,6 +266,7 @@ DEFINE_CATEGORY ( DEFINE_ELEMENT (_NL_PAPER_HEIGHT, "height", std, word) DEFINE_ELEMENT (_NL_PAPER_WIDTH, "width", std, word) + DEFINE_ELEMENT (_NL_PAPER_CODESET, "paper-codeset", std, string) ), NO_POSTLOAD) DEFINE_CATEGORY @@ -273,6 +279,7 @@ DEFINE_CATEGORY DEFINE_ELEMENT (_NL_NAME_NAME_MRS, "name_mrs", std, string) DEFINE_ELEMENT (_NL_NAME_NAME_MISS, "name_miss", std, string) DEFINE_ELEMENT (_NL_NAME_NAME_MS, "name_ms", std, string) + DEFINE_ELEMENT (_NL_NAME_CODESET, "name-codeset", std, string) ), NO_POSTLOAD) DEFINE_CATEGORY @@ -291,6 +298,7 @@ DEFINE_CATEGORY DEFINE_ELEMENT (_NL_ADDRESS_LANG_AB, "lang_ab", std, string) DEFINE_ELEMENT (_NL_ADDRESS_LANG_TERM, "lang_term", std, string) DEFINE_ELEMENT (_NL_ADDRESS_LANG_LIB, "lang_lib", std, string) + DEFINE_ELEMENT (_NL_ADDRESS_CODESET, "address-codeset", std, string) ), NO_POSTLOAD) DEFINE_CATEGORY @@ -301,6 +309,7 @@ DEFINE_CATEGORY DEFINE_ELEMENT (_NL_TELEPHONE_TEL_DOM_FMT, "tel_dom_fmt", std, string) DEFINE_ELEMENT (_NL_TELEPHONE_INT_SELECT, "int_select", std, string) DEFINE_ELEMENT (_NL_TELEPHONE_INT_PREFIX, "int_prefix", std, string) + DEFINE_ELEMENT (_NL_TELEPHONE_CODESET, "telephone-codeset", std, string) ), NO_POSTLOAD) DEFINE_CATEGORY @@ -308,6 +317,7 @@ DEFINE_CATEGORY LC_MEASUREMENT, "LC_MEASUREMENT", ( DEFINE_ELEMENT (_NL_MEASUREMENT_MEASUREMENT, "measurement", std, byte) + DEFINE_ELEMENT (_NL_MEASUREMENT_CODESET, "measurement-codeset", std, string) ), NO_POSTLOAD) DEFINE_CATEGORY @@ -328,5 +338,6 @@ DEFINE_CATEGORY DEFINE_ELEMENT (_NL_IDENTIFICATION_ABBREVIATION, "abbreviation", std, string) DEFINE_ELEMENT (_NL_IDENTIFICATION_REVISION, "revision", std, string) DEFINE_ELEMENT (_NL_IDENTIFICATION_DATE, "date", std, string) - DEFINE_ELEMENT (_NL_IDENTIFICATION_CATEGORY, "category", std, stringarray, 13, 13) + DEFINE_ELEMENT (_NL_IDENTIFICATION_CATEGORY, "category", std, stringarray, 13, 13) + DEFINE_ELEMENT (_NL_IDENTIFICATION_CODESET, "identification-codeset", std, string) ), NO_POSTLOAD) diff --git a/locale/findlocale.c b/locale/findlocale.c index 948dee2..de2dc2e 100644 --- a/locale/findlocale.c +++ b/locale/findlocale.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -17,6 +17,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include <assert.h> #include <locale.h> #include <stdlib.h> #include <string.h> @@ -26,6 +27,7 @@ #endif #include "localeinfo.h" +#include "../iconv/gconv_charset.h" /* Constant data defined in setlocale.c. */ @@ -164,6 +166,54 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len, return NULL; } + /* The LC_CTYPE category allows to check whether a locale is really + usable. If the locale name contains a charset name and the + charset name used in the locale (present in the LC_CTYPE data) is + not the same (after resolving aliases etc) we reject the locale + since using it would irritate users expecting the charset named + in the locale name. */ + if (codeset != NULL) + { + /* Get the codeset information from the locale file. */ + static const int codeset_idx[] = + { + [__LC_CTYPE] = _NL_ITEM_INDEX (CODESET), + [__LC_NUMERIC] = _NL_ITEM_INDEX (_NL_NUMERIC_CODESET), + [__LC_TIME] = _NL_ITEM_INDEX (_NL_TIME_CODESET), + [__LC_COLLATE] = _NL_ITEM_INDEX (_NL_COLLATE_CODESET), + [__LC_MONETARY] = _NL_ITEM_INDEX (_NL_MONETARY_CODESET), + [__LC_MESSAGES] = _NL_ITEM_INDEX (_NL_MESSAGES_CODESET), + [__LC_PAPER] = _NL_ITEM_INDEX (_NL_PAPER_CODESET), + [__LC_NAME] = _NL_ITEM_INDEX (_NL_NAME_CODESET), + [__LC_ADDRESS] = _NL_ITEM_INDEX (_NL_ADDRESS_CODESET), + [__LC_TELEPHONE] = _NL_ITEM_INDEX (_NL_TELEPHONE_CODESET), + [__LC_MEASUREMENT] = _NL_ITEM_INDEX (_NL_MEASUREMENT_CODESET), + [__LC_IDENTIFICATION] = _NL_ITEM_INDEX (_NL_IDENTIFICATION_CODESET) + }; + const struct locale_data *data; + const char *locale_codeset; + char *clocale_codeset; + char *ccodeset; + + data = (const struct locale_data *) locale_file->data; + locale_codeset = + (const char *) data->values[codeset_idx[category]].string; + assert (locale_codeset != NULL); + /* Note the length of the allocated memory: +3 for up to two slashes + and the NUL byte. */ + clocale_codeset = (char *) alloca (strlen (locale_codeset) + 3); + strip (clocale_codeset, locale_codeset); + + ccodeset = (char *) alloca (strlen (codeset) + 3); + strip (ccodeset, codeset); + + if (strcmp (__gconv_lookup_alias (upstr (ccodeset, ccodeset)), + __gconv_lookup_alias (upstr (clocale_codeset, + clocale_codeset))) != 0) + /* The codesets are not identical, don't use the locale. */ + return NULL; + } + /* Determine the locale name for which loading succeeded. This information comes from the file name. The form is <path>/<locale>/LC_foo. We must extract the <locale> part. */ diff --git a/locale/langinfo.h b/locale/langinfo.h index c2e312f..4ba90d4 100644 --- a/locale/langinfo.h +++ b/locale/langinfo.h @@ -231,6 +231,8 @@ enum #define _DATE_FMT _DATE_FMT _NL_W_DATE_FMT, + _NL_TIME_CODESET, + _NL_NUM_LC_TIME, /* Number of indices in LC_TIME category. */ /* LC_COLLATE category: text sorting. @@ -254,6 +256,7 @@ enum _NL_COLLATE_SYMB_EXTRAMB, _NL_COLLATE_COLLSEQMB, _NL_COLLATE_COLLSEQWC, + _NL_COLLATE_CODESET, _NL_NUM_LC_COLLATE, /* LC_CTYPE category: character classification. @@ -459,6 +462,7 @@ enum _NL_MONETARY_CONVERSION_RATE, _NL_MONETARY_DECIMAL_POINT_WC, _NL_MONETARY_THOUSANDS_SEP_WC, + _NL_MONETARY_CODESET, _NL_NUM_LC_MONETARY, /* LC_NUMERIC category: formatting of numbers. @@ -481,6 +485,7 @@ enum #endif _NL_NUMERIC_DECIMAL_POINT_WC, _NL_NUMERIC_THOUSANDS_SEP_WC, + _NL_NUMERIC_CODESET, _NL_NUM_LC_NUMERIC, __YESEXPR = _NL_ITEM (__LC_MESSAGES, 0), /* Regex matching ``yes'' input. */ @@ -495,10 +500,12 @@ enum #if defined __USE_GNU || (defined __USE_XOPEN && !defined __USE_XOPEN2K) # define NOSTR __NOSTR #endif + _NL_MESSAGES_CODESET, _NL_NUM_LC_MESSAGES, _NL_PAPER_HEIGHT = _NL_ITEM (__LC_PAPER, 0), _NL_PAPER_WIDTH, + _NL_PAPER_CODESET, _NL_NUM_LC_PAPER, _NL_NAME_NAME_FMT = _NL_ITEM (__LC_NAME, 0), @@ -507,6 +514,7 @@ enum _NL_NAME_NAME_MRS, _NL_NAME_NAME_MISS, _NL_NAME_NAME_MS, + _NL_NAME_CODESET, _NL_NUM_LC_NAME, _NL_ADDRESS_POSTAL_FMT = _NL_ITEM (__LC_ADDRESS, 0), @@ -521,15 +529,18 @@ enum _NL_ADDRESS_LANG_AB, _NL_ADDRESS_LANG_TERM, _NL_ADDRESS_LANG_LIB, + _NL_ADDRESS_CODESET, _NL_NUM_LC_ADDRESS, _NL_TELEPHONE_TEL_INT_FMT = _NL_ITEM (__LC_TELEPHONE, 0), _NL_TELEPHONE_TEL_DOM_FMT, _NL_TELEPHONE_INT_SELECT, _NL_TELEPHONE_INT_PREFIX, + _NL_TELEPHONE_CODESET, _NL_NUM_LC_TELEPHONE, _NL_MEASUREMENT_MEASUREMENT = _NL_ITEM (__LC_MEASUREMENT, 0), + _NL_MEASUREMENT_CODESET, _NL_NUM_LC_MEASUREMENT, _NL_IDENTIFICATION_TITLE = _NL_ITEM (__LC_IDENTIFICATION, 0), @@ -547,6 +558,7 @@ enum _NL_IDENTIFICATION_REVISION, _NL_IDENTIFICATION_DATE, _NL_IDENTIFICATION_CATEGORY, + _NL_IDENTIFICATION_CODESET, _NL_NUM_LC_IDENTIFICATION, /* This marks the highest value used. */ diff --git a/locale/localeinfo.h b/locale/localeinfo.h index f1f51d8..f677369 100644 --- a/locale/localeinfo.h +++ b/locale/localeinfo.h @@ -155,6 +155,9 @@ extern struct locale_data * *const _nl_current[__LC_LAST]; extern const char _nl_C_name[]; extern const char _nl_POSIX_name[]; +/* The standard codeset. */ +extern const char _nl_C_codeset[]; + /* Extract the current CATEGORY locale's string for ITEM. */ #define _NL_CURRENT(category, item) \ (_nl_current_##category->values[_NL_ITEM_INDEX (item)].string) diff --git a/locale/programs/ld-address.c b/locale/programs/ld-address.c index ed5860d..4e1c581 100644 --- a/locale/programs/ld-address.c +++ b/locale/programs/ld-address.c @@ -410,6 +410,11 @@ address_output (struct localedef_t *locale, struct charmap_t *charmap, iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; ++cnt; + idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len; + iov[cnt].iov_base = (void *) charmap->code_set_name; + iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; + ++cnt; + assert (cnt == 3 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS)); write_locale_data (output_path, "LC_ADDRESS", diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c index 2ce4d46..ddaf3ed 100644 --- a/locale/programs/ld-collate.c +++ b/locale/programs/ld-collate.c @@ -2522,9 +2522,15 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap, assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_COLLSEQWC)); iov[2 + cnt].iov_base = collate->wcseqorder.result; iov[2 + cnt].iov_len = collate->wcseqorder.result_size; + idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len; assert (idx[cnt] % __alignof__ (int32_t) == 0); ++cnt; + assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_CODESET)); + iov[2 + cnt].iov_base = (void *) charmap->code_set_name; + iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1; + ++cnt; + assert (cnt == _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE)); write_locale_data (output_path, "LC_COLLATE", 2 + cnt, iov); diff --git a/locale/programs/ld-identification.c b/locale/programs/ld-identification.c index 12e32f8..9a6dfdf 100644 --- a/locale/programs/ld-identification.c +++ b/locale/programs/ld-identification.c @@ -185,6 +185,7 @@ identification_output (struct localedef_t *locale, struct charmap_t *charmap, uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION)]; size_t cnt = 0; size_t num; + size_t last_idx; data.magic = LIMAGIC (LC_IDENTIFICATION); data.n = _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION); @@ -267,19 +268,26 @@ identification_output (struct localedef_t *locale, struct charmap_t *charmap, ++cnt; idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + last_idx = cnt - 1; + idx[last_idx] = idx[cnt - 2]; for (num = 0; num < __LC_LAST; ++num) if (num != LC_ALL) { iov[cnt].iov_base = (void *) identification->category[num]; iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; + idx[last_idx] += iov[cnt].iov_len; ++cnt; } + assert (last_idx == _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION) - 1); + iov[cnt].iov_base = (void *) charmap->code_set_name; + iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; + ++cnt; + assert (cnt == (2 + _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION) + (__LC_LAST - 2))); - write_locale_data (output_path, "LC_IDENTIFICATION", - 2 + _NL_ITEM_INDEX (_NL_NUM_LC_IDENTIFICATION), iov); + write_locale_data (output_path, "LC_IDENTIFICATION", cnt, iov); } diff --git a/locale/programs/ld-measurement.c b/locale/programs/ld-measurement.c index 07eb3cb..e2cfa6a 100644 --- a/locale/programs/ld-measurement.c +++ b/locale/programs/ld-measurement.c @@ -141,6 +141,11 @@ measurement_output (struct localedef_t *locale, struct charmap_t *charmap, iov[cnt].iov_len = 1; ++cnt; + idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len; + iov[cnt].iov_base = (void *) charmap->code_set_name; + iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; + ++cnt; + assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_MEASUREMENT)); write_locale_data (output_path, "LC_MEASUREMENT", diff --git a/locale/programs/ld-messages.c b/locale/programs/ld-messages.c index cbf240e..dd5de42 100644 --- a/locale/programs/ld-messages.c +++ b/locale/programs/ld-messages.c @@ -216,6 +216,11 @@ messages_output (struct localedef_t *locale, struct charmap_t *charmap, idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; iov[cnt].iov_base = (char *) messages->nostr; iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; + ++cnt; + + idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + iov[cnt].iov_base = (char *) charmap->code_set_name; + iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; assert (cnt + 1 == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_MESSAGES)); diff --git a/locale/programs/ld-monetary.c b/locale/programs/ld-monetary.c index 7779e87..3eeb305 100644 --- a/locale/programs/ld-monetary.c +++ b/locale/programs/ld-monetary.c @@ -608,6 +608,11 @@ monetary_output (struct localedef_t *locale, struct charmap_t *charmap, iov[cnt].iov_len = sizeof (uint32_t); ++cnt; + idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len; + iov[cnt].iov_base = (void *) charmap->code_set_name; + iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; + ++cnt; + assert (cnt == 3 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY)); write_locale_data (output_path, "LC_MONETARY", diff --git a/locale/programs/ld-name.c b/locale/programs/ld-name.c index 7940c03..8d7b863 100644 --- a/locale/programs/ld-name.c +++ b/locale/programs/ld-name.c @@ -200,6 +200,11 @@ name_output (struct localedef_t *locale, struct charmap_t *charmap, iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; ++cnt; + idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + iov[cnt].iov_base = (void *) charmap->code_set_name; + iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; + ++cnt; + assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_NAME)); write_locale_data (output_path, "LC_NAME", diff --git a/locale/programs/ld-numeric.c b/locale/programs/ld-numeric.c index 77633ef..6bf6c25 100644 --- a/locale/programs/ld-numeric.c +++ b/locale/programs/ld-numeric.c @@ -178,6 +178,11 @@ numeric_output (struct localedef_t *locale, struct charmap_t *charmap, idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len; iov[cnt].iov_base = (void *) &numeric->thousands_sep_wc; iov[cnt].iov_len = sizeof (uint32_t); + ++cnt; + + idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len; + iov[cnt].iov_base = (void *) charmap->code_set_name; + iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; assert (cnt + 1 == 3 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC)); diff --git a/locale/programs/ld-paper.c b/locale/programs/ld-paper.c index d0ca850..b55f985 100644 --- a/locale/programs/ld-paper.c +++ b/locale/programs/ld-paper.c @@ -143,6 +143,11 @@ paper_output (struct localedef_t *locale, struct charmap_t *charmap, iov[cnt].iov_len = 4; ++cnt; + idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + iov[cnt].iov_base = (void *) charmap->code_set_name; + iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; + ++cnt; + assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_PAPER)); write_locale_data (output_path, "LC_PAPER", diff --git a/locale/programs/ld-telephone.c b/locale/programs/ld-telephone.c index 2d59079..a2c8d51 100644 --- a/locale/programs/ld-telephone.c +++ b/locale/programs/ld-telephone.c @@ -210,6 +210,11 @@ telephone_output (struct localedef_t *locale, struct charmap_t *charmap, iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; ++cnt; + idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + iov[cnt].iov_base = (void *) charmap->code_set_name;; + iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; + ++cnt; + assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_TELEPHONE)); write_locale_data (output_path, "LC_TELEPHONE", diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c index 1475953..37615c4 100644 --- a/locale/programs/ld-time.c +++ b/locale/programs/ld-time.c @@ -869,6 +869,12 @@ time_output (struct localedef_t *locale, struct charmap_t *charmap, iov[2 + cnt].iov_base = (void *) time->wdate_fmt; iov[2 + cnt].iov_len = ((wcslen (iov[2 + cnt].iov_base) + 1) * sizeof (uint32_t)); + idx[1 + last_idx] = idx[last_idx] + iov[2 + cnt].iov_len; + ++cnt; + ++last_idx; + + iov[2 + cnt].iov_base = (void *) charmap->code_set_name; + iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1; ++cnt; ++last_idx; diff --git a/localedata/tests-mbwc/tst_funcs.h b/localedata/tests-mbwc/tst_funcs.h index e686bfe..552bed2 100644 --- a/localedata/tests-mbwc/tst_funcs.h +++ b/localedata/tests-mbwc/tst_funcs.h @@ -103,6 +103,7 @@ extern int result (FILE * fp, char res, const char *func, const char *loc, fprintf (stderr, "Warning : can't set locale: %s\nskipping ...\n", \ locale); \ result (fp, C_LOCALES, s_func, locale, 0, 0, 0, "can't set locale"); \ + ++err_count; \ continue; \ } diff --git a/string/Makefile b/string/Makefile index ff86bbb..c7dcbc4 100644 --- a/string/Makefile +++ b/string/Makefile @@ -57,6 +57,7 @@ include ../Rules tester-ENV = LANGUAGE=C inl-tester-ENV = LANGUAGE=C noinl-tester-ENV = LANGUAGE=C +tst-strxfrm-ENV = LOCPATH=$(common-objpfx)localedata CFLAGS-noinl-tester.c = -fno-builtin CFLAGS-tst-strlen.c = -fno-builtin CFLAGS-stratcliff.c = -fno-builtin diff --git a/sysdeps/unix/sysv/linux/ia64/getcontext.S b/sysdeps/unix/sysv/linux/ia64/getcontext.S index 24b58d4..2669a2b 100644 --- a/sysdeps/unix/sysv/linux/ia64/getcontext.S +++ b/sysdeps/unix/sysv/linux/ia64/getcontext.S @@ -1,5 +1,5 @@ /* Copyright (C) 2001 Free Software Foundation, Inc. - Contributed by David Mosberger-Tang <davidm@hpl.hp.com>. + Contributed by David Mosberger-Tang <davidm@hpl.hp.com>. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -21,7 +21,7 @@ #include "ucontext_i.h" -/* __getcontext (const ucontext_t *ucp) +/* __getcontext (ucontext_t *ucp) Saves the machine context in UCP such that when it is activated, it appears as if __getcontext() returned again. The only difference |