Fix compiler output to be in the user locale.

* libltdl/config/general.m4sh (func_show_eval_locale): New
function, for running commands in the user locale.
* libltdl/config/ltmain.m4sh (func_mode_compile): Use it for
compiling.
* tests/localization.at (localized compiler messages): New test.
* Makefile.am: Adjust.
Report by Bruno Haible.
This commit is contained in:
Bruno Haible 2008-03-09 14:12:10 +00:00 committed by Ralf Wildenhues
parent 1b8b9e3e5e
commit 294465722d
5 changed files with 93 additions and 3 deletions

View File

@ -1,3 +1,15 @@
2008-03-09 Bruno Haible <bruno@clisp.org>
and Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Fix compiler output to be in the user locale.
* libltdl/config/general.m4sh (func_show_eval_locale): New
function, for running commands in the user locale.
* libltdl/config/ltmain.m4sh (func_mode_compile): Use it for
compiling.
* tests/localization.at (localized compiler messages): New test.
* Makefile.am: Adjust.
Report by Bruno Haible.
2008-03-08 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Fix several test failures on Cygwin and MinGW.

View File

@ -448,6 +448,7 @@ TESTSUITE_AT = tests/testsuite.at \
tests/indirect_deps.at \
tests/archive-in-archive.at \
tests/execute-mode.at \
tests/localization.at \
tests/destdir.at \
tests/old-m4-iface.at \
tests/am-subdir.at \

View File

@ -1,6 +1,6 @@
m4_if([general.m4sh -- general shell script boiler plate -*- Autoconf -*-
Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
Written by Gary V. Vaughan, 2004
This file is part of GNU Cvs-utils.
@ -344,5 +344,31 @@ func_show_eval ()
fi
fi
}
# func_show_eval_locale cmd [fail_exp]
# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
# is given, then evaluate it. Use the saved locale for evaluation.
func_show_eval_locale ()
{
my_cmd="$1"
my_fail_exp="${2-:}"
${opt_silent-false} || {
func_quote_for_expand "$my_cmd"
eval "func_echo $func_quote_for_expand_result"
}
if ${opt_dry_run-false}; then :; else
eval "$lt_user_locale
$my_cmd"
my_status=$?
eval "$lt_safe_locale"
if test "$my_status" -eq 0; then :; else
eval "(exit $my_status); $my_fail_exp"
fi
fi
}
]])

View File

@ -96,12 +96,16 @@ DUALCASE=1; export DUALCASE # for MKS sh
# Only set LANG and LC_ALL to C if already set.
# These must not be set unconditionally because not all systems understand
# e.g. LANG=C (notably SCO).
lt_user_locale=
lt_safe_locale=
for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
do
eval "if test \"\${$lt_var+set}\" = set; then
save_$lt_var=\$$lt_var
$lt_var=C
export $lt_var
lt_user_locale=\"$lt_var=\$save_$lt_var; \$lt_user_locale\"
lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
fi"
done
@ -1515,7 +1519,7 @@ compiler."
$opt_dry_run || $RM "$lobj" "$output_obj"
func_show_eval "$command" \
func_show_eval_locale "$command" \
'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
if test "$need_locks" = warn &&
@ -1565,7 +1569,7 @@ compiler."
# Suppress compiler output if we already did a PIC compilation.
command="$command$suppress_output"
$opt_dry_run || $RM "$obj" "$output_obj"
func_show_eval "$command" \
func_show_eval_locale "$command" \
'$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
if test "$need_locks" = warn &&

47
tests/localization.at Normal file
View File

@ -0,0 +1,47 @@
# localization.at -- libtool and locales -*- Autotest -*-
#
# Copyright (C) 2008 Free Software Foundation, Inc.
# Written by Ralf Wildenhues, 2008
#
# This file is part of GNU Libtool.
#
# GNU Libtool is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# GNU Libtool is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Libtool; see the file COPYING. If not, a copy
# can be downloaded from http://www.gnu.org/licenses/gpl.html,
# or obtained by writing to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
####
AT_SETUP([localized compiler messages])
AT_KEYWORDS([libtool])
# Let's try German locale. :-)
LANG=de_DE
LANGUAGE=de_DE
LC_ALL=de_DE
export LANG LANGUAGE LC_ALL
AT_DATA([a.c],
[[int x[-1];
]])
AT_CHECK([$CC $CPPFLAGS $CFLAGS -c a.c || exit 1], [1], [stdout], [stderr])
mv -f stdout expected-stdout
mv -f stderr expected-stderr
AT_CHECK([$LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c a.c || exit 1],
[1], [stdout], [stderr])
AT_CHECK([diff expected-stderr stderr])
LTBASE=`$ECHO "$LIBTOOL" | sed 's,^.*/,,'`
AT_CHECK([grep -v "^$LTBASE: compile" stdout | diff expected-stdout -])
AT_CLEANUP