From c161010e9deec544410a3e91d105d07ed9ec9911 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Mon, 4 Oct 2010 21:16:26 +0200 Subject: [PATCH] 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. Signed-off-by: Peter Rosin --- ChangeLog | 7 +++++ libltdl/config/ltmain.m4sh | 12 ++++++-- tests/cwrapper.at | 61 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4477414cc..c0492fe84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2010-10-04 Peter Rosin + 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) : Make all sections diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index 041800744..1078e757b 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -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 diff --git a/tests/cwrapper.at b/tests/cwrapper.at index 248c0c0ad..cd618dcb7 100644 --- a/tests/cwrapper.at +++ b/tests/cwrapper.at @@ -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 -- 2.47.2