OK to both patches for HEAD (-33 lines, -66 lines, while investigating
unrelated bugs)?

Cheers,
Ralf

        * config/ltmain.m4sh (func_source): New function.
        (func_mode_execute, func_mode_install, func_mode_link): Use it.

        * config/ltmain.m4sh (func_execute_cmds): New function.
        (func_mode_finish, func_mode_install, func_mode_link)
        (func_mode_uninstall): Use it.
        * config/ltmain.m4sh (func_source): New function.
        (func_mode_execute, func_mode_install, func_mode_link): Use it.

Index: config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/config/ltmain.m4sh,v
retrieving revision 1.81
diff -u -r1.81 ltmain.m4sh
--- config/ltmain.m4sh  8 Aug 2005 19:03:52 -0000       1.81
+++ config/ltmain.m4sh  9 Aug 2005 19:50:59 -0000
@@ -627,6 +627,25 @@
 }
 
 
+# func_source file noexe
+# Source FILE, adding directory component if necessary.
+# If noexe is given, add a dot to prevent `$file.exe' from
+# being sourced on system with automatic-append-.exe behavior.
+func_source ()
+{
+    $opt_debug
+    case $2,$build in
+    noexe,*cygwin* | noexe,*mingw*)
+       func_source_file=$1. ;;
+    *) func_source_file=$1  ;;
+    esac
+    case $func_source_file in
+    */* | *\\*)        . "$func_source_file" ;;
+    *)         . "./$func_source_file" ;;
+    esac
+}
+
+
 # Generated shell functions inserted here.
 
 
@@ -1486,12 +1504,7 @@
        # Read the libtool library.
        dlname=
        library_names=
-
-       # If there is no directory component, then add one.
-       case $file in
-       */* | *\\*) . $file ;;
-       *) . ./$file ;;
-       esac
+       func_source "$file"
 
        # Skip this library if it cannot be dlopened.
        if test -z "$dlname"; then
@@ -1548,11 +1561,7 @@
       *)
        # Do a test to see if this is really a libtool program.
        if func_ltwrapper_p "$file"; then
-         # If there is no directory component, then add one.
-         case $file in
-         */* | *\\*) . $file ;;
-         *) . ./$file ;;
-         esac
+         func_source "$file"
 
          # Transform arg to wrapped name.
          file="$progdir/$program"
@@ -1822,11 +1831,7 @@
        library_names=
        old_library=
        relink_command=
-       # If there is no directory component, then add one.
-       case $file in
-       */* | *\\*) . $file ;;
-       *) . ./$file ;;
-       esac
+       func_source "$file"
 
        # Add the libdir to current_libdirs if it is the destination.
        if test "X$destdir" = "X$libdir"; then
@@ -2005,18 +2010,7 @@
          notinst_deplibs=
          relink_command=
 
-         # To insure that "foo" is sourced, and not "foo.exe",
-         # finese the cygwin/MSYS system by explicitly sourcing "foo."
-         # which disallows the automatic-append-.exe behavior.
-         case $build in
-         *cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
-         *) wrapperdot=${wrapper} ;;
-         esac
-         # If there is no directory component, then add one.
-         case $file in
-         */* | *\\*) . ${wrapperdot} ;;
-         *) . ./${wrapperdot} ;;
-         esac
+         func_source "$wrapper" noexe
 
          # Check the variables that should have been set.
          test -z "$generated_by_libtool_version" && \
@@ -2027,11 +2021,7 @@
            # Check to see that each library is installed.
            libdir=
            if test -f "$lib"; then
-             # If there is no directory component, then add one.
-             case $lib in
-             */* | *\\*) . $lib ;;
-             *) . ./$lib ;;
-             esac
+             func_source "$lib"
            fi
            libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### 
testsuite: skip nested quoting test
            if test -n "$libdir" && test ! -f "$libfile"; then
@@ -2041,18 +2031,7 @@
          done
 
          relink_command=
-         # To insure that "foo" is sourced, and not "foo.exe",
-         # finese the cygwin/MSYS system by explicitly sourcing "foo."
-         # which disallows the automatic-append-.exe behavior.
-         case $build in
-         *cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
-         *) wrapperdot=${wrapper} ;;
-         esac
-         # If there is no directory component, then add one.
-         case $file in
-         */* | *\\*) . ${wrapperdot} ;;
-         *) . ./${wrapperdot} ;;
-         esac
+         func_source "$wrapper" noexe
 
          outputname=
          if test "$fast_install" = no && test -n "$relink_command"; then
@@ -2364,11 +2343,7 @@
                non_pic_object=
 
                # Read the .lo file
-               # If there is no directory component, then add one.
-               case $arg in
-               */* | *\\*) . $arg ;;
-               *) . ./$arg ;;
-               esac
+               func_source "$arg"
 
                if test -z "$pic_object" ||
                   test -z "$non_pic_object" ||
@@ -2873,11 +2848,7 @@
          non_pic_object=
 
          # Read the .lo file
-         # If there is no directory component, then add one.
-         case $arg in
-         */* | *\\*) . $arg ;;
-         *) . ./$arg ;;
-         esac
+         func_source "$arg"
 
          if test -z "$pic_object" ||
             test -z "$non_pic_object" ||
@@ -3124,8 +3095,7 @@
          # Ignore non-libtool-libs
          dependency_libs=
          case $lib in
-         *[[\\/]]*.la) . $lib   ;;
-         *.la)       . ./$lib ;;
+         *.la) func_source "$lib" ;;
          esac
 
          # Collect preopened libtool deplibs, except any this library
@@ -3205,10 +3175,7 @@
                if func_lalib_p "$lib"; then
                  library_names=
                  old_library=
-                 case $lib in
-                 */* | *\\*) . $lib ;;
-                 *) . ./$lib ;;
-                 esac
+                 func_source "$lib"
                  for l in $old_library $library_names; do
                    ll="$l"
                  done
@@ -3395,10 +3362,7 @@
 
 
        # Read the .la file
-       case $lib in
-       */* | *\\*) . $lib ;;
-       *) . ./$lib ;;
-       esac
+       func_source "$lib"
 
        case $host in
        *-*-darwin*)
        * config/ltmain.m4sh (func_execute_cmds): New function.
        (func_mode_finish, func_mode_install, func_mode_link)
        (func_mode_uninstall): Use it.

Index: config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/config/ltmain.m4sh,v
retrieving revision 1.81
diff -u -r1.81 ltmain.m4sh
--- config/ltmain.m4sh  8 Aug 2005 19:03:52 -0000       1.81
+++ config/ltmain.m4sh  9 Aug 2005 19:50:01 -0000
@@ -627,6 +627,23 @@
 }
 
 
+# func_execute_cmds commands fail_cmd
+# Execute tilde-delimited COMMANDS.
+# If FAIL_CMD is given, eval that upon failure.
+# FAIL_CMD may read-access the current command in variable CMD!
+func_execute_cmds ()
+{
+    $opt_debug
+    save_ifs=$IFS; IFS='~'
+    for cmd in $1; do
+      IFS=$save_ifs
+      eval cmd=\"$cmd\"
+      func_show_eval "$cmd" "${2-:}"
+    done
+    IFS=$save_ifs
+}
+
+
 # Generated shell functions inserted here.
 
 
@@ -1608,15 +1616,8 @@
       for libdir in $libdirs; do
        if test -n "$finish_cmds"; then
          # Do each command in the finish commands.
-         cmds=$finish_cmds
-         save_ifs="$IFS"; IFS='~'
-         for cmd in $cmds; do
-           IFS="$save_ifs"
-           eval cmd=\"$cmd\"
-           func_show_eval "$cmd" 'admincmds="$admincmds
+         func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
 '"$cmd"'"'
-         done
-         IFS="$save_ifs"
        fi
        if test -n "$finish_eval"; then
          # Do the single finish_eval.
@@ -1908,14 +1909,7 @@
 
          # Do each command in the postinstall commands.
          lib="$destdir/$realname"
-         cmds=$postinstall_cmds
-         save_ifs="$IFS"; IFS='~'
-         for cmd in $cmds; do
-           IFS="$save_ifs"
-           eval cmd=\"$cmd\"
-           func_show_eval "$cmd" 'exit $?'
-         done
-         IFS="$save_ifs"
+         func_execute_cmds "$postinstall_cmds" 'exit $?'
        fi
 
        # Install the pseudo-library for information purposes.
@@ -2126,14 +2120,7 @@
       fi
 
       # Do each command in the postinstall commands.
-      cmds=$old_postinstall_cmds
-      save_ifs="$IFS"; IFS='~'
-      for cmd in $cmds; do
-       IFS="$save_ifs"
-       eval cmd=\"$cmd\"
-       func_show_eval "$cmd" 'exit $?'
-      done
-      IFS="$save_ifs"
+      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
     done
 
     test -n "$future_libdirs" && \
@@ -3730,27 +3717,13 @@
            if test -f "$output_objdir/$soname-def"; then :
            else
              func_echo "extracting exported symbol list from \`$soname'"
-             save_ifs="$IFS"; IFS='~'
-             cmds=$extract_expsyms_cmds
-             for cmd in $cmds; do
-               IFS="$save_ifs"
-               eval cmd=\"$cmd\"
-               func_show_eval "$cmd" 'exit $?'
-             done
-             IFS="$save_ifs"
+             func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
            fi
 
            # Create $newlib
            if test -f "$output_objdir/$newlib"; then :; else
              func_echo "generating import library for \`$soname'"
-             save_ifs="$IFS"; IFS='~'
-             cmds=$old_archive_from_expsyms_cmds
-             for cmd in $cmds; do
-               IFS="$save_ifs"
-               eval cmd=\"$cmd\"
-               func_show_eval "$cmd" 'exit $?'
-             done
-             IFS="$save_ifs"
+             func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
            fi
            # make sure the library variables are pointing to the new library
            dir=$output_objdir
@@ -5357,14 +5330,7 @@
       reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e 
'/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### 
testsuite: skip nested quoting test
 
       output="$obj"
-      cmds=$reload_cmds
-      save_ifs="$IFS"; IFS='~'
-      for cmd in $cmds; do
-       IFS="$save_ifs"
-       eval cmd=\"$cmd\"
-       func_show_eval "$cmd" 'exit $?'
-      done
-      IFS="$save_ifs"
+      func_execute_cmds "$reload_cmds" 'exit $?'
 
       # Exit if we aren't doing a library object file.
       if test -z "$libobj"; then
@@ -5391,14 +5357,7 @@
        # Only do commands if we really have different PIC objects.
        reload_objs="$libobjs $reload_conv_objs"
        output="$libobj"
-       cmds=$reload_cmds
-       save_ifs="$IFS"; IFS='~'
-       for cmd in $cmds; do
-         IFS="$save_ifs"
-         eval cmd=\"$cmd\"
-         func_show_eval "$cmd" 'exit $?'
-       done
-       IFS="$save_ifs"
+       func_execute_cmds "$reload_cmds" 'exit $?'
       fi
 
       if test -n "$gentop"; then
@@ -5561,14 +5520,7 @@
 
       # template prelinking step
       if test -n "$prelink_cmds"; then
-       cmds=$prelink_cmds
-       save_ifs="$IFS"; IFS='~'
-       for cmd in $cmds; do
-         eval cmd=\"$cmd\"
-         IFS="$save_ifs"
-         func_show_eval "$cmd" 'exit $?'
-       done
-       IFS="$save_ifs"
+       func_execute_cmds "$prelink_cmds" 'exit $?'
       fi
 
       wrappers_required=yes
@@ -6390,13 +6342,7 @@
          fi
        fi
       fi
-      save_ifs="$IFS"; IFS='~'
-      for cmd in $cmds; do
-       eval cmd=\"$cmd\"
-       IFS="$save_ifs"
-       func_show_eval "$cmd" 'exit $?'
-      done
-      IFS="$save_ifs"
+      func_execute_cmds "$cmds" 'exit $?'
     done
 
     test -n "$generated" && \
@@ -6647,32 +6593,12 @@
          if test "$mode" = uninstall; then
            if test -n "$library_names"; then
              # Do each command in the postuninstall commands.
-             cmds=$postuninstall_cmds
-             save_ifs="$IFS"; IFS='~'
-             for cmd in $cmds; do
-               IFS="$save_ifs"
-               eval cmd=\"$cmd\"
-               func_show_eval "$cmd"
-               if test "$?" -ne 0 && test "$rmforce" != yes; then
-                 exit_status=1
-               fi
-             done
-             IFS="$save_ifs"
+             func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || 
exit_status=1'
            fi
 
            if test -n "$old_library"; then
              # Do each command in the old_postuninstall commands.
-             cmds=$old_postuninstall_cmds
-             save_ifs="$IFS"; IFS='~'
-             for cmd in $cmds; do
-               IFS="$save_ifs"
-               eval cmd=\"$cmd\"
-               func_show_eval "$cmd"
-               if test "$?" -ne 0 && test "$rmforce" != yes; then
-                 exit_status=1
-               fi
-             done
-             IFS="$save_ifs"
+             func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = 
yes || exit_status=1'
            fi
            # FIXME: should reinstall the best remaining shared library.
          fi

Reply via email to