libtool-patches
[Top][All Lists]
Advanced

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

Re: executable wrapper on mingw mangles arguments


From: Ralf Wildenhues
Subject: Re: executable wrapper on mingw mangles arguments
Date: Mon, 10 Nov 2008 22:16:09 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

Hello Bruno, Charles,

apologies for the long delay.

* Bruno Haible wrote on Sat, Oct 11, 2008 at 02:38:31AM CEST:
> > +for arg in \
> > +   'def ghi' \
> > +   'd"e' 'f"g' \
> > +   'd\"e' 'f\"g' \
[...]
> Well, I meant these as pairs of arguments. When you pass just one argument
> 
>     d"e
> 
> to spawnvpe, CreateProcess does less damage than when you pass two arguments
> 
>     d"e f"g

Ah, ok.

> Btw, if you need to do more tests performed, you can give me tarballs that
> I can try. I now have access again to a Windows machine for testing.

Thanks.  Here's an updated patch, to be squashed onto yours.
Please test whether it exposes the bugs, and whether the test
passes with your fix applied.

If you prefer a tarball for testing, then I can also just push the
combined patch and you can use the nightly build from the Libtool
web page.

Thanks,
Ralf

        * tests/execute-mode.at (execute mode): Output args
        newline-separated.  Extend tests by more argument pairs that
        contain special characters, where the w32 cwrapper fails.
        Also test a real compiled program, linked against an uninstalled
        library, to expose cwrapper issues.
        * NEWS: Update.

diff --git a/NEWS b/NEWS
index 4945c51..a38bfb3 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ New in 2.2.8 2008-??-??: git version 2.2.7a, Libtool team:
 
   - Fix 2.2.6 regression that prevented using the libltdl macros together
     with Autoconf 2.59 (`possibly undefined macro: LT_LIBEXT').
+  - Fix 2.2.4 regression that caused arguments with special characters
+    to be mangled by the compile wrapper for uninstalled programs on MinGW.
 
 * Miscellaneous changes:
 
diff --git a/tests/execute-mode.at b/tests/execute-mode.at
index 349c829..acbe081 100644
--- a/tests/execute-mode.at
+++ b/tests/execute-mode.at
@@ -25,10 +25,15 @@
 AT_SETUP([execute mode])
 AT_KEYWORDS([libtool])
 
+eval `$LIBTOOL --config | $EGREP '^(FGREP)='`
+
 AT_DATA([foo],
 [[#! /bin/sh
 if test $# -gt 0; then
-  echo "$@"
+  for arg
+  do
+    printf %s\\n "$arg"
+  done
 else
   :
 fi
@@ -50,7 +55,10 @@ fi
 
 AT_DATA([lt-real],
 [[#! /bin/sh
-echo "$@"
+for arg
+do
+  printf %s\\n "$arg"
+done
 cat
 ]])
 
@@ -81,6 +89,45 @@ mkdir sub
 cp foo sub/foo
 chmod +x foo sub/foo lt-wrapper lt-real
 
+AT_DATA([liba.c],
+[[int a () { return 0; }
+]])
+
+AT_DATA([main.c],
+[[#include <stdio.h>
+extern int a ();
+int main (int argc, char **argv)
+{
+  int i;
+  for (i=1; i<argc; ++i)
+    {
+      if (i != 1)
+       fputc ('\n', stdout);
+      fputs (argv[i], stdout);
+    }
+  fputc ('\n', stdout);
+  return a ();
+}
+]])
+
+instdir=`pwd`/inst
+libdir=$instdir/lib
+
+AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c liba.c],
+        [], [ignore], [ignore])
+AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la -rpath $libdir 
liba.lo],
+        [], [ignore], [ignore])
+AT_CHECK([$CC $CPPFLAGS $CFLAGS -c main.c],
+        [], [ignore], [ignore])
+AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main main.$OBJEXT 
liba.la],
+        [], [ignore], [ignore])
+
+# end of preparatory blurb.
+# Now, when doing the tests, we both try the fake wrappers plus the real one
+# (only the latter exposes the C wrappers used for w32 systems).
+# With the latter, however, we need to ignore additional output; esp. wine
+# may be rather noisy.
+
 AT_CHECK([$LIBTOOL --mode=execute ./foo])
 AT_CHECK([$LIBTOOL --mode=execute sub/foo])
 AT_CHECK([$LIBTOOL --mode=execute ./foo foo], [], [foo
@@ -91,7 +138,9 @@ AT_CHECK([cd sub && $LIBTOOL --mode=execute ./foo ../foo], 
[], [../foo
 ])
 # suppose that ./foo is gdb, and lt-wrapper is the wrapper script.
 AT_CHECK([$LIBTOOL --mode=execute ./foo lt-wrapper bar baz </dev/null], [],
-        [./lt-real bar baz
+        [./lt-real
+bar
+baz
 ])
 
 # check that stdin works even with -dlopen.
@@ -116,7 +165,41 @@ AT_CHECK([$LIBTOOL --mode=execute ./lt-wrapper "arg  with 
special chars: \$!&*\`
         [], [arg  with special chars: $!&*`'()
 ])
 AT_CHECK([$LIBTOOL --mode=execute ./foo lt-wrapper "arg  with special chars: 
\$!&*\`'()"],
-        [], [./lt-real arg  with special chars: $!&*`'()
+        [], [./lt-real
+arg  with special chars: $!&*`'()
 ])
 
+# We always pair two args.  The first one is never the empty string.
+arg1=
+for arg2 in \
+   'def ghi' '' \
+   'd"e' 'f"g' \
+   'd\"e' 'f\"g' \
+   'd\\"e' 'f\\"g' \
+   'd\\\"e' 'f\\\"g' \
+   'd\' '' \
+   'd\\' '' \
+   'd\\\' '' \
+   'd\\\\' '' \
+   '<' '>' \
+   '<def>' ''
+do
+  if test -z "$arg1"; then
+    arg1=$arg2; continue
+  fi
+  AT_CHECK([$LIBTOOL --mode=execute ./foo abc "$arg1" "$arg2" xyz], [], 
[stdout])
+  AT_CHECK([$FGREP "$arg1" stdout], [], [ignore])
+  AT_CHECK([$FGREP "$arg2" stdout], [], [ignore])
+  AT_CHECK([test `sed -n '/^abc$/,/^xyz$/p' stdout | wc -l` -eq 4])
+  AT_CHECK([$LIBTOOL --mode=execute ./lt-wrapper abc "$arg1" "$arg2" xyz 
</dev/null], [], [stdout])
+  AT_CHECK([$FGREP "$arg1" stdout], [], [ignore])
+  AT_CHECK([$FGREP "$arg2" stdout], [], [ignore])
+  AT_CHECK([test `sed -n '/^abc$/,/^xyz$/p' stdout | wc -l` -eq 4])
+  AT_CHECK([$LIBTOOL --mode=execute ./foo lt-wrapper abc "$arg1" "$arg2" xyz], 
[], [stdout])
+  AT_CHECK([$FGREP "$arg1" stdout], [], [ignore])
+  AT_CHECK([$FGREP "$arg2" stdout], [], [ignore])
+  AT_CHECK([test `sed -n '/^abc$/,/^xyz$/p' stdout | wc -l` -eq 4])
+  arg1=
+done
+
 AT_CLEANUP




reply via email to

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