summaryrefslogtreecommitdiff
path: root/bootstrap
diff options
context:
space:
mode:
authorPavel Raiskup <praiskup@redhat.com>2015-10-04 21:55:03 +0200
committerPavel Raiskup <praiskup@redhat.com>2015-10-12 19:21:33 +0200
commit32f0df9835ac15ac17e04be57c368172c3ad1d19 (patch)
treee68bace94ffd423ff0bde382d6fa9a7760469930 /bootstrap
parentb7b6ec33baa4747eb147e9e249e675e477d861f4 (diff)
downloadlibtool-32f0df9835ac15ac17e04be57c368172c3ad1d19.tar.gz
libtool: mitigate the $sed_quote_subst slowdown
When it is reasonably possible, use shell implementation for quoting. References: http://lists.gnu.org/archive/html/libtool/2015-03/msg00005.html http://lists.gnu.org/archive/html/libtool/2015-02/msg00000.html https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20006 * gl/build-aux/funclib.sh (func_quote): New function that can be used as substitution for '$SED $sed_quote_subst' call. * build-aux/ltmain.in (func_emit_wrapper): Use func_quote instead of '$SED $sed_quote_subst'. (func_mode_link): Likewise. * NEWS: Document. * bootstrap: Sync with funclib.sh.
Diffstat (limited to 'bootstrap')
-rwxr-xr-xbootstrap61
1 files changed, 54 insertions, 7 deletions
diff --git a/bootstrap b/bootstrap
index c179f51d..fe9e9cac 100755
--- a/bootstrap
+++ b/bootstrap
@@ -230,7 +230,7 @@ vc_ignore=
# Source required external libraries:
# Set a version string for this script.
-scriptversion=2015-01-20.17; # UTC
+scriptversion=2015-10-04.22; # UTC
# General shell script boiler plate, and helper functions.
# Written by Gary V. Vaughan, 2004
@@ -1257,6 +1257,57 @@ func_relative_path ()
}
+# func_quote ARG
+# --------------
+# Aesthetically quote one ARG, store the result into $func_quote_result. Note
+# that we keep attention to performance here (so far O(N) complexity as long as
+# func_append is O(1)).
+func_quote ()
+{
+ $debug_cmd
+
+ func_quote_result=$1
+
+ case $func_quote_result in
+ *[\\\`\"\$]*)
+ case $func_quote_result in
+ *'*'*|*'['*)
+ func_quote_result=`$ECHO "$func_quote_result" | $SED "$sed_quote_subst"`
+ return 0
+ ;;
+ esac
+
+ func_quote_old_IFS=$IFS
+ for _G_char in '\' '`' '"' '$'
+ do
+ # STATE($1) PREV($2) SEPARATOR($3)
+ set start "" ""
+ func_quote_result=dummy"$_G_char$func_quote_result$_G_char"dummy
+ IFS=$_G_char
+ for _G_part in $func_quote_result
+ do
+ case $1 in
+ quote)
+ func_append func_quote_result "$3$2"
+ set quote "$_G_part" "\\$_G_char"
+ ;;
+ start)
+ set first "" ""
+ func_quote_result=
+ ;;
+ first)
+ set quote "$_G_part" ""
+ ;;
+ esac
+ done
+ IFS=$func_quote_old_IFS
+ done
+ ;;
+ *) ;;
+ esac
+}
+
+
# func_quote_for_eval ARG...
# --------------------------
# Aesthetically quote ARGs to be evaled later.
@@ -1273,12 +1324,8 @@ func_quote_for_eval ()
func_quote_for_eval_unquoted_result=
func_quote_for_eval_result=
while test 0 -lt $#; do
- case $1 in
- *[\\\`\"\$]*)
- _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
- *)
- _G_unquoted_arg=$1 ;;
- esac
+ func_quote "$1"
+ _G_unquoted_arg=$func_quote_result
if test -n "$func_quote_for_eval_unquoted_result"; then
func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
else