libtool-patches
[Top][All Lists]
Advanced

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

Speed up progname, progpath setting


From: Ralf Wildenhues
Subject: Speed up progname, progpath setting
Date: Thu, 10 Apr 2008 01:31:26 +0200
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

OK to apply?

What about eliminating (when progdir='.')
  curwd=`cd . && pwd`

Do we know when (with which shells) this can be replaced by $PWD
portably?

Thanks,
Ralf

2008-04-10  Ralf Wildenhues  <address@hidden>

        * 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.

Index: libltdl/config/general.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/general.m4sh,v
retrieving revision 1.10
diff -u -r1.10 general.m4sh
--- libltdl/config/general.m4sh 9 Mar 2008 14:12:10 -0000       1.10
+++ libltdl/config/general.m4sh 9 Apr 2008 23:24:13 -0000
@@ -61,6 +61,32 @@
 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 @@
 # 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"
      ;;
Index: libltdl/config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.102
diff -u -r1.102 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  16 Mar 2008 08:34:25 -0000      1.102
+++ libltdl/config/ltmain.m4sh  9 Apr 2008 23:24:15 -0000
@@ -432,9 +432,6 @@
     exit $?
 }
 
-# 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.
 {
Index: libltdl/m4/libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/m4/libtool.m4,v
retrieving revision 1.146
diff -u -r1.146 libtool.m4
--- libltdl/m4/libtool.m4       1 Apr 2008 18:23:19 -0000       1.146
+++ libltdl/m4/libtool.m4       9 Apr 2008 23:24:17 -0000
@@ -7189,29 +7189,9 @@
   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.
Index: tests/sh.test
===================================================================
RCS file: /cvsroot/libtool/libtool/tests/sh.test,v
retrieving revision 1.32
diff -u -r1.32 sh.test
--- tests/sh.test       25 Mar 2007 12:12:43 -0000      1.32
+++ tests/sh.test       9 Apr 2008 23:24:18 -0000
@@ -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 @@
 for s in $scripts
 do
   if $SED -n '
-      /^func_/{
+      /^func_.*(/{
          N
          /^func_[^     ]* ()\n{$/d
          p




reply via email to

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