diff options
author | Chip Salzenberg <chip@atlantic.net> | 1996-12-31 10:57:15 +1200 |
---|---|---|
committer | Chip Salzenberg <chip@atlantic.net> | 1997-01-01 08:59:00 +1200 |
commit | 02b32252cb5781c70cbc96b7697e4796f3e60cd9 (patch) | |
tree | 4c5daae113868e0d9f9c9d1cdea37278fd04eeb1 /util.c | |
parent | 77676ba1ca148a47a08648896b0af31d1f464a3d (diff) | |
download | perl-02b32252cb5781c70cbc96b7697e4796f3e60cd9.tar.gz |
Ultrix setlocale() workaround
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 52 |
1 files changed, 44 insertions, 8 deletions
@@ -548,24 +548,60 @@ perl_init_i18nl10n(printwarn) #ifdef USE_LOCALE -#ifdef LC_ALL - char *lc_all = getenv("LC_ALL"); -#endif /* LC_ALL */ #ifdef USE_LOCALE_CTYPE - char *lc_ctype = getenv("LC_CTYPE"); char *curctype = NULL; #endif /* USE_LOCALE_CTYPE */ #ifdef USE_LOCALE_COLLATE - char *lc_collate = getenv("LC_COLLATE"); char *curcoll = NULL; #endif /* USE_LOCALE_COLLATE */ #ifdef USE_LOCALE_NUMERIC - char *lc_numeric = getenv("LC_NUMERIC"); char *curnum = NULL; #endif /* USE_LOCALE_NUMERIC */ + char *lc_all = getenv("LC_ALL"); char *lang = getenv("LANG"); bool setlocale_failure = FALSE; +#ifdef LOCALE_ENVIRON_REQUIRED + + /* + * Ultrix setlocale(..., "") fails if there are no environment + * variables from which to get a locale name. + */ + + bool done = FALSE; + +#ifdef LC_ALL + if (lang) { + if (setlocale(LC_ALL, "")) + done = TRUE; + else + setlocale_failure = TRUE; + } + if (!setlocale_failure) +#endif /* LC_ALL */ + { +#ifdef USE_LOCALE_CTYPE + if (! (curctype = setlocale(LC_CTYPE, + (!done && (lang || getenv("LC_CTYPE"))) + ? "" : Nullch))) + setlocale_failure = TRUE; +#endif /* USE_LOCALE_CTYPE */ +#ifdef USE_LOCALE_COLLATE + if (! (curcoll = setlocale(LC_COLLATE, + (!done && (lang || getenv("LC_COLLATE"))) + ? "" : Nullch))) + setlocale_failure = TRUE; +#endif /* USE_LOCALE_COLLATE */ +#ifdef USE_LOCALE_NUMERIC + if (! (curnum = setlocale(LC_NUMERIC, + (!done && (lang || getenv("LC_NUMERIC"))) + ? "" : Nullch))) + setlocale_failure = TRUE; +#endif /* USE_LOCALE_NUMERIC */ + } + +#else /* !LOCALE_ENVIRON_REQUIRED */ + #ifdef LC_ALL if (! setlocale(LC_ALL, "")) @@ -599,6 +635,8 @@ perl_init_i18nl10n(printwarn) #endif /* LC_ALL */ +#endif /* !LOCALE_ENVIRON_REQUIRED */ + if (setlocale_failure) { char *p; bool locwarn = (printwarn > 1 || @@ -634,13 +672,11 @@ perl_init_i18nl10n(printwarn) PerlIO_printf(PerlIO_stderr(), "perl: warning: Please check that your locale settings:\n"); -#ifdef LC_ALL PerlIO_printf(PerlIO_stderr(), "\tLC_ALL = %c%s%c,\n", lc_all ? '"' : '(', lc_all ? lc_all : "unset", lc_all ? '"' : ')'); -#endif /* LC_ALL */ { char **e; |