[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Autoconf proposed fix for "NLS nuisances" POSIX non-conformance
From: |
Paul Eggert |
Subject: |
Autoconf proposed fix for "NLS nuisances" POSIX non-conformance |
Date: |
Wed, 31 Oct 2001 14:36:13 -0800 (PST) |
Autoconf generates "configure" scripts that do the following:
# NLS nuisances.
$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; }
$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL;
}
...
Unfortunately, this does not necessarily have the desired effect on
POSIX platforms. POSIX says that if none of the LANG or LC_*
environment variables are set, then the locale is
implementation-defined. I think most implementations default to 'C',
which is what is wanted here, but this is not required by POSIX.
Here's the ChangeLog entry that talks about why Autoconf does it the way
that it does:
Thu Jun 24 15:58:04 1993 Noah Friedman (address@hidden)
* autoconf.sh, autoheader.sh, acgeneral.m4 (AC_PREPARE): Undo
change of Jun 16 1993. Only set `LANG' and `LC_ALL' to "C" if
already set.
I vaguely recall that the problem is that some older (pre-POSIX)
shells reject "LC_ALL='C'", because they don't have a C locale.
I propose that we fix the problem by using the following technique:
test -n "`(LANG=C; export LANG) 2>&1`" &&
{ $as_unset LANG || test "${LANG+set}" != set; } ||
{ LANG=C; export LANG; }
This will cause LANG to be set to C on POSIX platforms, as POSIX
requires for maximum portability, while retaining the 1993 workaround
for older platforms.
Here is a proposed patch to do this.
This patch also fixes a related portability problem: "configure" must
fix NLS before invoking AS_BASENAME, since AS_BASENAME can use negated
character classes and these have implementation-defined behavior
outside the C locale.
2001-10-31 Paul Eggert <address@hidden>
* lib/m4sugar/m4sh.m4 (AS_SHELL_SANITIZE): Fix NLS before
invoking AS_BASENAME. Set the locale variables to 'C' if
possible, as POSIX requires this to get the traditional
behavior.
--- m4sh.m4-old Wed Oct 31 12:51:14 2001
+++ m4sh.m4 Wed Oct 31 13:23:09 2001
@@ -151,6 +151,16 @@ elif test -n "${BASH_VERSION+set}" && (s
set -o posix
fi
+# NLS nuisances.
+_AS_UNSET_PREPARE
+m4_foreach([_AS_var],
+ [LANG, LC_ALL, LC_TIME, LC_CTYPE, LANGUAGE,
+ LC_COLLATE, LC_NUMERIC, LC_MESSAGES],
+ [(set +x; test -n "`(_AS_var=C; export _AS_var) 2>&1`") &&
+ { $as_unset _AS_var || test "${_AS_var+set}" != set; } ||
+ { _AS_var=C; export _AS_var; }
+])
+
# Name of the executable.
as_me=`AS_BASENAME("$[0]")`
@@ -165,17 +175,6 @@ _AS_LN_S_PREPARE
_AS_TEST_PREPARE
_AS_TR_CPP_PREPARE
_AS_TR_SH_PREPARE
-_AS_UNSET_PREPARE
-
-# NLS nuisances.
-AS_UNSET([LANG], [C])
-AS_UNSET([LC_ALL], [C])
-AS_UNSET([LC_TIME], [C])
-AS_UNSET([LC_CTYPE], [C])
-AS_UNSET([LANGUAGE], [C])
-AS_UNSET([LC_COLLATE], [C])
-AS_UNSET([LC_NUMERIC], [C])
-AS_UNSET([LC_MESSAGES], [C])
# IFS
# We need space, tab and new line, in precisely that order.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Autoconf proposed fix for "NLS nuisances" POSIX non-conformance,
Paul Eggert <=