From: Bruno Haible Date: Sun, 9 Mar 2008 14:12:10 +0000 (+0000) Subject: Fix compiler output to be in the user locale. X-Git-Tag: v2.2.2~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=294465722d1c040bf3bb12343aec6a0e4568e3ea;p=thirdparty%2Flibtool.git 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. --- diff --git a/ChangeLog b/ChangeLog index f3196220d..d27a02c0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-03-09 Bruno Haible + and Ralf Wildenhues + + 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 Fix several test failures on Cygwin and MinGW. diff --git a/Makefile.am b/Makefile.am index 6e7c802c2..0168a4171 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/libltdl/config/general.m4sh b/libltdl/config/general.m4sh index 880748e99..71a20d28a 100644 --- a/libltdl/config/general.m4sh +++ b/libltdl/config/general.m4sh @@ -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 +} ]]) diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index 13b221d08..ade8b4505 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -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 && diff --git a/tests/localization.at b/tests/localization.at new file mode 100644 index 000000000..195e20c28 --- /dev/null +++ b/tests/localization.at @@ -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