]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
Fix compiler output to be in the user locale.
authorBruno Haible <bruno@clisp.org>
Sun, 9 Mar 2008 14:12:10 +0000 (14:12 +0000)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 9 Mar 2008 14:12:10 +0000 (14:12 +0000)
* 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.

ChangeLog
Makefile.am
libltdl/config/general.m4sh
libltdl/config/ltmain.m4sh
tests/localization.at [new file with mode: 0644]

index f3196220db78dad7596b9df5ad8a029ffe842407..d27a02c0a24dd296ebcee5335298a41238540040 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index 6e7c802c29a1f5f8c2df12eaa1911c4f8c1c8a0d..0168a4171f8cb84174b99976554d32591228d55f 100644 (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 \
index 880748e995026ffdd6804a01369af0c13da72839..71a20d28a63f7b5f8e201d9b24afb6c5295fe055 100644 (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
+}
 ]])
 
index 13b221d0872a8fe6f4b0cd195f4e83a1bc030830..ade8b45059a7c777bda8aaf405991f2637e2724c 100644 (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 &&
diff --git a/tests/localization.at b/tests/localization.at
new file mode 100644 (file)
index 0000000..195e20c
--- /dev/null
@@ -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