From: Ralf Wildenhues Date: Thu, 10 Apr 2008 21:18:02 +0000 (+0000) Subject: * libltdl/m4/libtool.m4 (_LT_PROG_XSI_SHELLFNS): Move non-XSI X-Git-Tag: v2.2.4~32 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=f470f5557b015ed52c77b42b733d2edc7ceeb993;p=thirdparty%2Flibtool.git * libltdl/m4/libtool.m4 (_LT_PROG_XSI_SHELLFNS): Move non-XSI definition of func_dirname_and_basename ... * libltdl/config/general.m4sh (func_dirname_and_basename): ... here, to use it for the other scripts that use general.m4sh (and as portable fallback for libtool). Add marker for early insertion of generated shell functions (into libtool, not the other scripts) here. Use func_dirname_and_basename to compute progname, progpath. * libltdl/config/ltmain.m4sh (func_mode_help): Remove marker for insertion of generated shell functions. * tests/sh.test: Adjust function definition test to not match function call. --- diff --git a/ChangeLog b/ChangeLog index 2ece81d94..f806f5ad6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2008-04-10 Ralf Wildenhues + * libltdl/m4/libtool.m4 (_LT_PROG_XSI_SHELLFNS): Move non-XSI + definition of func_dirname_and_basename ... + * libltdl/config/general.m4sh (func_dirname_and_basename): + ... here, to use it for the other scripts that use general.m4sh + (and as portable fallback for libtool). Add marker for early + insertion of generated shell functions (into libtool, not the + other scripts) here. + Use func_dirname_and_basename to compute progname, progpath. + * libltdl/config/ltmain.m4sh (func_mode_help): Remove marker + for insertion of generated shell functions. + * tests/sh.test: Adjust function definition test to not match + function call. + * libltdl/m4/libtool.m4 (_LT_PROG_XSI_SHELLFNS) : New function. * libltdl/config/ltmain.m4sh (func_mode_compile): Use it to diff --git a/libltdl/config/general.m4sh b/libltdl/config/general.m4sh index 71a20d28a..29b3d917e 100644 --- a/libltdl/config/general.m4sh +++ b/libltdl/config/general.m4sh @@ -61,6 +61,32 @@ IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi + func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` +} + +# Generated shell functions inserted here. + # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special @@ -71,13 +97,17 @@ progpath="$0" # The name of this program: # In the unlikely event $progname began with a '-', it would play havoc with # func_echo (imagine progname=-n), so we prepend ./ in that case: -progname=`$ECHO "X$progpath" | $Xsed -e "$basename" -e 's,^-,./-,'` +func_dirname_and_basename "$progpath" +progname=$func_basename_result +case $progname in + -*) progname=./$progname ;; +esac # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) - progdir=`$ECHO "X$progpath" | $Xsed -e "$dirname"` + progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index 905be9d9c..8ffcbaf90 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -250,9 +250,6 @@ func_enable_tag () esac } -# Generated shell functions inserted here. - - # Parse options once, thoroughly. This comes as soon as possible in # the script to make things like `libtool --version' happen quickly. { diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4 index 38b9569d7..1fc9ccf8d 100644 --- a/libltdl/m4/libtool.m4 +++ b/libltdl/m4/libtool.m4 @@ -7198,29 +7198,9 @@ func_basename () func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` } -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi - func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` -} +dnl func_dirname_and_basename +dnl A portable version of this function is already defined in general.m4sh +dnl so there is no need for it here. # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. diff --git a/tests/sh.test b/tests/sh.test index dad74bacd..6d2fa2073 100755 --- a/tests/sh.test +++ b/tests/sh.test @@ -2,7 +2,8 @@ # sh.test - check for some nonportable or dubious or undesired shell # constructs in shell scripts. # -# Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software +# Foundation, Inc. # Written by Gary V. Vaughan, 2003 # # This file is part of GNU Libtool. @@ -104,7 +105,7 @@ done for s in $scripts do if $SED -n ' - /^func_/{ + /^func_.*(/{ N /^func_[^ ]* ()\n{$/d p