bug-libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libtool runs compiler command in wrong locale


From: Ralf Wildenhues
Subject: Re: libtool runs compiler command in wrong locale
Date: Thu, 6 Mar 2008 20:42:02 +0100
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

* Ralf Wildenhues wrote on Mon, Jan 21, 2008 at 08:18:26AM CET:
> * Bruno Haible wrote on Mon, Jan 21, 2008 at 12:46:12AM CET:
> [...]
> >       if ${opt_dry_run-false}; then :; else
> > +       eval "$lt_switch_to_user_locale"
> >         eval "$my_cmd"
> >         my_status=$?
> > +       eval "$lt_switch_to_safe_locale"
> >         if test "$my_status" -eq 0; then :; else
> [...]
> 
> > +     lt_switch_to_user_locale=\"$lt_var=\$save_$lt_var; 
> > \$lt_switch_to_user_locale\"
> > +     lt_switch_to_safe_locale=\"$lt_var=C; \$lt_switch_to_safe_locale\"
> 
> This approach has the advantage of not using an extra fork (as your
> branch-1-5 patch does), but it lacks re-exporting of the changed
> variables, which is needed by some older shells.

Playing on the rather safe side, I consider applying this patch for now.
OK?

I considered doing the same for link mode and some of the other stuff we
pipe through func_show_eval, but that should only be done after an audit
of the various *archive_cmds variables and settings in libtool.m4 to
ensure there are no grep patterns or so that would be influenced.

Thanks,
Ralf

2008-03-06  Bruno Haible  <address@hidden>
        and Ralf Wildenhues  <address@hidden>

        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.

Index: Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/Makefile.am,v
retrieving revision 1.230
diff -u -r1.230 Makefile.am
--- Makefile.am 4 Mar 2008 21:25:48 -0000       1.230
+++ Makefile.am 6 Mar 2008 19:36:08 -0000
@@ -448,6 +448,7 @@
                  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: libltdl/config/general.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/general.m4sh,v
retrieving revision 1.9
diff -u -r1.9 general.m4sh
--- libltdl/config/general.m4sh 10 May 2007 17:26:45 -0000      1.9
+++ libltdl/config/general.m4sh 6 Mar 2008 19:36:08 -0000
@@ -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 @@
       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: libltdl/config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.99
diff -u -r1.99 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  5 Mar 2008 20:14:43 -0000       1.99
+++ libltdl/config/ltmain.m4sh  6 Mar 2008 19:36:10 -0000
@@ -96,12 +96,16 @@
 # 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 @@
 
       $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 @@
       # 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 &&
--- /dev/null   2008-03-02 10:33:19.200041011 +0100
+++ tests/localization.at       2008-03-06 20:39:05.000000000 +0100
@@ -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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]