summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChip Salzenberg <chip@atlantic.net>1996-12-31 10:57:15 +1200
committerChip Salzenberg <chip@atlantic.net>1997-01-01 08:59:00 +1200
commit02b32252cb5781c70cbc96b7697e4796f3e60cd9 (patch)
tree4c5daae113868e0d9f9c9d1cdea37278fd04eeb1
parent77676ba1ca148a47a08648896b0af31d1f464a3d (diff)
downloadperl-02b32252cb5781c70cbc96b7697e4796f3e60cd9.tar.gz
Ultrix setlocale() workaround
-rw-r--r--hints/ultrix_4.sh3
-rw-r--r--util.c52
2 files changed, 47 insertions, 8 deletions
diff --git a/hints/ultrix_4.sh b/hints/ultrix_4.sh
index 76b0768f8d..826cb34c19 100644
--- a/hints/ultrix_4.sh
+++ b/hints/ultrix_4.sh
@@ -50,4 +50,7 @@ case "$osvers" in
*) ranlib='ranlib' ;;
esac
+# Settings that don't depend on $osvers:
+
+util_cflags='ccflags="$ccflags -DLOCALE_ENVIRON_REQUIRED"'
groupstype='int'
diff --git a/util.c b/util.c
index 84c55730df..99c6f416d4 100644
--- a/util.c
+++ b/util.c
@@ -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;