summaryrefslogtreecommitdiff
path: root/libc/misc
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-12-20 16:08:45 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-12-20 16:08:45 +0000
commit0e674ab3af45934ba107931b67a01e193f9233ca (patch)
tree1a3e87575d59206922cadbb8347afe1c82d8c76e /libc/misc
parent3fa5621448d11fbe8ad3bbb80e3daa7cb9c943f9 (diff)
libc/misc/locale/locale.c: remove one unneeded static data,
rewrite one exceptionally unreadable loop. Heed a few warnings (wrong type for string op params) text data bss dec hex filename - 1164 16 0 1180 49c libc/misc/locale/newlocale.os + 1180 0 0 1180 49c libc/misc/locale/newlocale.os - 494480 2751 15684 512915 7d393 lib/libuClibc-0.9.30-svn.so + 494472 2735 15684 512891 7d37b lib/libuClibc-0.9.30-svn.so
Diffstat (limited to 'libc/misc')
-rw-r--r--libc/misc/locale/locale.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c
index 71bd77951..29a80fab0 100644
--- a/libc/misc/locale/locale.c
+++ b/libc/misc/locale/locale.c
@@ -230,7 +230,8 @@ static void update_hr_locale(const unsigned char *spec)
+ __LOCALE_DATA_WIDTH_LOCALES * ((((int)(*s & 0x7f)) << 7)
+ (s[1] & 0x7f));
if (category == LC_ALL) {
- n = stpcpy(n, CATEGORY_NAMES + (int) CATEGORY_NAMES[i]);
+ /* CATEGORY_NAMES is unsigned char* */
+ n = stpcpy(n, (char*) CATEGORY_NAMES + (int) CATEGORY_NAMES[i]);
*n++ = '=';
}
if (*loc == 0) {
@@ -1217,7 +1218,8 @@ static unsigned char *composite_locale(int category_mask, const char *locale,
t = strtok_r(buf, "=", &e); /* This can't fail because of strchr test above. */
do {
c = 0;
- while (strcmp(CATEGORY_NAMES + (int) CATEGORY_NAMES[c], t)) {
+ /* CATEGORY_NAMES is unsigned char* */
+ while (strcmp((char*) CATEGORY_NAMES + (int) CATEGORY_NAMES[c], t)) {
if (++c == LC_ALL) { /* Unknown category name! */
return NULL;
}
@@ -1262,11 +1264,13 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
strcpy((char *) new_selector,
(base ? (char *) base->cur_locale : C_LOCALE_SELECTOR));
- if (!*locale) { /* locale == "", so check environment. */
-#ifndef __UCLIBC_HAS_THREADS__
- static /* If no threads, then envstr can be static. */
-#endif /* __UCLIBC_HAS_THREADS__ */
- const char *envstr[4] = { "LC_ALL", NULL, "LANG", posix };
+ if (!locale[0]) { /* locale == "", so check environment. */
+ const char *envstr[4];
+
+ envstr[0] = "LC_ALL";
+ envstr[1] = NULL;
+ envstr[2] = "LANG";
+ envstr[3] = posix;
i = 1;
k = 0;
@@ -1275,12 +1279,16 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
/* Note: SUSv3 doesn't define a fallback mechanism here.
* So, if LC_ALL is invalid, we do _not_ continue trying
* the other environment vars. */
- envstr[1] = CATEGORY_NAMES + CATEGORY_NAMES[k];
+ envstr[1] = (char*) CATEGORY_NAMES + CATEGORY_NAMES[k];
j = 0;
- do {
+ while (1) {
p = envstr[j];
- } while ((++j < 4) && (!(p = getenv(p)) || !*p));
-
+ if (++j >= 4)
+ break; /* now p == "POSIX" */
+ p = getenv(p);
+ if (p && p[0])
+ break;
+ };
/* The user set something... is it valid? */
/* Note: Since we don't support user-supplied locales and