From 8907c7e1a03b721ce696bce499b52ebc7ebb1cd7 Mon Sep 17 00:00:00 2001 From: jbj Date: Thu, 19 Aug 1999 19:42:18 +0000 Subject: [PATCH] match "de" when locale is specified as "de_DE.ISO-8859-1@Munich". CVS patchset: 3239 CVS date: 1999/08/19 19:42:18 --- CHANGES | 1 + lib/header.c | 82 +++++++++++++++++++++++++++++++++++++----------------------- po/rpm.pot | 38 ++++++++++++++-------------- 3 files changed, 71 insertions(+), 50 deletions(-) diff --git a/CHANGES b/CHANGES index 4c40b12..92aadc4 100644 --- a/CHANGES +++ b/CHANGES @@ -29,6 +29,7 @@ - prepare for handling \r in macro exapnsions. - fix: n>1 occurrences of %config(noreplace) should not FA_CREATE (#4355). - fix: use pgp5 rather than pgp-2.6.3 if both are in %_pgpbin (#4564). + - match "de" when locale is specified as "de_DE.ISO-8859-1@Munich". 3.0.1 -> 3.0.2 - eliminate armv4 entries from rpmrc (Andrew E. Mileski). diff --git a/lib/header.c b/lib/header.c index 5967e34..1ee8f07 100644 --- a/lib/header.c +++ b/lib/header.c @@ -787,44 +787,64 @@ int headerGetRawEntry(Header h, int_32 tag, int_32 *type, void **p, int_32 *c) static char *headerFindI18NString(Header h, struct indexEntry *entry) { - char * lang, * buf, * chptr, * start, * next, * resptr; + const char *lang, *l, *le; struct indexEntry * table; - int langNum; - if (! (lang = getenv("LANGUAGE"))) { - lang = getenv("LANG"); - } + if (((lang = getenv("LANGUAGE")) == NULL && + (lang = getenv("LANG")) == NULL)) + return entry->data; - table = findEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE); - - if (!lang || !table) { + if ((table = findEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE)) == NULL) return entry->data; - } - buf = alloca(strlen(lang) + 1); - strcpy(buf, lang); + for (l = lang; *l; l = le) { + const char *td, *fe; + char *ed; + int count; - start = buf; - while (start) { - chptr = strchr(start, ':'); - if (chptr) *chptr = '\0'; - - next = table->data; - resptr = entry->data; - for (langNum = 0; langNum < entry->info.count; langNum++) { - if (!strcmp(next, start) && *resptr) break; - next += strlen(next) + 1; - resptr += strlen(resptr) + 1; - } - - if (langNum < entry->info.count) { - return resptr; + while (*l && *l == ':') /* skip leading colons */ + l++; + if (*l == '\0') + break; + for (le = l; *le && *le != ':'; le++) /* find end of this locale */ + ; + + /* + * The range [l,le) now contains the next locale to match: + * ll[_CC][.EEEEE][@dddd] + * where + * ll ISO language code (in lowercase). + * CC (optional) ISO coutnry code (in uppercase). + * EEEEE (optional) encoding (not really standardized). + * dddd (optional) dialect. + */ + + /* For each entry in the header ... */ + for (count = entry->info.count, td = table->data, ed = entry->data; + count-- > 0; td += strlen(td) + 1, ed += strlen(ed) + 1) { + + /* First try a complete match. */ + if (!strncmp(td, l, (le - l))) + return ed; + + /* Next, try stripping optional dialect and matching. */ + for (fe = l; fe < le && *fe != '@'; fe++) + ; + if (fe < le && !strncmp(td, l, (fe - l))) + return ed; + + /* Next, try stripping optional codeset and matching. */ + for (fe = l; fe < le && *fe != '.'; fe++) + ; + if (fe < le && !strncmp(td, l, (fe - l))) + return ed; + + /* Finally, try stripping optional country code and matching. */ + for (fe = l; fe < le && *fe != '_'; fe++) + ; + if (fe < le && !strncmp(td, l, (fe - l))) + return ed; } - - if (chptr) - start = chptr + 1; - else - start = NULL; } return entry->data; diff --git a/po/rpm.pot b/po/rpm.pot index f4fcf34..b20cf53 100644 --- a/po/rpm.pot +++ b/po/rpm.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 1999-08-18 12:12-0400\n" +"POT-Creation-Date: 1999-08-19 15:21-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2016,8 +2016,8 @@ msgid "" msgstr "" #: ../lib/formats.c:65 ../lib/formats.c:83 ../lib/formats.c:104 -#: ../lib/formats.c:137 ../lib/header.c:1995 ../lib/header.c:2012 -#: ../lib/header.c:2032 +#: ../lib/formats.c:137 ../lib/header.c:2015 ../lib/header.c:2032 +#: ../lib/header.c:2052 msgid "(not a number)" msgstr "" @@ -2108,69 +2108,69 @@ msgstr "" msgid "Data type %d not supprted\n" msgstr "" -#: ../lib/header.c:995 +#: ../lib/header.c:1015 #, c-format msgid "Bad count for headerAddEntry(): %d\n" msgstr "" -#: ../lib/header.c:1395 +#: ../lib/header.c:1415 #, c-format msgid "missing { after %" msgstr "" -#: ../lib/header.c:1423 +#: ../lib/header.c:1443 msgid "missing } after %{" msgstr "" -#: ../lib/header.c:1435 +#: ../lib/header.c:1455 msgid "empty tag format" msgstr "" -#: ../lib/header.c:1445 +#: ../lib/header.c:1465 msgid "empty tag name" msgstr "" -#: ../lib/header.c:1460 +#: ../lib/header.c:1480 msgid "unknown tag" msgstr "" -#: ../lib/header.c:1486 +#: ../lib/header.c:1506 msgid "] expected at end of array" msgstr "" -#: ../lib/header.c:1502 +#: ../lib/header.c:1522 msgid "unexpected ]" msgstr "" -#: ../lib/header.c:1504 +#: ../lib/header.c:1524 msgid "unexpected }" msgstr "" -#: ../lib/header.c:1556 +#: ../lib/header.c:1576 msgid "? expected in expression" msgstr "" -#: ../lib/header.c:1563 +#: ../lib/header.c:1583 msgid "{ expected after ? in expression" msgstr "" -#: ../lib/header.c:1573 ../lib/header.c:1605 +#: ../lib/header.c:1593 ../lib/header.c:1625 msgid "} expected in expression" msgstr "" -#: ../lib/header.c:1580 +#: ../lib/header.c:1600 msgid ": expected following ? subexpression" msgstr "" -#: ../lib/header.c:1593 +#: ../lib/header.c:1613 msgid "{ expected after : in expression" msgstr "" -#: ../lib/header.c:1612 +#: ../lib/header.c:1632 msgid "| expected at end of expression" msgstr "" -#: ../lib/header.c:1779 +#: ../lib/header.c:1799 msgid "(unknown type)" msgstr "" -- 2.7.4