diff options
author | marc <devnull@localhost> | 1998-06-02 21:34:51 +0000 |
---|---|---|
committer | marc <devnull@localhost> | 1998-06-02 21:34:51 +0000 |
commit | a8975d188ea58fee841b4da0ec38140e786ce89d (patch) | |
tree | 3cd5ae26e43a1eda8c3ec6ae5dc32ba288dd9d19 | |
parent | 5373b67cf1d99d7746fc630a5fd9d5b2f7a87b89 (diff) | |
download | librpm-tizen-a8975d188ea58fee841b4da0ec38140e786ce89d.tar.gz librpm-tizen-a8975d188ea58fee841b4da0ec38140e786ce89d.tar.bz2 librpm-tizen-a8975d188ea58fee841b4da0ec38140e786ce89d.zip |
- fixed ugly i18n header bug
- deal with lang paths sanely when entries are missing languages
CVS patchset: 2142
CVS date: 1998/06/02 21:34:51
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | lib/header.c | 57 |
2 files changed, 52 insertions, 7 deletions
@@ -4,6 +4,8 @@ - copy CHANGELOG* and URL tags to all subpackages - follow symlinks when packaging sources - handle %files -f with no %setup (no build directory) + - fixed ugly i18n header bug + - deal with lang paths sanely when entries are missing languages 2.5 -> 2.5.1: - fail if sources are not regular files diff --git a/lib/header.c b/lib/header.c index 73828c021..1e1832d70 100644 --- a/lib/header.c +++ b/lib/header.c @@ -151,6 +151,7 @@ static char * shescapeFormat(int_32 type, const void * data, static int getExtension(Header h, headerTagTagFunction fn, int_32 * typeptr, void ** data, int_32 * countptr, struct extensionCache * ext); +char *headerFindI18NString(Header h, struct indexEntry *entry); const struct headerSprintfExtension headerDefaultFormats[] = { { HEADER_EXT_FORMAT, "octal", { octalFormat } }, @@ -795,15 +796,11 @@ int headerGetEntry(Header h, int_32 tag, int_32 * type, void **p, int_32 * c) } if (entry->info.type == RPM_I18NSTRING_TYPE) { - if (h->langNum == -1) headerResetLang(h); + chptr = headerFindI18NString(h, entry); if (type) *type = RPM_STRING_TYPE; if (c) *c = 1; - chptr = entry->data; - for (i = 0; i < h->langNum; i++) - chptr += strlen(chptr) + 1; - *p = chptr; } else { copyEntry(entry, type, p, c); @@ -1077,8 +1074,9 @@ int headerAddI18NString(Header h, int_32 tag, char * string, char * lang) { memcpy(buf, entry->data, length); strcpy(buf + length, string); i = strlen(chptr + length) + 1; - memcpy(buf + strlen(string) + 1, ((char *) entry->data) + length + i, - entry->length - length - i); + memcpy(buf + length + strlen(string) + 1, + ((char *) entry->data) + length + i, + entry->length - length - i); free(entry->data); entry->data = buf; @@ -2047,3 +2045,48 @@ void headerResetLang(Header h) { headerSetLangPath(h, getenv("LANG")); } + +char *headerFindI18NString(Header h, struct indexEntry *entry) +{ + char * lang, * buf, * chptr, * start, * next, * resptr; + struct indexEntry * table; + int langNum; + + if (! (lang = getenv("LANGUAGE"))) { + lang = getenv("LANG"); + } + + table = findEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE); + + if (!lang || !table) { + return entry->data; + } + + buf = alloca(strlen(lang) + 1); + strcpy(buf, lang); + + 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; + } + + if (chptr) + start = chptr + 1; + else + start = NULL; + } + + return entry->data; +} |