diff options
| author | Ulrich Drepper <drepper@redhat.com> | 1999-12-24 05:42:34 +0000 |
|---|---|---|
| committer | Ulrich Drepper <drepper@redhat.com> | 1999-12-24 05:42:34 +0000 |
| commit | 575b273bdc8b2fe0be70396486e9fbc400b2e641 (patch) | |
| tree | 6df0b1bb75edc18a3786b5f7fe470ac7bce3ea73 | |
| parent | 46fd4f671c45b70909e03160aa4568db5f6c8556 (diff) | |
| download | glibc-575b273bdc8b2fe0be70396486e9fbc400b2e641.tar.xz glibc-575b273bdc8b2fe0be70396486e9fbc400b2e641.zip | |
Update.
1999-12-23 Ulrich Drepper <drepper@cygnus.com>
* locale/en_BW: New file.
* locale/en_ZW: New file.
Contributed by Schalk W. Cronjé <schalkc@ntaba.co.za>.
Contributed by Schalk W. Cronjé <schalkc@ntaba.co.za>.
| -rw-r--r-- | NAMESPACE | 1 | ||||
| -rw-r--r-- | intl/gettextP.h | 2 | ||||
| -rw-r--r-- | intl/libintl.h | 29 | ||||
| -rw-r--r-- | locale/C-collate.c | 35 | ||||
| -rw-r--r-- | locale/categories.def | 4 | ||||
| -rw-r--r-- | locale/iso-4217.def | 5 | ||||
| -rw-r--r-- | locale/langinfo.h | 20 | ||||
| -rw-r--r-- | locale/lc-collate.c | 39 | ||||
| -rw-r--r-- | locale/localeinfo.h | 15 | ||||
| -rw-r--r-- | locale/programs/ld-collate.c | 488 | ||||
| -rw-r--r-- | locale/programs/ld-monetary.c | 2 | ||||
| -rw-r--r-- | locale/setlocale.c | 12 | ||||
| -rw-r--r-- | localedata/ChangeLog | 7 |
13 files changed, 488 insertions, 171 deletions
@@ -6,6 +6,7 @@ complex.h cerf{,f,l}, cerfc{,f,l}, cexp2{,f,l}, clog2{,f,l}, clgamma{,f,l}, ctgamma{,f,l} ctype.h is[a-z], to[a-z] dirent.h d_ +dlfcn.h RTLD_ errno.h E fcntl.h l_ glob.h gl_, GLOB_ diff --git a/intl/gettextP.h b/intl/gettextP.h index 1b4dcb3e07..b3c8c18598 100644 --- a/intl/gettextP.h +++ b/intl/gettextP.h @@ -92,6 +92,8 @@ struct binding char *dirname; }; +extern int _nl_msg_cat_cntr; + struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname, char *__locale, const char *__domainname)) diff --git a/intl/libintl.h b/intl/libintl.h index 0c987e7d73..10c3726b7c 100644 --- a/intl/libintl.h +++ b/intl/libintl.h @@ -82,34 +82,7 @@ extern char *bindtextdomain (__const char *__domainname, # define dgettext(domainname, msgid) \ dcgettext (domainname, msgid, LC_MESSAGES) -# if __GLIBC__ >= 2 && __GNUC_PREREQ (2,7) -/* Variable defined in loadmsgcat.c which gets incremented every time a - new catalog is loaded. */ -extern int _nl_msg_cat_cntr; - -# define dcgettext(domainname, msgid, category) \ - (__extension__ \ - ({ \ - char *__result; \ - if (__builtin_constant_p (msgid)) \ - { \ - static char *__translation__; \ - static int __catalog_counter__; \ - if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr) \ - { \ - __translation__ = \ - __dcgettext ((domainname), (msgid), (category)); \ - __catalog_counter__ = _nl_msg_cat_cntr; \ - } \ - __result = __translation__; \ - } \ - else \ - __result = __dcgettext ((domainname), (msgid), (category)); \ - __result; \ - })) -# endif -#endif /* Optimizing. */ - +#endif /* Optimizing. */ __END_DECLS diff --git a/locale/C-collate.c b/locale/C-collate.c index 6fd0e721be..94f6e0f60f 100644 --- a/locale/C-collate.c +++ b/locale/C-collate.c @@ -20,11 +20,12 @@ #include <endian.h> #include "localeinfo.h" +#if 0 /* These tables' entries contain values which make the function behave according to POSIX.2 Table 2-8 ``LC_COLLATE Category Definition in the POSIX Locale''. */ -const u_int32_t _nl_C_LC_COLLATE_symbol_hash[446] = +const uint32_t _nl_C_LC_COLLATE_symbol_hash[446] = { 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0x00000154u, 0x00000060u, 0xffffffffu, 0xffffffffu, @@ -123,7 +124,7 @@ const char _nl_C_LC_COLLATE_symbol_strings[732] = "r\0" "s\0" "t\0" "u\0" "v\0" "w\0" "x\0" "y\0" "z\0" "left-curly-bracket\0" "vertical-line\0" "right-curly-bracket\0" "tilde\0" "DEL\0"; -const u_int32_t _nl_C_LC_COLLATE_symbol_classes[256] = +const uint32_t _nl_C_LC_COLLATE_symbol_classes[256] = { 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, @@ -142,43 +143,19 @@ const u_int32_t _nl_C_LC_COLLATE_symbol_classes[256] = 1, 112, 1, 113, 1, 114, 1, 115, 1, 116, 1, 117, 1, 118, 1, 119, 1, 120, 1, 121, 1, 122, 1, 123, 1, 124, 1, 125, 1, 126, 1, 127 }; +#endif const struct locale_data _nl_C_LC_COLLATE = { _nl_C_name, NULL, 0, 0, /* no file mapped */ UNDELETABLE, - 30, + 5, { { word: 0 }, { string: NULL }, - { word: 0 }, - { word: 0 }, - { string: NULL }, - { string: NULL }, - { string: NULL }, - { string: NULL }, - { word: 0 }, - { word: 0 }, - { string: NULL }, - { string: NULL }, - { string: NULL }, - { string: NULL }, - { word: 0 }, - { string: NULL }, - { string: NULL }, - { string: NULL }, - { string: NULL }, - { string: NULL }, - { string: NULL }, - { string: NULL }, - { string: NULL }, - { string: NULL }, - { word: 223 }, - { string: (const char *) _nl_C_LC_COLLATE_symbol_hash }, - { string: _nl_C_LC_COLLATE_symbol_strings }, { string: NULL }, { string: NULL }, - { string: (const char *) _nl_C_LC_COLLATE_symbol_classes } + { string: NULL } } }; diff --git a/locale/categories.def b/locale/categories.def index d94840c5c2..06d79ed202 100644 --- a/locale/categories.def +++ b/locale/categories.def @@ -43,6 +43,10 @@ DEFINE_CATEGORY LC_COLLATE, "LC_COLLATE", ( DEFINE_ELEMENT (_NL_COLLATE_NRULES, "collate-nrules", std, word) + DEFINE_ELEMENT (_NL_COLLATE_RULESETS, "collate-rulesets", std, string) + DEFINE_ELEMENT (_NL_COLLATE_TABLEMB, "collate-tablemb", std, string) + DEFINE_ELEMENT (_NL_COLLATE_WEIGHTMB, "collate-weightmb", std, string) + DEFINE_ELEMENT (_NL_COLLATE_EXTRAMB, "collate-extramb", std, string) ), _nl_postload_collate) diff --git a/locale/iso-4217.def b/locale/iso-4217.def index bd777639e0..d35def61a2 100644 --- a/locale/iso-4217.def +++ b/locale/iso-4217.def @@ -12,14 +12,13 @@ DEFINE_INT_CURR("AFA ") /* Afghanistan Afgani */ DEFINE_INT_CURR("ALL ") /* Albanian Lek */ DEFINE_INT_CURR("AMD ") /* Armenia Dram */ DEFINE_INT_CURR("ANG ") /* Netherlands Antilles */ -DEFINE_INT_CURR("AOK ") /* Angolan Kwanza */ /* obsolete */ DEFINE_INT_CURR("AON ") /* Angolan New Kwanza */ DEFINE_INT_CURR("ARS ") /* Argentine Peso */ DEFINE_INT_CURR("ATS ") /* Austrian Schilling */ DEFINE_INT_CURR("AUD ") /* Australian Dollar */ DEFINE_INT_CURR("AWG ") /* Aruba Guilder */ DEFINE_INT_CURR("AZM ") /* Azerbaijan Manat */ -DEFINE_INT_CURR("BAD ") /* Bosnian Dinar */ +DEFINE_INT_CURR("BAK ") /* Bosnian and Herzegovina Convertible Mark */ DEFINE_INT_CURR("BBD ") /* Barbados Dollar */ DEFINE_INT_CURR("BDT ") /* Bangladesh Taka */ DEFINE_INT_CURR("BEF ") /* Belgian Franc */ @@ -32,7 +31,6 @@ DEFINE_INT_CURR("BOB ") /* Bolivian Boliviano */ DEFINE_INT_CURR("BPS ") /* Canton and Enderbury Islands */ /* ?? */ DEFINE_INT_CURR("BRE ") /* Brazil Real */ /* obsolete */ DEFINE_INT_CURR("BRL ") /* Brazil Cruzeiro */ -DEFINE_INT_CURR("BRR ") /* Brazil Real */ /* obsolete */ DEFINE_INT_CURR("BSD ") /* Bahamas Dollar */ DEFINE_INT_CURR("BTN ") /* Bhutan Ngultrum */ DEFINE_INT_CURR("BUK ") /* Burma */ /* obsolete */ @@ -129,6 +127,7 @@ DEFINE_INT_CURR("MWK ") /* Malawi Kwacha */ DEFINE_INT_CURR("MXP ") /* Mexican Peso */ DEFINE_INT_CURR("MYR ") /* Malaysian Ringgit */ DEFINE_INT_CURR("MZM ") /* Mozambique Metical */ +DEFINE_INT_CURR("NAD ") /* Namibia Dollar */ DEFINE_INT_CURR("NGN ") /* Nigeria Naira */ DEFINE_INT_CURR("NIC ") /* Nicaragua Cordoba */ DEFINE_INT_CURR("NLG ") /* Netherlands Guilder */ diff --git a/locale/langinfo.h b/locale/langinfo.h index 44f4064708..ff48fab35f 100644 --- a/locale/langinfo.h +++ b/locale/langinfo.h @@ -231,26 +231,10 @@ enum This information is accessed by the strcoll and strxfrm functions. These `nl_langinfo' names are used only internally. */ _NL_COLLATE_NRULES = _NL_ITEM (LC_COLLATE, 0), -#if 0 + _NL_COLLATE_RULESETS, _NL_COLLATE_TABLEMB, - _NL_COLLATE_HASH_SIZE, - _NL_COLLATE_HASH_LAYERS, - _NL_COLLATE_TABLEWC, - _NL_COLLATE_UNDEFINED_WC, + _NL_COLLATE_WEIGHTMB, _NL_COLLATE_EXTRAMB, - _NL_COLLATE_EXTRAWC, - _NL_COLLATE_ELEM_HASH_SIZE, - _NL_COLLATE_ELEM_HASH, - _NL_COLLATE_ELEM_STR_POOL, - _NL_COLLATE_ELEM_VAL, - _NL_COLLATE_ELEM_VALMB, - _NL_COLLATE_ELEM_VALWC, - _NL_COLLATE_SYMB_HASH_SIZE, - _NL_COLLATE_SYMB_HASH, - _NL_COLLATE_SYMB_STR_POOL, - _NL_COLLATE_SYMB_CLASSMB, - _NL_COLLATE_SYMB_CLASSWC, -#endif _NL_NUM_LC_COLLATE, /* LC_CTYPE category: character classification. diff --git a/locale/lc-collate.c b/locale/lc-collate.c index c448e1079d..02262b5ce2 100644 --- a/locale/lc-collate.c +++ b/locale/lc-collate.c @@ -21,47 +21,22 @@ #include <endian.h> -extern const u_int32_t _nl_C_LC_COLLATE_symbol_hash[]; -extern const char _nl_C_LC_COLLATE_symbol_strings[]; -extern const u_int32_t _nl_C_LC_COLLATE_symbol_classes[]; - - _NL_CURRENT_DEFINE (LC_COLLATE); -const u_int32_t *__collate_tablewc; -const u_int32_t *__collate_extrawc; - -const u_int32_t *__collate_element_hash; -const char *__collate_element_strings; -const uint32_t *__collate_element_values; - -const u_int32_t *__collate_symbol_hash = _nl_C_LC_COLLATE_symbol_hash; -const char *__collate_symbol_strings = _nl_C_LC_COLLATE_symbol_strings; -const u_int32_t *__collate_symbol_classeswc = _nl_C_LC_COLLATE_symbol_classes; - +const int32_t *__collate_tablemb; +const unsigned char *__collate_weightmb; +const unsigned char *__collate_extramb; /* We are called after loading LC_CTYPE data to load it into the variables used by the collation functions and regex. */ void _nl_postload_collate (void) { -#if 0 - /* XXX For now */ #define paste(a,b) paste1(a,b) #define paste1(a,b) a##b +#define current(x) _NL_CURRENT (LC_COLLATE, paste(_NL_COLLATE_,x)) -#define current(x) \ - ((const unsigned int *) _NL_CURRENT (LC_COLLATE, paste(_NL_COLLATE_,x))) - - __collate_tablewc = current (TABLEWC); - __collate_extrawc = current (EXTRAWC); - - __collate_element_hash = current (ELEM_HASH); - __collate_element_strings = (const char *) current (ELEM_STR_POOL); - __collate_element_values = (const uint32_t *) current (ELEM_VAL); - - __collate_symbol_hash = current (SYMB_HASH); - __collate_symbol_strings = (const char *) current (SYMB_STR_POOL); - __collate_symbol_classeswc = current (SYMB_CLASSWC); -#endif + __collate_tablemb = (const int32_t *) current (TABLEMB); + __collate_weightmb = (const unsigned char *) current (WEIGHTMB); + __collate_extramb = (const unsigned char *) current (EXTRAMB); } diff --git a/locale/localeinfo.h b/locale/localeinfo.h index c72ea9d84d..078e205f4f 100644 --- a/locale/localeinfo.h +++ b/locale/localeinfo.h @@ -36,9 +36,7 @@ #define LIMAGIC(category) (0x980505 ^ (category)) /* Two special weight constants for the collation data. */ -#define FORWARD_CHAR ((uint32_t) 0xfffffffd) -#define ELLIPSIS_CHAR ((uint32_t) 0xfffffffe) -#define IGNORE_CHAR ((uint32_t) 0xffffffff) +#define IGNORE_CHAR 2 /* We use a special value for the usage counter in `locale_data' to signal that this data must never be removed anymore. */ @@ -184,13 +182,8 @@ extern const wchar_t *_nl_get_walt_digit (unsigned int number); /* Global variables for LC_COLLATE category data. */ -extern const uint32_t *__collate_tablewc; -extern const uint32_t *__collate_extrawc; -extern const uint32_t *__collate_element_hash; -extern const char *__collate_element_strings; -extern const uint32_t *__collate_element_values; -extern const uint32_t *__collate_symbol_hash; -extern const char *__collate_symbol_strings; -extern const uint32_t *__collate_symbol_classes; +extern const int32_t *__collate_tablemb; +extern const unsigned char *__collate_extrweightmb; +extern const unsigned char *__collate_extramb; #endif /* localeinfo.h */ diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c index 52c4e3c6a1..a0f1139cde 100644 --- a/locale/programs/ld-collate.c +++ b/locale/programs/ld-collate.c @@ -54,6 +54,8 @@ struct section_list struct element_t *last; /* These are the rules for this section. */ enum coll_sort_rule *rules; + /* Index of the rule set in the appropriate section of the output file. */ + int ruleidx; }; struct element_t; @@ -72,7 +74,9 @@ struct element_t const char *name; const char *mbs; + size_t nmbs; const uint32_t *wcs; + size_t nwcs; int *mborder; int wcorder; @@ -175,6 +179,55 @@ struct locale_collate_t static int nrules; +/* These are definitions used by some of the functions for handling + UTF-8 encoding below. */ +static const uint32_t encoding_mask[] = +{ + ~0x7ff, ~0xffff, ~0x1fffff, ~0x3ffffff +}; + +static const unsigned char encoding_byte[] = +{ + 0xc0, 0xe0, 0xf0, 0xf8, 0xfc +}; + + +/* We need UTF-8 encoding of numbers. */ +static inline int +utf8_encode (char *buf, int val) +{ + char *startp = buf; + int retval; + + if (val < 0x80) + { + *buf++ = (char) val; + retval = 1; + } + else + { + int step; + + for (step = 2; step < 6; ++step) + if ((val & encoding_mask[step - 2]) == 0) + break; + retval = step; + + *buf = encoding_byte[step - 2]; + --step; + do + { + buf[step] = 0x80 | (val & 0x3f); + val >>= 6; + } + while (--step > 0); + *buf |= val; + } + + return buf - startp; +} + + static struct section_list * make_seclist_elem (struct locale_collate_t *collate, const char *string, struct section_list *next) @@ -202,19 +255,29 @@ new_element (struct locale_collate_t *collate, const char *mbs, size_t mbslen, newp->name = name == NULL ? NULL : obstack_copy0 (&collate->mempool, name, namelen); if (mbs != NULL) - newp->mbs = obstack_copy0 (&collate->mempool, mbs, mbslen); + { + newp->mbs = obstack_copy0 (&collate->mempool, mbs, mbslen); + newp->nmbs = mbslen; + } else - newp->mbs = NULL; + { + newp->mbs = NULL; + newp->nmbs = 0; + } if (wcs != NULL) { - size_t nwcs = wcslen ((wchar_t *) wcs) + 1; + size_t nwcs = wcslen ((wchar_t *) wcs); uint32_t zero = 0; obstack_grow (&collate->mempool, wcs, nwcs * sizeof (uint32_t)); obstack_grow (&collate->mempool, &zero, sizeof (uint32_t)); newp->wcs = (uint32_t *) obstack_finish (&collate->mempool); + newp->nwcs = nwcs; } else - newp->wcs = NULL; + { + newp->wcs = NULL; + newp->nwcs = 0; + } newp->mborder = NULL; newp->wcorder = 0; newp->used_in_level = 0; @@ -225,7 +288,7 @@ new_element (struct locale_collate_t *collate, const char *mbs, size_t mbslen, newp->file = NULL; newp->line = 0; - newp->section = NULL; + newp->section = collate->current_section; newp->last = NULL; newp->next = NULL; @@ -532,6 +595,7 @@ insert_weights (struct linereader *ldfile, struct element_t *elem, elem->line = ldfile->lineno; elem->last = collate->cursor; elem->next = collate->cursor ? collate->cursor->next : NULL; + elem->section = collate->current_section; if (collate->cursor != NULL) collate->cursor->next = elem; if (collate->start == NULL) @@ -801,6 +865,25 @@ insert_value (struct linereader *ldfile, struct token *arg, /* This cannot happen. */ assert (! "Internal error"); } + else + { + /* Maybe the character was used before the definition. In this case + we have to insert the byte sequences now. */ + if (elem->mbs == NULL && seq != NULL) + { + elem->mbs = obstack_copy0 (&collate->mempool, + seq->bytes, seq->nbytes); + elem->nmbs = seq->nbytes; + } + + if (elem->wcs == NULL && seq != ILLEGAL_CHAR_VALUE) + { + uint32_t wcs[2] = { wc, 0 }; + + elem->wcs = obstack_copy (&collate->mempool, wcs, sizeof (wcs)); + elem->nwcs = 1; + } + } } /* Test whether this element is not already in the list. */ @@ -808,7 +891,7 @@ insert_value (struct linereader *ldfile, struct token *arg, && elem->next == collate->cursor)) { lr_error (ldfile, _("order for `%.*s' already defined at %s:%zu"), - arg->val.str.lenmb, arg->val.str.startmb, + (int) arg->val.str.lenmb, arg->val.str.startmb, elem->file, elem->line); lr_ignore_rest (ldfile, 0); return 1; @@ -866,8 +949,8 @@ handle_ellipsis (struct linereader *ldfile, struct token *arg, sequences for the first and end character must be the same. This is mainly to prevent unwanted effects and this is often not what is wanted. */ - size_t len = (startp->mbs != NULL ? strlen (startp->mbs) - : (endp->mbs != NULL ? strlen (endp->mbs) : 0)); + size_t len = (startp->mbs != NULL ? startp->nmbs + : (endp->mbs != NULL ? endp->nmbs : 0)); char mbcnt[len + 1]; char mbend[len + 1]; @@ -878,7 +961,7 @@ handle_ellipsis (struct linereader *ldfile, struct token *arg, if (startp != NULL && endp != NULL && startp->mbs != NULL && endp->mbs != NULL - && strlen (startp->mbs) != strlen (endp->mbs)) + && startp->nmbs != endp->nmbs) { lr_error (ldfile, _("\ %s: byte sequences of first and last character must have the same length"), @@ -974,7 +1057,8 @@ sequence is not lower than that of the last character"), "LC_COLLATE"); { lr_error (ldfile, _("\ order for `%.*s' already defined at %s:%zu"), - namelen, seq->name, elem->file, elem->line); + (int) namelen, seq->name, + elem->file, elem->line); goto increment; } @@ -1066,7 +1150,7 @@ order for `%.*s' already defined at %s:%zu"), invalid_range: lr_error (ldfile, _("\ `%s' and `%.*s' are no valid names for symbolic range"), - startp->name, lento, endp->name); + startp->name, (int) lento, endp->name); return; } @@ -1112,7 +1196,7 @@ order for `%.*s' already defined at %s:%zu"), { lr_error (ldfile, _("\ %s: order for `%.*s' already defined at %s:%zu"), - "LC_COLLATE", lenfrom, buf, + "LC_COLLATE", (int) lenfrom, buf, elem->file, elem->line); continue; } @@ -1160,8 +1244,11 @@ order for `%.*s' already defined at %s:%zu"), { /* Update the element. */ if (seq != NULL) - elem->mbs = obstack_copy0 (&collate->mempool, - seq->bytes, seq->nbytes); + { + elem->mbs = obstack_copy0 (&collate->mempool, + seq->bytes, seq->nbytes); + elem->nmbs = seq->nbytes; + } if (wc != ILLEGAL_CHAR_VALUE) { @@ -1172,11 +1259,13 @@ order for `%.*s' already defined at %s:%zu"), obstack_grow (&collate->mempool, &zero, sizeof (uint32_t)); elem->wcs = obstack_finish (&collate->mempool); + elem->nwcs = 1; } } elem->file = ldfile->fname; elem->line = ldfile->lineno; + elem->section = collate->current_section; } /* Enqueue the new element. */ @@ -1281,6 +1370,8 @@ collate_finish (struct localedef_t *locale, struct charmap_t *charmap) struct element_t *runp; int i; int need_undefined = 0; + struct section_list *sect; + int ruleidx; /* If this assertion is hit change the type in `element_t'. */ assert (nrules <= sizeof (runp->used_in_level) * 8); @@ -1327,7 +1418,7 @@ collate_finish (struct localedef_t *locale, struct charmap_t *charmap) Since at each time only the weights for each of the rules are only compared to other weights for this rule it is possible to assign more compact weight values than simply counting all - weights in sequence. We can assign weights from 2 one for each + weights in sequence. We can assign weights from 3, one for each rule individually and only for those elements, which are actually used for this rule. @@ -1336,44 +1427,64 @@ collate_finish (struct localedef_t *locale, struct charmap_t *charmap) be encoded to make it possible to emit the value as a byte string. */ for (i = 0; i < nrules; ++i) - mbact[i] = 2; - wcact = 2; + mbact[i] = 3; + wcact = 3; runp = collate->start; while (runp != NULL) { - if (runp->mbs != NULL) + /* Determine the order. */ + if (runp->used_in_level != 0) { - struct element_t **eptr; + runp->mborder = (int *) obstack_alloc (&collate->mempool, + nrules * sizeof (int)); - /* Determine the order. */ |
