From: Gary V. Vaughan Date: Sat, 6 Oct 2012 10:50:57 +0000 (+0700) Subject: options-parser: employ fork minimisation. X-Git-Tag: v2.4.2.418~130 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=125eb722e4793a1e080975e01561082d67634fd3;p=thirdparty%2Flibtool.git options-parser: employ fork minimisation. * 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 --- diff --git a/build-aux/options-parser b/build-aux/options-parser index 86d52db07..ecd167993 100644 --- a/build-aux/options-parser +++ b/build-aux/options-parser @@ -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 ()