]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
cwrapper: split long lines when dumping the wrapper script.
authorPeter Rosin <peda@lysator.liu.se>
Mon, 4 Oct 2010 19:16:26 +0000 (21:16 +0200)
committerPeter Rosin <peda@lysator.liu.se>
Mon, 4 Oct 2010 19:16:26 +0000 (21:16 +0200)
* libltdl/config/ltmain.m4sh (func_emit_cwrapperexe_src): If
the wrapper script contains long lines, split them for
readability and to conform with C standards.
* tests/cwrapper.at (cwrapper string length): New test, making
sure we don't regress.

Signed-off-by: Peter Rosin <peda@lysator.liu.se>
ChangeLog
libltdl/config/ltmain.m4sh
tests/cwrapper.at

index 4477414cc762e6f5f672fe49dcf7d08351184838..c0492fe841c82eb8d4e6f5064333a38365a7a608 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2010-10-04  Peter Rosin  <peda@lysator.liu.se>
 
+       cwrapper: split long lines when dumping the wrapper script.
+       * libltdl/config/ltmain.m4sh (func_emit_cwrapperexe_src): If
+       the wrapper script contains long lines, split them for
+       readability and to conform with C standards.
+       * tests/cwrapper.at (cwrapper string length): New test, making
+       sure we don't regress.
+
        msvc: handle symbols from different files independently.
        * libltdl/m4/libtool.m4 (_LT_CMD_GLOBAL_SYMBOLS)
        <dumpbin, lt_cv_sys_global_symbol_pipe>: Make all sections
index 041800744da6c0b8c8511ab358502a91e8efd4b6..1078e757b091951b5ca956ee63f5a7323798885e 100644 (file)
@@ -4268,9 +4268,15 @@ void lt_dump_script (FILE* f)
 {
 EOF
            func_emit_wrapper yes |
-              $SED -e 's/\([\\"]\)/\\\1/g' \
-                  -e 's/^/  fputs ("/' -e 's/$/\\n", f);/'
-
+             $SED -n -e '
+s/^\(.\{79\}\)\(..*\)/\1\
+\2/
+h
+s/\([\\"]\)/\\\1/g
+s/$/\\n/
+s/\([^\n]*\).*/  fputs ("\1", f);/p
+g
+D'
             cat <<"EOF"
 }
 EOF
index 248c0c0ad07f63c33fcd9e08343fb19b000f873f..cd618dcb77d36516fe2dbd0470677f8d1c54b0a1 100644 (file)
@@ -134,3 +134,64 @@ done
 
 AT_CLEANUP
 
+
+AT_SETUP([cwrapper string length])
+
+eval "`$LIBTOOL --config | $EGREP '^(objdir)='`"
+
+AT_DATA([liba.c],
+[[int liba_func1 (int arg)
+{
+  return arg + 1;
+}
+]])
+AT_DATA([usea.c],
+[[extern int liba_func1 (int arg);
+int main (void)
+{
+  int a = 2;
+  int b = liba_func1 (a);
+  if (b == 3) return 0;
+  return 1;
+}
+]])
+
+AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c liba.c],
+        [], [ignore], [ignore])
+AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -no-undefined ]dnl
+        [-o liba.la -rpath /foo liba.lo],
+        [], [ignore], [ignore])
+AT_CHECK([$CC $CPPFLAGS $CFLAGS -c usea.c],
+        [], [ignore], [ignore])
+
+
+# Make sure PATH is at least 250 chars, which should force line breaks
+# in lt-usea.c.
+
+dirpath=
+save_IFS=$IFS
+IFS=$PATH_SEPARATOR
+for dirpath in $PATH; do
+  IFS=$save_IFS
+  break
+done
+IFS=$save_IFS
+
+until $ECHO "PATH=$PATH" | grep 'PATH=.\{250\}'; do
+  PATH="$PATH$PATH_SEPARATOR$dirpath"
+done
+export PATH
+
+AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -no-fast-install ]dnl
+        [-o usea$EXEEXT usea.$OBJEXT liba.la],
+        [], [ignore], [ignore])
+
+# Skip if no cwrapper is generated.
+AT_CHECK([test -f $objdir/lt-usea.c || exit 77])
+
+# Try to make sure the test is relevant.
+AT_CHECK([grep ' *fputs' $objdir/lt-usea.c > /dev/null])
+# Check for no overly long fputs.
+AT_CHECK([grep ' *fputs.\{250\}' $objdir/lt-usea.c], [1])
+
+AT_CLEANUP