]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
options-parser: employ fork minimisation.
authorGary V. Vaughan <gary@gnu.org>
Sat, 6 Oct 2012 10:50:57 +0000 (17:50 +0700)
committerGary V. Vaughan <gary@gnu.org>
Fri, 12 Oct 2012 11:36:37 +0000 (18:36 +0700)
* build-aux/options-parser (_G_HAVE_XSI_OPS): Environment
overrideable defaults for bash and zsh, which are known to
support XSI extensions.
(_G_HAVE_PLUSEQ_OP): Similarly for new enough versions of bash,
which are known to have += support.
(func_append): Only perform the shell += probe when state of
support is unknown.
(func_split_equals, func_split_short_opt): Similarly for XSI
probe to select fastest working implementation.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
build-aux/options-parser

index 86d52db07ceb7a0e40b8fc1e2ee0ece51b574dc1..ecd167993089443e4100e2cb0b4694c44fe1bf70 100644 (file)
@@ -232,11 +232,29 @@ progname=`$bs_echo "$progpath" |$SED "$basename"`
 # to the main code.  A hook is just a named list of of function, that can
 # be run in order later on.
 
+  # We should try to minimise forks, especially on Windows where they are
+  # unreasonably slow, so skip the feature probes when bash or zsh are
+  # being used:
+  if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
+    : ${_G_HAVE_XSI_OPS="yes"}
+    # The += operator was introduced in bash 3.1
+    case $BASH_VERSION in
+      [12].* | 3.0 | 3.0.*) ;;
+      *)
+        : ${_G_HAVE_PLUSEQ_OP="yes"}
+        ;;
+    esac
+  fi
+
 
 # func_append VAR VALUE
 # ---------------------
 # Append VALUE onto the existing contents of VAR.
-if (eval 'x=a; x+=" b"; test "x$x" = "xa b"') 2>/dev/null
+test -z "$_G_HAVE_PLUSEQ_OP" \
+    && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
+    && _G_HAVE_PLUSEQ_OP=yes
+
+if test yes = "$_G_HAVE_PLUSEQ_OP"
 then
   # This is an XSI compatible shell, allowing a faster implementation...
   eval 'func_append ()
@@ -728,7 +746,12 @@ func_quote_for_eval ()
 # ------------------------
 # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
 # splitting STRING at the `=' sign.
-if (eval 'x='--ab=cd'; y=${x#*=}; z=${x%%=*}; test x$y$z = xcd--ab') 2>/dev/null
+test -z "$_G_HAVE_XSI_OPS" \
+    && (eval 'x=a/b/c;
+      test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
+    && _G_HAVE_XSI_OPS=yes
+
+if test yes = "$_G_HAVE_XSI_OPS"
 then
   # This is an XSI compatible shell, allowing a faster implementation...
   eval 'func_split_equals ()
@@ -758,7 +781,7 @@ fi #func_split_equals
 # -----------------------------
 # Set func_split_short_opt_name and func_split_short_opt_arg shell
 # variables after splitting SHORTOPT after the 2nd character.
-if (eval 'x=-abc; y=${x#??}; z=${x%$y}; test x$y$z = xbc-a') 2>/dev/null
+if test yes = "$_G_HAVE_XSI_OPS"
 then
   # This is an XSI compatible shell, allowing a faster implementation...
   eval 'func_split_short_opt ()