diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 1997-02-06 09:11:06 +0000 |
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 1997-02-06 09:11:06 +0000 |
| commit | 63407d3487909d41524a1ae94e60b2fcec7e5c27 (patch) | |
| tree | 884ff88fa55071e0b114b7047342a5e92e455a11 /lib/libc/locale/setlocale.c | |
| parent | b6b0d266cd69d2d8bc8fbce4cb27e3dd764baeac (diff) | |
Notes
Diffstat (limited to 'lib/libc/locale/setlocale.c')
| -rw-r--r-- | lib/libc/locale/setlocale.c | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/lib/libc/locale/setlocale.c b/lib/libc/locale/setlocale.c index 686e36dc0e16..656ed85663f8 100644 --- a/lib/libc/locale/setlocale.c +++ b/lib/libc/locale/setlocale.c @@ -54,6 +54,7 @@ static char sccsid[] = "@(#)setlocale.c 8.1 (Berkeley) 7/4/93"; #include <string.h> #include <unistd.h> #include "collate.h" +#include "setlocale.h" /* * Category names for getenv() @@ -70,7 +71,7 @@ static char *categories[_LC_LAST] = { /* * Current locales for each category */ -static char current_categories[_LC_LAST][32] = { +static char current_categories[_LC_LAST][ENCODING_LEN + 1] = { "C", "C", "C", @@ -82,11 +83,10 @@ static char current_categories[_LC_LAST][32] = { /* * The locales we are going to try and load */ -static char new_categories[_LC_LAST][32]; -static char saved_categories[_LC_LAST][32]; +static char new_categories[_LC_LAST][ENCODING_LEN + 1]; +static char saved_categories[_LC_LAST][ENCODING_LEN + 1]; -static char current_locale_string[_LC_LAST * 33]; -char *_PathLocale; +static char current_locale_string[_LC_LAST * (ENCODING_LEN + 1/*"/"*/ + 1)]; static char *currentlocale __P((void)); static char *loadlocale __P((int)); @@ -134,33 +134,34 @@ setlocale(category, locale) if (!env || !*env) env = "C"; - (void) strncpy(new_categories[category], env, 31); - new_categories[category][31] = 0; + (void) strncpy(new_categories[category], env, ENCODING_LEN); + new_categories[category][ENCODING_LEN] = '\0'; if (category == LC_ALL) { for (i = 1; i < _LC_LAST; ++i) { if (!(env = getenv(categories[i])) || !*env) env = new_categories[LC_ALL]; - (void)strncpy(new_categories[i], env, 31); - new_categories[i][31] = 0; + (void)strncpy(new_categories[i], env, ENCODING_LEN); + new_categories[i][ENCODING_LEN] = '\0'; } } } else if (category != LC_ALL) { - (void)strncpy(new_categories[category], locale, 31); - new_categories[category][31] = 0; + (void)strncpy(new_categories[category], locale, ENCODING_LEN); + new_categories[category][ENCODING_LEN] = '\0'; } else { - if ((r = strchr(locale, '/')) == 0) { + if ((r = strchr(locale, '/')) == NULL) { for (i = 1; i < _LC_LAST; ++i) { - (void)strncpy(new_categories[i], locale, 31); - new_categories[i][31] = 0; + (void)strncpy(new_categories[i], locale, ENCODING_LEN); + new_categories[i][ENCODING_LEN] = '\0'; } } else { for (i = 1; r[1] == '/'; ++r); if (!r[1]) return (NULL); /* Hmm, just slashes... */ do { - len = r - locale > 31 ? 31 : r - locale; + len = r - locale > ENCODING_LEN ? ENCODING_LEN : r - locale; (void)strncpy(new_categories[i], locale, len); - new_categories[i++][len] = 0; + new_categories[i][len] = '\0'; + i++; locale = r; while (*locale == '/') ++locale; @@ -190,17 +191,6 @@ setlocale(category, locale) return (currentlocale()); } -/* To be compatible with crt0 hack */ -void -_startup_setlocale(category, locale) - int category; - const char *locale; -{ -#ifndef XPG4 - (void) setlocale(category, locale); -#endif -} - static char * currentlocale() { |
