return 1;
}
+static int headerMatchLocale(const char *td, const char *l, const char *le)
+{
+ const char *fe;
+
+ /*
+ * The range [l,le) 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.
+ */
+
+ /* First try a complete match. */
+ if (!strncmp(td, l, (le - l)))
+ return 1;
+
+ /* Next, try stripping optional dialect and matching. */
+ for (fe = l; fe < le && *fe != '@'; fe++)
+ ;
+ if (fe < le && !strncmp(td, l, (fe - l)))
+ return 1;
+
+ /* Next, try stripping optional codeset and matching. */
+ for (fe = l; fe < le && *fe != '.'; fe++)
+ ;
+ if (fe < le && !strncmp(td, l, (fe - l)))
+ return 1;
+
+ /* Finally, try stripping optional country code and matching. */
+ for (fe = l; fe < le && *fe != '_'; fe++)
+ ;
+ if (fe < le && !strncmp(td, l, (fe - l)))
+ return 1;
+
+ return 0;
+}
+
static char *headerFindI18NString(Header h, struct indexEntry *entry)
{
const char *lang, *l, *le;
return entry->data;
for (l = lang; *l; l = le) {
- const char *td, *fe;
+ const char *td;
char *ed;
- int count;
+ int langNum;
while (*l && *l == ':') /* skip leading colons */
l++;
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;
+ for (langNum = 0, td = table->data, ed = entry->data;
+ langNum < entry->info.count;
+ langNum++, td += strlen(td) + 1, ed += strlen(ed) + 1) {
+
+ if (headerMatchLocale(td, l, le))
+ return ed;
+
}
}
return entry->data;
}
+void headerSetLangPath(Header h, const char * lang)
+{
+ const char *l, *le;
+ struct indexEntry * table;
+
+ if (lang == NULL ||
+ (table = findEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE)) == NULL) {
+ h->langNum = -1;
+ return;
+ }
+
+ for (l = lang; *l; l = le) {
+ const char *td;
+ int langNum;
+
+ while (*l && *l == ':') /* skip leading colons */
+ l++;
+ if (*l == '\0')
+ break;
+ for (le = l; *le && *le != ':'; le++) /* find end of this locale */
+ ;
+
+ for (langNum = 0, td = table->data;
+ langNum < table->info.count;
+ langNum++, td += strlen(td) + 1) {
+
+ if (headerMatchLocale(td, l, le)) {
+ h->langNum = langNum;
+ return;
+ }
+
+ }
+ }
+
+ h->langNum = -1;
+}
+
+void headerResetLang(Header h)
+{
+ const char * str;
+
+ if ((str = getenv("LANGUAGE"))) {
+ headerSetLangPath(h, str);
+ return;
+ }
+
+ headerSetLangPath(h, getenv("LANG"));
+}
+
static int intGetEntry(Header h, int_32 tag, int_32 *type, void **p, int_32 *c,
int minMem)
{
{ HEADER_EXT_LAST, NULL, { NULL } }
};
-void headerSetLangPath(Header h, char * lang) {
- char * buf, * chptr, * start, * next;
- struct indexEntry * table;
- int langNum;
-
- table = findEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE);
-
- if (!lang || !table) {
- h->langNum = -1;
- return;
- }
-
- buf = alloca(strlen(lang) + 1);
- strcpy(buf, lang);
-
- start = buf;
- while (start) {
- chptr = strchr(start, ':');
- if (chptr) *chptr = '\0';
-
- next = table->data;
- for (langNum = 0; langNum < table->info.count; langNum++) {
- if (!strcmp(next, start)) break;
- next += strlen(next) + 1;
- }
-
- if (langNum < table->info.count) {
- h->langNum = langNum;
- break;
- }
-
- if (chptr)
- start = chptr + 1;
- else
- start = NULL;
- }
-
- if (!start)
- h->langNum = -1;
-}
-
-void headerResetLang(Header h) {
- char * str;
-
- if ((str = getenv("LANGUAGE"))) {
- headerSetLangPath(h, str);
- return;
- }
-
- headerSetLangPath(h, getenv("LANG"));
-}
-
void headerCopyTags(Header headerFrom, Header headerTo, int *tagstocopy)
{
int *p;
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1999-08-19 15:21-0400\n"
+"POT-Creation-Date: 1999-08-20 13:48-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgstr ""
#: ../lib/formats.c:65 ../lib/formats.c:83 ../lib/formats.c:104
-#: ../lib/formats.c:137 ../lib/header.c:2015 ../lib/header.c:2032
-#: ../lib/header.c:2052
+#: ../lib/formats.c:137 ../lib/header.c:2076 ../lib/header.c:2093
+#: ../lib/header.c:2113
msgid "(not a number)"
msgstr ""
msgid "Data type %d not supprted\n"
msgstr ""
-#: ../lib/header.c:1015
+#: ../lib/header.c:1076
#, c-format
msgid "Bad count for headerAddEntry(): %d\n"
msgstr ""
-#: ../lib/header.c:1415
+#: ../lib/header.c:1476
#, c-format
msgid "missing { after %"
msgstr ""
-#: ../lib/header.c:1443
+#: ../lib/header.c:1504
msgid "missing } after %{"
msgstr ""
-#: ../lib/header.c:1455
+#: ../lib/header.c:1516
msgid "empty tag format"
msgstr ""
-#: ../lib/header.c:1465
+#: ../lib/header.c:1526
msgid "empty tag name"
msgstr ""
-#: ../lib/header.c:1480
+#: ../lib/header.c:1541
msgid "unknown tag"
msgstr ""
-#: ../lib/header.c:1506
+#: ../lib/header.c:1567
msgid "] expected at end of array"
msgstr ""
-#: ../lib/header.c:1522
+#: ../lib/header.c:1583
msgid "unexpected ]"
msgstr ""
-#: ../lib/header.c:1524
+#: ../lib/header.c:1585
msgid "unexpected }"
msgstr ""
-#: ../lib/header.c:1576
+#: ../lib/header.c:1637
msgid "? expected in expression"
msgstr ""
-#: ../lib/header.c:1583
+#: ../lib/header.c:1644
msgid "{ expected after ? in expression"
msgstr ""
-#: ../lib/header.c:1593 ../lib/header.c:1625
+#: ../lib/header.c:1654 ../lib/header.c:1686
msgid "} expected in expression"
msgstr ""
-#: ../lib/header.c:1600
+#: ../lib/header.c:1661
msgid ": expected following ? subexpression"
msgstr ""
-#: ../lib/header.c:1613
+#: ../lib/header.c:1674
msgid "{ expected after : in expression"
msgstr ""
-#: ../lib/header.c:1632
+#: ../lib/header.c:1693
msgid "| expected at end of expression"
msgstr ""
-#: ../lib/header.c:1799
+#: ../lib/header.c:1860
msgid "(unknown type)"
msgstr ""