Control: tags 848864 + patch

Dear maintainer,

I've prepared an NMU for libtool (versioned as 2.4.6-2.1) to fix this
issue. This NMU restores most of the original performance of libtool
2.4.2.

Please review.

Thanks,
Andreas
diff -Nru libtool-2.4.6/debian/changelog libtool-2.4.6/debian/changelog
--- libtool-2.4.6/debian/changelog	2016-08-20 14:34:31.000000000 +0200
+++ libtool-2.4.6/debian/changelog	2018-01-19 11:37:19.000000000 +0100
@@ -1,3 +1,14 @@
+libtool (2.4.6-2.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Mitigate exessive sed forking (Closes: #848864):
+    - Add 0010-libtool-mitigate-the-sed_quote_subst-slowdown.patch
+    - Add 0011-libtool-optimizing-options-parser-hooks.patch
+    - Add 0012-funclib-refactor-quoting-methods-a-bit.patch
+    - Refresh 0020-libtool-fix-GCC-clang-linking-with-fsanitize.patch
+
+ -- Andreas Boll <andreas.boll....@gmail.com>  Fri, 19 Jan 2018 11:37:19 +0100
+
 libtool (2.4.6-2) unstable; urgency=medium
 
   * Don't show the debain version in --version, just in --help
diff -Nru libtool-2.4.6/debian/patches/0010-libtool-mitigate-the-sed_quote_subst-slowdown.patch libtool-2.4.6/debian/patches/0010-libtool-mitigate-the-sed_quote_subst-slowdown.patch
--- libtool-2.4.6/debian/patches/0010-libtool-mitigate-the-sed_quote_subst-slowdown.patch	1970-01-01 01:00:00.000000000 +0100
+++ libtool-2.4.6/debian/patches/0010-libtool-mitigate-the-sed_quote_subst-slowdown.patch	2018-01-19 11:28:13.000000000 +0100
@@ -0,0 +1,235 @@
+From 32f0df9835ac15ac17e04be57c368172c3ad1d19 Mon Sep 17 00:00:00 2001
+From: Pavel Raiskup <prais...@redhat.com>
+Date: Sun, 4 Oct 2015 21:55:03 +0200
+Subject: [PATCH] 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.
+---
+ NEWS                    |  3 +++
+ bootstrap               | 61 +++++++++++++++++++++++++++++++++++++++++++------
+ build-aux/ltmain.in     | 10 ++++----
+ gl/build-aux/funclib.sh | 61 +++++++++++++++++++++++++++++++++++++++++++------
+ 4 files changed, 117 insertions(+), 18 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
+diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
+index 0c40da06..24acefd5 100644
+--- a/build-aux/ltmain.in
++++ b/build-aux/ltmain.in
+@@ -3346,7 +3346,8 @@ else
+   if test \"\$libtool_execute_magic\" != \"$magic\"; then
+     file=\"\$0\""
+ 
+-    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
++    func_quote "$ECHO"
++    qECHO=$func_quote_result
+     $ECHO "\
+ 
+ # A function that is used when there is no print builtin or printf.
+@@ -8596,8 +8597,8 @@ EOF
+ 	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+ 	  fi
+ 	done
+-	relink_command="(cd `pwd`; $relink_command)"
+-	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
++	func_quote "(cd `pwd`; $relink_command)"
++	relink_command=$func_quote_result
+       fi
+ 
+       # Only actually do things if not in dry run mode.
+@@ -8843,7 +8844,8 @@ EOF
+       done
+       # Quote the link command for shipping.
+       relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+-      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
++      func_quote "$relink_command"
++      relink_command=$func_quote_result
+       if test yes = "$hardcode_automatic"; then
+ 	relink_command=
+       fi
+diff --git a/build-aux/funclib.sh b/build-aux/funclib.sh
+index 39d972ed..47d8b95a 100644
+--- a/build-aux/funclib.sh
++++ b/build-aux/funclib.sh
+@@ -1,5 +1,5 @@
+ # 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
+@@ -1026,6 +1026,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.
+@@ -1042,12 +1093,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
+-- 
+2.11.0
+
diff -Nru libtool-2.4.6/debian/patches/0011-libtool-optimizing-options-parser-hooks.patch libtool-2.4.6/debian/patches/0011-libtool-optimizing-options-parser-hooks.patch
--- libtool-2.4.6/debian/patches/0011-libtool-optimizing-options-parser-hooks.patch	1970-01-01 01:00:00.000000000 +0100
+++ libtool-2.4.6/debian/patches/0011-libtool-optimizing-options-parser-hooks.patch	2018-01-19 11:28:13.000000000 +0100
@@ -0,0 +1,755 @@
+From 16dbc070d32e6d4601cb5878dfdf69f2e29c84e1 Mon Sep 17 00:00:00 2001
+From: Pavel Raiskup <prais...@redhat.com>
+Date: Mon, 5 Oct 2015 13:16:08 +0200
+Subject: [PATCH] libtool: optimizing options-parser hooks
+
+Its not necessary to (re)func_quote_for_eval in each function in
+the hook hierarchy.  Usually it is enough if the leaf function
+does func_quote_for_eval and its caller just re-uses the
+<CALLEE>_return variable.
+
+This is follow up for the previous commit.
+
+* gl/build-aux/options-parser (func_run_hooks): Propagate
+$EXIT_SUCCESS return code down to caller if *any* hook succeeded.
+Never re-quote the result -- either the arguments are left
+untouched, or the options have already been properly quoted by
+succeeding hooks.
+(func_parse_options): Quote '$@' and return $EXIT_SUCCESS only if
+we changed something.
+(func_validate_options): Likewise.
+(func_options_prep): Likewise.
+(func_options_finish): New hook-caller for 'func_options' hooks.
+(func_options): Propagate return value down to top-level caller,
+but pay attention we have always set $func_options_result.
+* build-aux/ltmain.in (libtool_options_prep): Quote '$@' and
+return $EXIT_SUCCESS only if we changed something.
+(libtool_parse_options): Likewise.
+* bootstrap: Sync gl/build-aux/with option-parser.
+---
+ bootstrap                   | 171 +++++++++++++++++++++++++++++++-------------
+ build-aux/ltmain.in         |  35 ++++++---
+ gl/build-aux/options-parser | 171 +++++++++++++++++++++++++++++++-------------
+ 3 files changed, 271 insertions(+), 106 deletions(-)
+
+diff --git a/bootstrap b/bootstrap
+index fe9e9cac..4f000965 100755
+--- a/bootstrap
++++ b/bootstrap
+@@ -1583,7 +1583,7 @@ func_lt_ver ()
+ #! /bin/sh
+ 
+ # Set a version string for this script.
+-scriptversion=2014-01-07.03; # UTC
++scriptversion=2015-10-07.11; # UTC
+ 
+ # A portable, pluggable option parser for Bourne shell.
+ # Written by Gary V. Vaughan, 2010
+@@ -1743,6 +1743,8 @@ func_run_hooks ()
+ {
+     $debug_cmd
+ 
++    _G_rc_run_hooks=false
++
+     case " $hookable_fns " in
+       *" $1 "*) ;;
+       *) func_fatal_error "'$1' does not support hook funcions.n" ;;
+@@ -1751,16 +1753,16 @@ func_run_hooks ()
+     eval _G_hook_fns=\$$1_hooks; shift
+ 
+     for _G_hook in $_G_hook_fns; do
+-      eval $_G_hook '"$@"'
+-
+-      # store returned options list back into positional
+-      # parameters for next 'cmd' execution.
+-      eval _G_hook_result=\$${_G_hook}_result
+-      eval set dummy "$_G_hook_result"; shift
++      if eval $_G_hook '"$@"'; then
++        # store returned options list back into positional
++        # parameters for next 'cmd' execution.
++        eval _G_hook_result=\$${_G_hook}_result
++        eval set dummy "$_G_hook_result"; shift
++        _G_rc_run_hooks=:
++      fi
+     done
+ 
+-    func_quote_for_eval ${1+"$@"}
+-    func_run_hooks_result=$func_quote_for_eval_result
++    $_G_rc_run_hooks && func_run_hooks_result=$_G_hook_result
+ }
+ 
+ 
+@@ -1770,10 +1772,16 @@ func_run_hooks ()
+ ## --------------- ##
+ 
+ # In order to add your own option parsing hooks, you must accept the
+-# full positional parameter list in your hook function, remove any
+-# options that you action, and then pass back the remaining unprocessed
++# full positional parameter list in your hook function, you may remove/edit
++# any options that you action, and then pass back the remaining unprocessed
+ # options in '<hooked_function_name>_result', escaped suitably for
+-# 'eval'.  Like this:
++# 'eval'.  In this case you also must return $EXIT_SUCCESS to let the
++# hook's caller know that it should pay attention to
++# '<hooked_function_name>_result'.  Returning $EXIT_FAILURE signalizes that
++# arguments are left untouched by the hook and therefore caller will ignore the
++# result variable.
++#
++# Like this:
+ #
+ #    my_options_prep ()
+ #    {
+@@ -1783,9 +1791,11 @@ func_run_hooks ()
+ #        usage_message=$usage_message'
+ #      -s, --silent       don'\''t print informational messages
+ #    '
+-#
+-#        func_quote_for_eval ${1+"$@"}
+-#        my_options_prep_result=$func_quote_for_eval_result
++#        # No change in '$@' (ignored completely by this hook).  There is
++#        # no need to do the equivalent (but slower) action:
++#        # func_quote_for_eval ${1+"$@"}
++#        # my_options_prep_result=$func_quote_for_eval_result
++#        false
+ #    }
+ #    func_add_hook func_options_prep my_options_prep
+ #
+@@ -1794,25 +1804,37 @@ func_run_hooks ()
+ #    {
+ #        $debug_cmd
+ #
++#        args_changed=false
++#
+ #        # Note that for efficiency, we parse as many options as we can
+ #        # recognise in a loop before passing the remainder back to the
+ #        # caller on the first unrecognised argument we encounter.
+ #        while test $# -gt 0; do
+ #          opt=$1; shift
+ #          case $opt in
+-#            --silent|-s) opt_silent=: ;;
++#            --silent|-s) opt_silent=:
++#                         args_changed=:
++#                         ;;
+ #            # Separate non-argument short options:
+ #            -s*)         func_split_short_opt "$_G_opt"
+ #                         set dummy "$func_split_short_opt_name" \
+ #                             "-$func_split_short_opt_arg" ${1+"$@"}
+ #                         shift
++#                         args_changed=:
+ #                         ;;
+-#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
++#            *)           # Make sure the first unrecognised option "$_G_opt"
++#                         # is added back to "$@", we could need that later
++#                         # if $args_changed is true.
++#                         set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
+ #          esac
+ #        done
+ #
+-#        func_quote_for_eval ${1+"$@"}
+-#        my_silent_option_result=$func_quote_for_eval_result
++#        if $args_changed; then
++#          func_quote_for_eval ${1+"$@"}
++#          my_silent_option_result=$func_quote_for_eval_result
++#        fi
++#
++#        $args_changed
+ #    }
+ #    func_add_hook func_parse_options my_silent_option
+ #
+@@ -1824,16 +1846,32 @@ func_run_hooks ()
+ #        $opt_silent && $opt_verbose && func_fatal_help "\
+ #    '--silent' and '--verbose' options are mutually exclusive."
+ #
+-#        func_quote_for_eval ${1+"$@"}
+-#        my_option_validation_result=$func_quote_for_eval_result
++#        false
+ #    }
+ #    func_add_hook func_validate_options my_option_validation
+ #
+-# You'll alse need to manually amend $usage_message to reflect the extra
++# You'll also need to manually amend $usage_message to reflect the extra
+ # options you parse.  It's preferable to append if you can, so that
+ # multiple option parsing hooks can be added safely.
+ 
+ 
++# func_options_finish [ARG]...
++# ----------------------------
++# Finishing the option parse loop (call 'func_options' hooks ATM).
++func_options_finish ()
++{
++    $debug_cmd
++
++    _G_func_options_finish_exit=false
++    if func_run_hooks func_options ${1+"$@"}; then
++      func_options_finish_result=$func_run_hooks_result
++      _G_func_options_finish_exit=:
++    fi
++
++    $_G_func_options_finish_exit
++}
++
++
+ # func_options [ARG]...
+ # ---------------------
+ # All the functions called inside func_options are hookable. See the
+@@ -1843,17 +1881,28 @@ func_options ()
+ {
+     $debug_cmd
+ 
+-    func_options_prep ${1+"$@"}
+-    eval func_parse_options \
+-        ${func_options_prep_result+"$func_options_prep_result"}
+-    eval func_validate_options \
+-        ${func_parse_options_result+"$func_parse_options_result"}
++    _G_rc_options=false
+ 
+-    eval func_run_hooks func_options \
+-        ${func_validate_options_result+"$func_validate_options_result"}
++    for my_func in options_prep parse_options validate_options options_finish
++    do
++      if eval func_$my_func '${1+"$@"}'; then
++        eval _G_res_var='$'"func_${my_func}_result"
++        eval set dummy "$_G_res_var" ; shift
++        _G_rc_options=:
++      fi
++    done
+ 
+-    # save modified positional parameters for caller
+-    func_options_result=$func_run_hooks_result
++    # Save modified positional parameters for caller.  As a top-level
++    # options-parser function we always need to set the 'func_options_result'
++    # variable (regardless the $_G_rc_options value).
++    if $_G_rc_options; then
++      func_options_result=$_G_res_var
++    else
++      func_quote_for_eval ${1+"$@"}
++      func_options_result=$func_quote_for_eval_result
++    fi
++
++    $_G_rc_options
+ }
+ 
+ 
+@@ -1862,9 +1911,9 @@ func_options ()
+ # All initialisations required before starting the option parse loop.
+ # Note that when calling hook functions, we pass through the list of
+ # positional parameters.  If a hook function modifies that list, and
+-# needs to propogate that back to rest of this script, then the complete
++# needs to propagate that back to rest of this script, then the complete
+ # modified list must be put in 'func_run_hooks_result' before
+-# returning.
++# returning $EXIT_SUCCESS (otherwise $EXIT_FAILURE is returned).
+ func_hookable func_options_prep
+ func_options_prep ()
+ {
+@@ -1874,10 +1923,14 @@ func_options_prep ()
+     opt_verbose=false
+     opt_warning_types=
+ 
+-    func_run_hooks func_options_prep ${1+"$@"}
++    _G_rc_options_prep=false
++    if func_run_hooks func_options_prep ${1+"$@"}; then
++      _G_rc_options_prep=:
++      # save modified positional parameters for caller
++      func_options_prep_result=$func_run_hooks_result
++    fi
+ 
+-    # save modified positional parameters for caller
+-    func_options_prep_result=$func_run_hooks_result
++    $_G_rc_options_prep
+ }
+ 
+ 
+@@ -1891,18 +1944,20 @@ func_parse_options ()
+ 
+     func_parse_options_result=
+ 
++    _G_rc_parse_options=false
+     # this just eases exit handling
+     while test $# -gt 0; do
+       # Defer to hook functions for initial option parsing, so they
+       # get priority in the event of reusing an option name.
+-      func_run_hooks func_parse_options ${1+"$@"}
+-
+-      # Adjust func_parse_options positional parameters to match
+-      eval set dummy "$func_run_hooks_result"; shift
++      if func_run_hooks func_parse_options ${1+"$@"}; then
++        eval set dummy "$func_run_hooks_result"; shift
++        _G_rc_parse_options=:
++      fi
+ 
+       # Break out of the loop if we already parsed every option.
+       test $# -gt 0 || break
+ 
++      _G_match_parse_options=:
+       _G_opt=$1
+       shift
+       case $_G_opt in
+@@ -1917,7 +1972,10 @@ func_parse_options ()
+ 		      ;;
+ 
+         --warnings|--warning|-W)
+-                      test $# = 0 && func_missing_arg $_G_opt && break
++                      if test $# = 0 && func_missing_arg $_G_opt; then
++                        _G_rc_parse_options=:
++                        break
++                      fi
+                       case " $warning_categories $1" in
+                         *" $1 "*)
+                           # trailing space prevents matching last $1 above
+@@ -1970,15 +2028,25 @@ func_parse_options ()
+                       shift
+                       ;;
+ 
+-        --)           break ;;
++        --)           _G_rc_parse_options=: ; break ;;
+         -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
+-        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
++        *)            set dummy "$_G_opt" ${1+"$@"}; shift
++                      _G_match_parse_options=false
++                      break
++                      ;;
+       esac
++
++      $_G_match_parse_options && _G_rc_parse_options=:
+     done
+ 
+-    # save modified positional parameters for caller
+-    func_quote_for_eval ${1+"$@"}
+-    func_parse_options_result=$func_quote_for_eval_result
++
++    if $_G_rc_parse_options; then
++      # save modified positional parameters for caller
++      func_quote_for_eval ${1+"$@"}
++      func_parse_options_result=$func_quote_for_eval_result
++    fi
++
++    $_G_rc_parse_options
+ }
+ 
+ 
+@@ -1991,16 +2059,21 @@ func_validate_options ()
+ {
+     $debug_cmd
+ 
++    _G_rc_validate_options=false
++
+     # Display all warnings if -W was not given.
+     test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
+ 
+-    func_run_hooks func_validate_options ${1+"$@"}
++    if func_run_hooks func_validate_options ${1+"$@"}; then
++      # save modified positional parameters for caller
++      func_validate_options_result=$func_run_hooks_result
++      _G_rc_validate_options=:
++    fi
+ 
+     # Bail if the options were screwed!
+     $exit_cmd $EXIT_FAILURE
+ 
+-    # save modified positional parameters for caller
+-    func_validate_options_result=$func_run_hooks_result
++    $_G_rc_validate_options
+ }
+ 
+ 
+diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
+index 24acefd5..b4c6bcd6 100644
+--- a/build-aux/ltmain.in
++++ b/build-aux/ltmain.in
+@@ -358,6 +358,8 @@ libtool_options_prep ()
+     nonopt=
+     preserve_args=
+ 
++    _G_rc_lt_options_prep=:
++
+     # Shorthand for --mode=foo, only valid as the first argument
+     case $1 in
+     clean|clea|cle|cl)
+@@ -381,11 +383,18 @@ libtool_options_prep ()
+     uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+       shift; set dummy --mode uninstall ${1+"$@"}; shift
+       ;;
++    *)
++      _G_rc_lt_options_prep=false
++      ;;
+     esac
+ 
+-    # Pass back the list of options.
+-    func_quote_for_eval ${1+"$@"}
+-    libtool_options_prep_result=$func_quote_for_eval_result
++    if $_G_rc_lt_options_prep; then
++      # Pass back the list of options.
++      func_quote_for_eval ${1+"$@"}
++      libtool_options_prep_result=$func_quote_for_eval_result
++    fi
++
++    $_G_rc_lt_options_prep
+ }
+ func_add_hook func_options_prep libtool_options_prep
+ 
+@@ -397,9 +406,12 @@ libtool_parse_options ()
+ {
+     $debug_cmd
+ 
++    _G_rc_lt_parse_options=false
++
+     # Perform our own loop to consume as many options as possible in
+     # each iteration.
+     while test $# -gt 0; do
++      _G_match_lt_parse_options=:
+       _G_opt=$1
+       shift
+       case $_G_opt in
+@@ -474,15 +486,22 @@ libtool_parse_options ()
+                         func_append preserve_args " $_G_opt"
+                         ;;
+ 
+-	# An option not handled by this hook function:
+-        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
++        # An option not handled by this hook function:
++        *)              set dummy "$_G_opt" ${1+"$@"} ; shift
++                        _G_match_lt_parse_options=false
++                        break
++                        ;;
+       esac
++      $_G_match_lt_parse_options && _G_rc_lt_parse_options=:
+     done
+ 
++    if $_G_rc_lt_parse_options; then
++      # save modified positional parameters for caller
++      func_quote_for_eval ${1+"$@"}
++      libtool_parse_options_result=$func_quote_for_eval_result
++    fi
+ 
+-    # save modified positional parameters for caller
+-    func_quote_for_eval ${1+"$@"}
+-    libtool_parse_options_result=$func_quote_for_eval_result
++    $_G_rc_lt_parse_options
+ }
+ func_add_hook func_parse_options libtool_parse_options
+ 
+diff --git a/build-aux/options-parser b/build-aux/options-parser
+index d651f1d7..4c7e9cba 100644
+--- a/build-aux/options-parser
++++ b/build-aux/options-parser
+@@ -1,7 +1,7 @@
+ #! /bin/sh
+ 
+ # Set a version string for this script.
+-scriptversion=2014-01-07.03; # UTC
++scriptversion=2015-10-07.11; # UTC
+ 
+ # A portable, pluggable option parser for Bourne shell.
+ # Written by Gary V. Vaughan, 2010
+@@ -161,6 +161,8 @@ func_run_hooks ()
+ {
+     $debug_cmd
+ 
++    _G_rc_run_hooks=false
++
+     case " $hookable_fns " in
+       *" $1 "*) ;;
+       *) func_fatal_error "'$1' does not support hook funcions.n" ;;
+@@ -169,16 +171,16 @@ func_run_hooks ()
+     eval _G_hook_fns=\$$1_hooks; shift
+ 
+     for _G_hook in $_G_hook_fns; do
+-      eval $_G_hook '"$@"'
+-
+-      # store returned options list back into positional
+-      # parameters for next 'cmd' execution.
+-      eval _G_hook_result=\$${_G_hook}_result
+-      eval set dummy "$_G_hook_result"; shift
++      if eval $_G_hook '"$@"'; then
++        # store returned options list back into positional
++        # parameters for next 'cmd' execution.
++        eval _G_hook_result=\$${_G_hook}_result
++        eval set dummy "$_G_hook_result"; shift
++        _G_rc_run_hooks=:
++      fi
+     done
+ 
+-    func_quote_for_eval ${1+"$@"}
+-    func_run_hooks_result=$func_quote_for_eval_result
++    $_G_rc_run_hooks && func_run_hooks_result=$_G_hook_result
+ }
+ 
+ 
+@@ -188,10 +190,16 @@ func_run_hooks ()
+ ## --------------- ##
+ 
+ # In order to add your own option parsing hooks, you must accept the
+-# full positional parameter list in your hook function, remove any
+-# options that you action, and then pass back the remaining unprocessed
++# full positional parameter list in your hook function, you may remove/edit
++# any options that you action, and then pass back the remaining unprocessed
+ # options in '<hooked_function_name>_result', escaped suitably for
+-# 'eval'.  Like this:
++# 'eval'.  In this case you also must return $EXIT_SUCCESS to let the
++# hook's caller know that it should pay attention to
++# '<hooked_function_name>_result'.  Returning $EXIT_FAILURE signalizes that
++# arguments are left untouched by the hook and therefore caller will ignore the
++# result variable.
++#
++# Like this:
+ #
+ #    my_options_prep ()
+ #    {
+@@ -201,9 +209,11 @@ func_run_hooks ()
+ #        usage_message=$usage_message'
+ #      -s, --silent       don'\''t print informational messages
+ #    '
+-#
+-#        func_quote_for_eval ${1+"$@"}
+-#        my_options_prep_result=$func_quote_for_eval_result
++#        # No change in '$@' (ignored completely by this hook).  There is
++#        # no need to do the equivalent (but slower) action:
++#        # func_quote_for_eval ${1+"$@"}
++#        # my_options_prep_result=$func_quote_for_eval_result
++#        false
+ #    }
+ #    func_add_hook func_options_prep my_options_prep
+ #
+@@ -212,25 +222,37 @@ func_run_hooks ()
+ #    {
+ #        $debug_cmd
+ #
++#        args_changed=false
++#
+ #        # Note that for efficiency, we parse as many options as we can
+ #        # recognise in a loop before passing the remainder back to the
+ #        # caller on the first unrecognised argument we encounter.
+ #        while test $# -gt 0; do
+ #          opt=$1; shift
+ #          case $opt in
+-#            --silent|-s) opt_silent=: ;;
++#            --silent|-s) opt_silent=:
++#                         args_changed=:
++#                         ;;
+ #            # Separate non-argument short options:
+ #            -s*)         func_split_short_opt "$_G_opt"
+ #                         set dummy "$func_split_short_opt_name" \
+ #                             "-$func_split_short_opt_arg" ${1+"$@"}
+ #                         shift
++#                         args_changed=:
+ #                         ;;
+-#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
++#            *)           # Make sure the first unrecognised option "$_G_opt"
++#                         # is added back to "$@", we could need that later
++#                         # if $args_changed is true.
++#                         set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
+ #          esac
+ #        done
+ #
+-#        func_quote_for_eval ${1+"$@"}
+-#        my_silent_option_result=$func_quote_for_eval_result
++#        if $args_changed; then
++#          func_quote_for_eval ${1+"$@"}
++#          my_silent_option_result=$func_quote_for_eval_result
++#        fi
++#
++#        $args_changed
+ #    }
+ #    func_add_hook func_parse_options my_silent_option
+ #
+@@ -242,16 +264,32 @@ func_run_hooks ()
+ #        $opt_silent && $opt_verbose && func_fatal_help "\
+ #    '--silent' and '--verbose' options are mutually exclusive."
+ #
+-#        func_quote_for_eval ${1+"$@"}
+-#        my_option_validation_result=$func_quote_for_eval_result
++#        false
+ #    }
+ #    func_add_hook func_validate_options my_option_validation
+ #
+-# You'll alse need to manually amend $usage_message to reflect the extra
++# You'll also need to manually amend $usage_message to reflect the extra
+ # options you parse.  It's preferable to append if you can, so that
+ # multiple option parsing hooks can be added safely.
+ 
+ 
++# func_options_finish [ARG]...
++# ----------------------------
++# Finishing the option parse loop (call 'func_options' hooks ATM).
++func_options_finish ()
++{
++    $debug_cmd
++
++    _G_func_options_finish_exit=false
++    if func_run_hooks func_options ${1+"$@"}; then
++      func_options_finish_result=$func_run_hooks_result
++      _G_func_options_finish_exit=:
++    fi
++
++    $_G_func_options_finish_exit
++}
++
++
+ # func_options [ARG]...
+ # ---------------------
+ # All the functions called inside func_options are hookable. See the
+@@ -261,17 +299,28 @@ func_options ()
+ {
+     $debug_cmd
+ 
+-    func_options_prep ${1+"$@"}
+-    eval func_parse_options \
+-        ${func_options_prep_result+"$func_options_prep_result"}
+-    eval func_validate_options \
+-        ${func_parse_options_result+"$func_parse_options_result"}
++    _G_rc_options=false
+ 
+-    eval func_run_hooks func_options \
+-        ${func_validate_options_result+"$func_validate_options_result"}
++    for my_func in options_prep parse_options validate_options options_finish
++    do
++      if eval func_$my_func '${1+"$@"}'; then
++        eval _G_res_var='$'"func_${my_func}_result"
++        eval set dummy "$_G_res_var" ; shift
++        _G_rc_options=:
++      fi
++    done
+ 
+-    # save modified positional parameters for caller
+-    func_options_result=$func_run_hooks_result
++    # Save modified positional parameters for caller.  As a top-level
++    # options-parser function we always need to set the 'func_options_result'
++    # variable (regardless the $_G_rc_options value).
++    if $_G_rc_options; then
++      func_options_result=$_G_res_var
++    else
++      func_quote_for_eval ${1+"$@"}
++      func_options_result=$func_quote_for_eval_result
++    fi
++
++    $_G_rc_options
+ }
+ 
+ 
+@@ -280,9 +329,9 @@ func_options ()
+ # All initialisations required before starting the option parse loop.
+ # Note that when calling hook functions, we pass through the list of
+ # positional parameters.  If a hook function modifies that list, and
+-# needs to propogate that back to rest of this script, then the complete
++# needs to propagate that back to rest of this script, then the complete
+ # modified list must be put in 'func_run_hooks_result' before
+-# returning.
++# returning $EXIT_SUCCESS (otherwise $EXIT_FAILURE is returned).
+ func_hookable func_options_prep
+ func_options_prep ()
+ {
+@@ -292,10 +341,14 @@ func_options_prep ()
+     opt_verbose=false
+     opt_warning_types=
+ 
+-    func_run_hooks func_options_prep ${1+"$@"}
++    _G_rc_options_prep=false
++    if func_run_hooks func_options_prep ${1+"$@"}; then
++      _G_rc_options_prep=:
++      # save modified positional parameters for caller
++      func_options_prep_result=$func_run_hooks_result
++    fi
+ 
+-    # save modified positional parameters for caller
+-    func_options_prep_result=$func_run_hooks_result
++    $_G_rc_options_prep
+ }
+ 
+ 
+@@ -309,18 +362,20 @@ func_parse_options ()
+ 
+     func_parse_options_result=
+ 
++    _G_rc_parse_options=false
+     # this just eases exit handling
+     while test $# -gt 0; do
+       # Defer to hook functions for initial option parsing, so they
+       # get priority in the event of reusing an option name.
+-      func_run_hooks func_parse_options ${1+"$@"}
+-
+-      # Adjust func_parse_options positional parameters to match
+-      eval set dummy "$func_run_hooks_result"; shift
++      if func_run_hooks func_parse_options ${1+"$@"}; then
++        eval set dummy "$func_run_hooks_result"; shift
++        _G_rc_parse_options=:
++      fi
+ 
+       # Break out of the loop if we already parsed every option.
+       test $# -gt 0 || break
+ 
++      _G_match_parse_options=:
+       _G_opt=$1
+       shift
+       case $_G_opt in
+@@ -335,7 +390,10 @@ func_parse_options ()
+ 		      ;;
+ 
+         --warnings|--warning|-W)
+-                      test $# = 0 && func_missing_arg $_G_opt && break
++                      if test $# = 0 && func_missing_arg $_G_opt; then
++                        _G_rc_parse_options=:
++                        break
++                      fi
+                       case " $warning_categories $1" in
+                         *" $1 "*)
+                           # trailing space prevents matching last $1 above
+@@ -388,15 +446,25 @@ func_parse_options ()
+                       shift
+                       ;;
+ 
+-        --)           break ;;
++        --)           _G_rc_parse_options=: ; break ;;
+         -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
+-        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
++        *)            set dummy "$_G_opt" ${1+"$@"}; shift
++                      _G_match_parse_options=false
++                      break
++                      ;;
+       esac
++
++      $_G_match_parse_options && _G_rc_parse_options=:
+     done
+ 
+-    # save modified positional parameters for caller
+-    func_quote_for_eval ${1+"$@"}
+-    func_parse_options_result=$func_quote_for_eval_result
++
++    if $_G_rc_parse_options; then
++      # save modified positional parameters for caller
++      func_quote_for_eval ${1+"$@"}
++      func_parse_options_result=$func_quote_for_eval_result
++    fi
++
++    $_G_rc_parse_options
+ }
+ 
+ 
+@@ -409,16 +477,21 @@ func_validate_options ()
+ {
+     $debug_cmd
+ 
++    _G_rc_validate_options=false
++
+     # Display all warnings if -W was not given.
+     test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
+ 
+-    func_run_hooks func_validate_options ${1+"$@"}
++    if func_run_hooks func_validate_options ${1+"$@"}; then
++      # save modified positional parameters for caller
++      func_validate_options_result=$func_run_hooks_result
++      _G_rc_validate_options=:
++    fi
+ 
+     # Bail if the options were screwed!
+     $exit_cmd $EXIT_FAILURE
+ 
+-    # save modified positional parameters for caller
+-    func_validate_options_result=$func_run_hooks_result
++    $_G_rc_validate_options
+ }
+ 
+ 
+-- 
+2.11.0
+
diff -Nru libtool-2.4.6/debian/patches/0012-funclib-refactor-quoting-methods-a-bit.patch libtool-2.4.6/debian/patches/0012-funclib-refactor-quoting-methods-a-bit.patch
--- libtool-2.4.6/debian/patches/0012-funclib-refactor-quoting-methods-a-bit.patch	1970-01-01 01:00:00.000000000 +0100
+++ libtool-2.4.6/debian/patches/0012-funclib-refactor-quoting-methods-a-bit.patch	2018-01-19 11:37:19.000000000 +0100
@@ -0,0 +1,1258 @@
+From 9187e9a231e0a06cc29c336857e95f07f855b2c9 Mon Sep 17 00:00:00 2001
+From: Pavel Raiskup <prais...@redhat.com>
+Date: Sun, 11 Oct 2015 14:35:15 +0200
+Subject: [PATCH] funclib: refactor quoting methods a bit
+
+From now we have two basic functions to perform string quoting for
+shell evaluation -- 'func_quote_arg' to quote one argument and
+'func_quote' which takes list of arguments to be quoted.
+
+New function name-scheme should be more descriptive (previously we
+called func_quote_for_eval with one argument and also multiple
+arguments, while we had confusing
+$func_quote_for_eval_unquoted_result which is redundant for
+multiple-arguments call).
+
+New abstraction allowed us (in an easy way) to implement
+bash-specific optimization for quoting  (using
+'printf -v VARNAME %q "$value"', suggested by Eric Blake), this
+construct may be used on those places where we don't care much
+about the result aesthetics (its thus not useful for '*.la'
+generation or for error printing).
+
+* gl/build-aux/funclib.sh (func_append_quoted): Use
+func_quote_arg internally (kept in 'pretty' mode for now).
+(func_quote): Made to be "main" high-level quoting method taking
+list of arguments to be quoted into single command.  It replaces
+func_quote_for_{expand,eval}.
+(func_quote_portable): Implements quoting in shell, falling back
+to portable sed call (rare cases).
+(func_quotefast_eval): New internal function using fast
+bash-specific construct, falling back to func_quote_portable for
+non-Bash scripts.
+(func_quote_arg): New function to quote one argument.
+(func_quote_for_eval): Removed.  All callers changed to call
+func_quote.
+(func_quote_for_expand): Likewise.
+* bootstrap: Sync with funclib.sh and options-parser.
+---
+ bootstrap                   | 319 +++++++++++++++++++++++++-------------------
+ build-aux/ltmain.in         | 114 ++++++++--------
+ gl/build-aux/bootstrap.in   |  22 +--
+ gl/build-aux/funclib.sh     | 281 ++++++++++++++++++++++----------------
+ gl/build-aux/options-parser |  18 +--
+ gl/doc/bootstrap.texi       |   4 +-
+ libtoolize.in               |  18 +--
+ 7 files changed, 437 insertions(+), 339 deletions(-)
+
+diff --git a/bootstrap b/bootstrap
+index 4f000965..1d86ab02 100755
+--- a/bootstrap
++++ b/bootstrap
+@@ -230,7 +230,7 @@ vc_ignore=
+ 
+ # Source required external libraries:
+ # Set a version string for this script.
+-scriptversion=2015-10-04.22; # UTC
++scriptversion=2015-10-12.13; # UTC
+ 
+ # General shell script boiler plate, and helper functions.
+ # Written by Gary V. Vaughan, 2004
+@@ -746,16 +746,16 @@ if test yes = "$_G_HAVE_PLUSEQ_OP"; then
+   {
+     $debug_cmd
+ 
+-    func_quote_for_eval "$2"
+-    eval "$1+=\\ \$func_quote_for_eval_result"
++    func_quote_arg pretty "$2"
++    eval "$1+=\\ \$func_quote_arg_result"
+   }'
+ else
+   func_append_quoted ()
+   {
+     $debug_cmd
+ 
+-    func_quote_for_eval "$2"
+-    eval "$1=\$$1\\ \$func_quote_for_eval_result"
++    func_quote_arg pretty "$2"
++    eval "$1=\$$1\\ \$func_quote_arg_result"
+   }
+ fi
+ 
+@@ -1257,132 +1257,181 @@ 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 ()
++# func_quote_portable EVAL ARG
++# ----------------------------
++# Internal function to portably implement func_quote_arg.  Note that we still
++# keep attention to performance here so we as much as possible try to avoid
++# calling sed binary (so far O(N) complexity as long as func_append is O(1)).
++func_quote_portable ()
+ {
+     $debug_cmd
+ 
+-    func_quote_result=$1
++    func_quote_portable_result=$2
+ 
+-    case $func_quote_result in
+-      *[\\\`\"\$]*)
+-        case $func_quote_result in
+-          *'*'*|*'['*)
+-            func_quote_result=`$ECHO "$func_quote_result" | $SED "$sed_quote_subst"`
+-            return 0
+-            ;;
+-        esac
++    # one-time-loop (easy break)
++    while true
++    do
++      if $1; then
++        func_quote_portable_result=`$ECHO "$2" | $SED \
++          -e "$sed_double_quote_subst" -e "$sed_double_backslash"`
++        break
++      fi
+ 
+-        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=
++      # Quote for eval.
++      case $func_quote_portable_result in
++        *[\\\`\"\$]*)
++          case $func_quote_portable_result in
++            *[\[\*\?]*)
++              func_quote_portable_result=`$ECHO "$func_quote_portable_result" | $SED "$sed_quote_subst"`
++              break
+               ;;
+-            first)
+-              set quote "$_G_part" ""
+-              ;;
+-            esac
++          esac
++
++          func_quote_portable_old_IFS=$IFS
++          for _G_char in '\' '`' '"' '$'
++          do
++            # STATE($1) PREV($2) SEPARATOR($3)
++            set start "" ""
++            func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy
++            IFS=$_G_char
++            for _G_part in $func_quote_portable_result
++            do
++              case $1 in
++              quote)
++                func_append func_quote_portable_result "$3$2"
++                set quote "$_G_part" "\\$_G_char"
++                ;;
++              start)
++                set first "" ""
++                func_quote_portable_result=
++                ;;
++              first)
++                set quote "$_G_part" ""
++                ;;
++              esac
++            done
+           done
+-          IFS=$func_quote_old_IFS
+-        done
++          IFS=$func_quote_portable_old_IFS
++          ;;
++        *) ;;
++      esac
++      break
++    done
++
++    func_quote_portable_unquoted_result=$func_quote_portable_result
++    case $func_quote_portable_result in
++      # double-quote args containing shell metacharacters to delay
++      # word splitting, command substitution and variable expansion
++      # for a subsequent eval.
++      # many bourne shells cannot handle close brackets correctly
++      # in scan sets, so we specify it separately.
++      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
++        func_quote_portable_result=\"$func_quote_portable_result\"
+         ;;
+-      *) ;;
+     esac
+ }
+ 
+ 
+-# func_quote_for_eval ARG...
+-# --------------------------
+-# Aesthetically quote ARGs to be evaled later.
+-# This function returns two values:
+-#   i) func_quote_for_eval_result
+-#      double-quoted, suitable for a subsequent eval
+-#  ii) func_quote_for_eval_unquoted_result
+-#      has all characters that are still active within double
+-#      quotes backslashified.
+-func_quote_for_eval ()
+-{
+-    $debug_cmd
++# func_quotefast_eval ARG
++# -----------------------
++# Quote one ARG (internal).  This is equivalent to 'func_quote_arg eval ARG',
++# but optimized for speed.  Result is stored in $func_quotefast_eval.
++if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
++  func_quotefast_eval ()
++  {
++    printf -v func_quotefast_eval_result %q "$1"
++  }
++else
++  func_quotefast_eval ()
++  {
++    func_quote_portable false "$1"
++    func_quotefast_eval_result=$func_quote_portable_result
++  }
++fi
+ 
+-    func_quote_for_eval_unquoted_result=
+-    func_quote_for_eval_result=
+-    while test 0 -lt $#; do
+-      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
+-        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
+-      fi
+ 
+-      case $_G_unquoted_arg in
+-        # Double-quote args containing shell metacharacters to delay
+-        # word splitting, command substitution and variable expansion
+-        # for a subsequent eval.
+-        # Many Bourne shells cannot handle close brackets correctly
+-        # in scan sets, so we specify it separately.
+-        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+-          _G_quoted_arg=\"$_G_unquoted_arg\"
+-          ;;
+-        *)
+-          _G_quoted_arg=$_G_unquoted_arg
+-	  ;;
+-      esac
++# func_quote_arg MODEs ARG
++# ------------------------
++# Quote one ARG to be evaled later.  MODEs argument may contain zero ore more
++# specifiers listed below separated by ',' character.  This function returns two
++# values:
++#   i) func_quote_arg_result
++#      double-quoted (when needed), suitable for a subsequent eval
++#  ii) func_quote_arg_unquoted_result
++#      has all characters that are still active within double
++#      quotes backslashified.  Available only if 'unquoted' is specified.
++#
++# Available modes:
++# ----------------
++# 'eval' (default)
++#       - escape shell special characters
++# 'expand'
++#       - the same as 'eval';  but do not quote variable references
++# 'pretty'
++#       - request aesthetic output, i.e. '"a b"' instead of 'a\ b'.  This might
++#         later used in func_quote to get output like: 'echo "a b"' instead of
++#         'echo a\ b'.  This is slower than default on some shells.
++# 'unquoted'
++#       - produce also $func_quote_arg_unquoted_result which does not contain
++#         wrapping double-quotes.
++#
++# Examples for 'func_quote_arg pretty,unquoted string':
++#
++#   string      | *_result              | *_unquoted_result
++#   ------------+-----------------------+-------------------
++#   "           | \"                    | \"
++#   a b         | "a b"                 | a b
++#   "a b"       | "\"a b\""             | \"a b\"
++#   *           | "*"                   | *
++#   z="${x-$y}" | "z=\"\${x-\$y}\""     | z=\"\${x-\$y}\"
++#
++# Examples for 'func_quote_arg pretty,unquoted,expand string':
++#
++#   string        |   *_result          |  *_unquoted_result
++#   --------------+---------------------+--------------------
++#   z="${x-$y}"   | "z=\"${x-$y}\""     | z=\"${x-$y}\"
++func_quote_arg ()
++{
++    _G_quote_expand=false
++    case ,$1, in
++      *,expand,*)
++        _G_quote_expand=:
++        ;;
++    esac
+ 
+-      if test -n "$func_quote_for_eval_result"; then
+-	func_append func_quote_for_eval_result " $_G_quoted_arg"
+-      else
+-        func_append func_quote_for_eval_result "$_G_quoted_arg"
+-      fi
+-      shift
+-    done
++    case ,$1, in
++      *,pretty,*|*,expand,*|*,unquoted,*)
++        func_quote_portable $_G_quote_expand "$2"
++        func_quote_arg_result=$func_quote_portable_result
++        func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result
++        ;;
++      *)
++        # Faster quote-for-eval for some shells.
++        func_quotefast_eval "$2"
++        func_quote_arg_result=$func_quotefast_eval_result
++        ;;
++    esac
+ }
+ 
+ 
+-# func_quote_for_expand ARG
+-# -------------------------
+-# Aesthetically quote ARG to be evaled later; same as above,
+-# but do not quote variable references.
+-func_quote_for_expand ()
++# func_quote MODEs ARGs...
++# ------------------------
++# Quote all ARGs to be evaled later and join them into single command.  See
++# func_quote_arg's description for more info.
++func_quote ()
+ {
+     $debug_cmd
+-
+-    case $1 in
+-      *[\\\`\"]*)
+-	_G_arg=`$ECHO "$1" | $SED \
+-	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
+-      *)
+-        _G_arg=$1 ;;
+-    esac
+-
+-    case $_G_arg in
+-      # Double-quote args containing shell metacharacters to delay
+-      # word splitting and command substitution for a subsequent eval.
+-      # Many Bourne shells cannot handle close brackets correctly
+-      # in scan sets, so we specify it separately.
+-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+-        _G_arg=\"$_G_arg\"
+-        ;;
+-    esac
+-
+-    func_quote_for_expand_result=$_G_arg
++    _G_func_quote_mode=$1 ; shift
++    func_quote_result=
++    while test 0 -lt $#; do
++      func_quote_arg "$_G_func_quote_mode" "$1"
++      if test -n "$func_quote_result"; then
++        func_append func_quote_result " $func_quote_arg_result"
++      else
++        func_append func_quote_result "$func_quote_arg_result"
++      fi
++      shift
++    done
+ }
+ 
+ 
+@@ -1428,8 +1477,8 @@ func_show_eval ()
+     _G_cmd=$1
+     _G_fail_exp=${2-':'}
+ 
+-    func_quote_for_expand "$_G_cmd"
+-    eval "func_notquiet $func_quote_for_expand_result"
++    func_quote_arg pretty,expand "$_G_cmd"
++    eval "func_notquiet $func_quote_arg_result"
+ 
+     $opt_dry_run || {
+       eval "$_G_cmd"
+@@ -1454,8 +1503,8 @@ func_show_eval_locale ()
+     _G_fail_exp=${2-':'}
+ 
+     $opt_quiet || {
+-      func_quote_for_expand "$_G_cmd"
+-      eval "func_echo $func_quote_for_expand_result"
++      func_quote_arg expand,pretty "$_G_cmd"
++      eval "func_echo $func_quote_arg_result"
+     }
+ 
+     $opt_dry_run || {
+@@ -1583,7 +1632,7 @@ func_lt_ver ()
+ #! /bin/sh
+ 
+ # Set a version string for this script.
+-scriptversion=2015-10-07.11; # UTC
++scriptversion=2015-10-12.13; # UTC
+ 
+ # A portable, pluggable option parser for Bourne shell.
+ # Written by Gary V. Vaughan, 2010
+@@ -1793,8 +1842,8 @@ func_run_hooks ()
+ #    '
+ #        # No change in '$@' (ignored completely by this hook).  There is
+ #        # no need to do the equivalent (but slower) action:
+-#        # func_quote_for_eval ${1+"$@"}
+-#        # my_options_prep_result=$func_quote_for_eval_result
++#        # func_quote eval ${1+"$@"}
++#        # my_options_prep_result=$func_quote_result
+ #        false
+ #    }
+ #    func_add_hook func_options_prep my_options_prep
+@@ -1830,8 +1879,8 @@ func_run_hooks ()
+ #        done
+ #
+ #        if $args_changed; then
+-#          func_quote_for_eval ${1+"$@"}
+-#          my_silent_option_result=$func_quote_for_eval_result
++#          func_quote eval ${1+"$@"}
++#          my_silent_option_result=$func_quote_result
+ #        fi
+ #
+ #        $args_changed
+@@ -1898,8 +1947,8 @@ func_options ()
+     if $_G_rc_options; then
+       func_options_result=$_G_res_var
+     else
+-      func_quote_for_eval ${1+"$@"}
+-      func_options_result=$func_quote_for_eval_result
++      func_quote eval ${1+"$@"}
++      func_options_result=$func_quote_result
+     fi
+ 
+     $_G_rc_options
+@@ -2042,8 +2091,8 @@ func_parse_options ()
+ 
+     if $_G_rc_parse_options; then
+       # save modified positional parameters for caller
+-      func_quote_for_eval ${1+"$@"}
+-      func_parse_options_result=$func_quote_for_eval_result
++      func_quote eval ${1+"$@"}
++      func_parse_options_result=$func_quote_result
+     fi
+ 
+     $_G_rc_parse_options
+@@ -2753,7 +2802,7 @@ test extract-trace = "$progname" && func_main "$@"
+ # End:
+ 
+ # Set a version string for *this* script.
+-scriptversion=2015-01-20.17; # UTC
++scriptversion=2015-10-12.13; # UTC
+ 
+ 
+ ## ------------------- ##
+@@ -2781,8 +2830,8 @@ func_bootstrap ()
+ 
+     # Save the current positional parameters to prevent them being
+     # corrupted by calls to 'set' in 'func_init'.
+-    func_quote_for_eval ${1+"$@"}
+-    _G_saved_positional_parameters=$func_quote_for_eval_result
++    func_quote eval ${1+"$@"}
++    _G_saved_positional_parameters=$func_quote_result
+ 
+     # Initialisation.
+     func_init
+@@ -4821,8 +4870,8 @@ func_show_eval ()
+     _G_fail_exp=${2-':'}
+ 
+     ${opt_silent-'false'} || {
+-      func_quote_for_eval $_G_cmd
+-      eval func_truncate_cmd $func_quote_for_eval_result
++      func_quote eval $_G_cmd
++      eval func_truncate_cmd $func_quote_result
+       func_echo "running: $tc_bold$func_truncate_cmd_result$tc_reset"
+     }
+ 
+@@ -5209,8 +5258,8 @@ bootstrap_options_prep ()
+     opt_skip_po=false
+ 
+     # Pass back the list of options we consumed.
+-    func_quote_for_eval ${1+"$@"}
+-    bootstrap_options_prep_result=$func_quote_for_eval_result
++    func_quote eval ${1+"$@"}
++    bootstrap_options_prep_result=$func_quote_result
+ }
+ func_add_hook func_options_prep bootstrap_options_prep
+ 
+@@ -5260,8 +5309,8 @@ bootstrap_parse_options ()
+     done
+ 
+     # save modified positional parameters for caller
+-    func_quote_for_eval ${1+"$@"}
+-    bootstrap_parse_options_result=$func_quote_for_eval_result
++    func_quote eval ${1+"$@"}
++    bootstrap_parse_options_result=$func_quote_result
+ }
+ func_add_hook func_parse_options bootstrap_parse_options
+ 
+@@ -5279,8 +5328,8 @@ bootstrap_validate_options ()
+         && func_fatal_help "too many arguments"
+ 
+     # Pass back the (empty) list of unconsumed options.
+-    func_quote_for_eval ${1+"$@"}
+-    bootstrap_validate_options_result=$func_quote_for_eval_result
++    func_quote eval ${1+"$@"}
++    bootstrap_validate_options_result=$func_quote_result
+ }
+ func_add_hook func_validate_options bootstrap_validate_options
+ 
+diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
+index b4c6bcd6..1cbe875d 100644
+--- a/build-aux/ltmain.in
++++ b/build-aux/ltmain.in
+@@ -390,8 +390,8 @@ libtool_options_prep ()
+ 
+     if $_G_rc_lt_options_prep; then
+       # Pass back the list of options.
+-      func_quote_for_eval ${1+"$@"}
+-      libtool_options_prep_result=$func_quote_for_eval_result
++      func_quote eval ${1+"$@"}
++      libtool_options_prep_result=$func_quote_result
+     fi
+ 
+     $_G_rc_lt_options_prep
+@@ -497,8 +497,8 @@ libtool_parse_options ()
+ 
+     if $_G_rc_lt_parse_options; then
+       # save modified positional parameters for caller
+-      func_quote_for_eval ${1+"$@"}
+-      libtool_parse_options_result=$func_quote_for_eval_result
++      func_quote eval ${1+"$@"}
++      libtool_parse_options_result=$func_quote_result
+     fi
+ 
+     $_G_rc_lt_parse_options
+@@ -558,8 +558,8 @@ libtool_validate_options ()
+     }
+ 
+     # Pass back the unparsed argument list
+-    func_quote_for_eval ${1+"$@"}
+-    libtool_validate_options_result=$func_quote_for_eval_result
++    func_quote eval ${1+"$@"}
++    libtool_validate_options_result=$func_quote_result
+ }
+ func_add_hook func_validate_options libtool_validate_options
+ 
+@@ -1525,8 +1525,8 @@ func_mode_compile ()
+       esac
+     done
+ 
+-    func_quote_for_eval "$libobj"
+-    test "X$libobj" != "X$func_quote_for_eval_result" \
++    func_quote_arg pretty "$libobj"
++    test "X$libobj" != "X$func_quote_arg_result" \
+       && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
+       && func_warning "libobj name '$libobj' may not contain shell special characters."
+     func_dirname_and_basename "$obj" "/" ""
+@@ -1599,8 +1599,8 @@ compiler."
+ 
+     func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
+     srcfile=$func_to_tool_file_result
+-    func_quote_for_eval "$srcfile"
+-    qsrcfile=$func_quote_for_eval_result
++    func_quote_arg pretty "$srcfile"
++    qsrcfile=$func_quote_arg_result
+ 
+     # Only build a PIC object if we are building libtool libraries.
+     if test yes = "$build_libtool_libs"; then
+@@ -2203,8 +2203,8 @@ func_mode_install ()
+        case $nonopt in *shtool*) :;; *) false;; esac
+     then
+       # Aesthetically quote it.
+-      func_quote_for_eval "$nonopt"
+-      install_prog="$func_quote_for_eval_result "
++      func_quote_arg pretty "$nonopt"
++      install_prog="$func_quote_arg_result "
+       arg=$1
+       shift
+     else
+@@ -2214,8 +2214,8 @@ func_mode_install ()
+ 
+     # The real first argument should be the name of the installation program.
+     # Aesthetically quote it.
+-    func_quote_for_eval "$arg"
+-    func_append install_prog "$func_quote_for_eval_result"
++    func_quote_arg pretty "$arg"
++    func_append install_prog "$func_quote_arg_result"
+     install_shared_prog=$install_prog
+     case " $install_prog " in
+       *[\\\ /]cp\ *) install_cp=: ;;
+@@ -2272,12 +2272,12 @@ func_mode_install ()
+       esac
+ 
+       # Aesthetically quote the argument.
+-      func_quote_for_eval "$arg"
+-      func_append install_prog " $func_quote_for_eval_result"
++      func_quote_arg pretty "$arg"
++      func_append install_prog " $func_quote_arg_result"
+       if test -n "$arg2"; then
+-	func_quote_for_eval "$arg2"
++	func_quote_arg pretty "$arg2"
+       fi
+-      func_append install_shared_prog " $func_quote_for_eval_result"
++      func_append install_shared_prog " $func_quote_arg_result"
+     done
+ 
+     test -z "$install_prog" && \
+@@ -2288,8 +2288,8 @@ func_mode_install ()
+ 
+     if test -n "$install_override_mode" && $no_mode; then
+       if $install_cp; then :; else
+-	func_quote_for_eval "$install_override_mode"
+-	func_append install_shared_prog " -m $func_quote_for_eval_result"
++	func_quote_arg pretty "$install_override_mode"
++	func_append install_shared_prog " -m $func_quote_arg_result"
+       fi
+     fi
+ 
+@@ -2585,8 +2585,8 @@ func_mode_install ()
+ 	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
+ 
+ 	        $opt_quiet || {
+-	          func_quote_for_expand "$relink_command"
+-		  eval "func_echo $func_quote_for_expand_result"
++	          func_quote_arg expand,pretty "$relink_command"
++		  eval "func_echo $func_quote_arg_result"
+ 	        }
+ 	        if eval "$relink_command"; then :
+ 	          else
+@@ -3365,8 +3365,8 @@ else
+   if test \"\$libtool_execute_magic\" != \"$magic\"; then
+     file=\"\$0\""
+ 
+-    func_quote "$ECHO"
+-    qECHO=$func_quote_result
++    func_quote_arg pretty "$ECHO"
++    qECHO=$func_quote_arg_result
+     $ECHO "\
+ 
+ # A function that is used when there is no print builtin or printf.
+@@ -3376,7 +3376,7 @@ func_fallback_echo ()
+ \$1
+ _LTECHO_EOF'
+ }
+-    ECHO=\"$qECHO\"
++    ECHO=$qECHO
+   fi
+ 
+ # Very basic option parsing. These options are (a) specific to
+@@ -4719,9 +4719,9 @@ func_mode_link ()
+     while test "$#" -gt 0; do
+       arg=$1
+       shift
+-      func_quote_for_eval "$arg"
+-      qarg=$func_quote_for_eval_unquoted_result
+-      func_append libtool_args " $func_quote_for_eval_result"
++      func_quote_arg pretty,unquoted "$arg"
++      qarg=$func_quote_arg_unquoted_result
++      func_append libtool_args " $func_quote_arg_result"
+ 
+       # If the previous option needs an argument, assign it.
+       if test -n "$prev"; then
+@@ -5319,9 +5319,9 @@ func_mode_link ()
+ 	save_ifs=$IFS; IFS=,
+ 	for flag in $args; do
+ 	  IFS=$save_ifs
+-          func_quote_for_eval "$flag"
+-	  func_append arg " $func_quote_for_eval_result"
+-	  func_append compiler_flags " $func_quote_for_eval_result"
++          func_quote_arg pretty "$flag"
++	  func_append arg " $func_quote_arg_result"
++	  func_append compiler_flags " $func_quote_arg_result"
+ 	done
+ 	IFS=$save_ifs
+ 	func_stripname ' ' '' "$arg"
+@@ -5335,10 +5335,10 @@ func_mode_link ()
+ 	save_ifs=$IFS; IFS=,
+ 	for flag in $args; do
+ 	  IFS=$save_ifs
+-          func_quote_for_eval "$flag"
+-	  func_append arg " $wl$func_quote_for_eval_result"
+-	  func_append compiler_flags " $wl$func_quote_for_eval_result"
+-	  func_append linker_flags " $func_quote_for_eval_result"
++          func_quote_arg pretty "$flag"
++	  func_append arg " $wl$func_quote_arg_result"
++	  func_append compiler_flags " $wl$func_quote_arg_result"
++	  func_append linker_flags " $func_quote_arg_result"
+ 	done
+ 	IFS=$save_ifs
+ 	func_stripname ' ' '' "$arg"
+@@ -5362,8 +5362,8 @@ func_mode_link ()
+ 
+       # -msg_* for osf cc
+       -msg_*)
+-	func_quote_for_eval "$arg"
+-	arg=$func_quote_for_eval_result
++	func_quote_arg pretty "$arg"
++	arg=$func_quote_arg_result
+ 	;;
+ 
+       # Flags to be passed through unchanged, with rationale:
+@@ -5386,8 +5386,8 @@ func_mode_link ()
+       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
+       -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
+       -specs=*)
+-        func_quote_for_eval "$arg"
+-	arg=$func_quote_for_eval_result
++        func_quote_arg pretty "$arg"
++	arg=$func_quote_arg_result
+         func_append compile_command " $arg"
+         func_append finalize_command " $arg"
+         func_append compiler_flags " $arg"
+@@ -5408,15 +5408,15 @@ func_mode_link ()
+ 	  continue
+         else
+ 	  # Otherwise treat like 'Some other compiler flag' below
+-	  func_quote_for_eval "$arg"
+-	  arg=$func_quote_for_eval_result
++	  func_quote_arg pretty "$arg"
++	  arg=$func_quote_arg_result
+         fi
+ 	;;
+ 
+       # Some other compiler flag.
+       -* | +*)
+-        func_quote_for_eval "$arg"
+-	arg=$func_quote_for_eval_result
++        func_quote_arg pretty "$arg"
++	arg=$func_quote_arg_result
+ 	;;
+ 
+       *.$objext)
+@@ -5536,8 +5536,8 @@ func_mode_link ()
+       *)
+ 	# Unknown arguments in both finalize_command and compile_command need
+ 	# to be aesthetically quoted because they are evaled later.
+-	func_quote_for_eval "$arg"
+-	arg=$func_quote_for_eval_result
++	func_quote_arg pretty "$arg"
++	arg=$func_quote_arg_result
+ 	;;
+       esac # arg
+ 
+@@ -8043,8 +8043,8 @@ EOF
+ 	    for cmd in $concat_cmds; do
+ 	      IFS=$save_ifs
+ 	      $opt_quiet || {
+-		  func_quote_for_expand "$cmd"
+-		  eval "func_echo $func_quote_for_expand_result"
++		  func_quote_arg expand,pretty "$cmd"
++		  eval "func_echo $func_quote_arg_result"
+ 	      }
+ 	      $opt_dry_run || eval "$cmd" || {
+ 		lt_exit=$?
+@@ -8137,8 +8137,8 @@ EOF
+ 	  eval cmd=\"$cmd\"
+ 	  IFS=$save_ifs
+ 	  $opt_quiet || {
+-	    func_quote_for_expand "$cmd"
+-	    eval "func_echo $func_quote_for_expand_result"
++	    func_quote_arg expand,pretty "$cmd"
++	    eval "func_echo $func_quote_arg_result"
+ 	  }
+ 	  $opt_dry_run || eval "$cmd" || {
+ 	    lt_exit=$?
+@@ -8612,12 +8612,12 @@ EOF
+ 	  elif eval var_value=\$$var; test -z "$var_value"; then
+ 	    relink_command="$var=; export $var; $relink_command"
+ 	  else
+-	    func_quote_for_eval "$var_value"
+-	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
++	    func_quote_arg pretty "$var_value"
++	    relink_command="$var=$func_quote_arg_result; export $var; $relink_command"
+ 	  fi
+ 	done
+-	func_quote "(cd `pwd`; $relink_command)"
+-	relink_command=$func_quote_result
++	func_quote_arg pretty,unquoted "(cd `pwd`; $relink_command)"
++	relink_command=$func_quote_arg_unquoted_result
+       fi
+ 
+       # Only actually do things if not in dry run mode.
+@@ -8857,14 +8857,14 @@ EOF
+ 	elif eval var_value=\$$var; test -z "$var_value"; then
+ 	  relink_command="$var=; export $var; $relink_command"
+ 	else
+-	  func_quote_for_eval "$var_value"
+-	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
++	  func_quote_arg pretty,unquoted "$var_value"
++	  relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command"
+ 	fi
+       done
+       # Quote the link command for shipping.
+       relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+-      func_quote "$relink_command"
+-      relink_command=$func_quote_result
++      func_quote_arg pretty,unquoted "$relink_command"
++      relink_command=$func_quote_arg_unquoted_result
+       if test yes = "$hardcode_automatic"; then
+ 	relink_command=
+       fi
+diff --git a/build-aux/funclib.sh b/build-aux/funclib.sh
+index 47d8b95a..2c22db17 100644
+--- a/build-aux/funclib.sh
++++ b/build-aux/funclib.sh
+@@ -1,5 +1,5 @@
+ # Set a version string for this script.
+-scriptversion=2015-10-04.22; # UTC
++scriptversion=2015-10-12.13; # UTC
+ 
+ # General shell script boiler plate, and helper functions.
+ # Written by Gary V. Vaughan, 2004
+@@ -515,16 +515,16 @@ if test yes = "$_G_HAVE_PLUSEQ_OP"; then
+   {
+     $debug_cmd
+ 
+-    func_quote_for_eval "$2"
+-    eval "$1+=\\ \$func_quote_for_eval_result"
++    func_quote_arg pretty "$2"
++    eval "$1+=\\ \$func_quote_arg_result"
+   }'
+ else
+   func_append_quoted ()
+   {
+     $debug_cmd
+ 
+-    func_quote_for_eval "$2"
+-    eval "$1=\$$1\\ \$func_quote_for_eval_result"
++    func_quote_arg pretty "$2"
++    eval "$1=\$$1\\ \$func_quote_arg_result"
+   }
+ fi
+ 
+@@ -1026,135 +1026,184 @@ 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 ()
++# func_quote_portable EVAL ARG
++# ----------------------------
++# Internal function to portably implement func_quote_arg.  Note that we still
++# keep attention to performance here so we as much as possible try to avoid
++# calling sed binary (so far O(N) complexity as long as func_append is O(1)).
++func_quote_portable ()
+ {
+     $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" ""
++    func_quote_portable_result=$2
++
++    # one-time-loop (easy break)
++    while true
++    do
++      if $1; then
++        func_quote_portable_result=`$ECHO "$2" | $SED \
++          -e "$sed_double_quote_subst" -e "$sed_double_backslash"`
++        break
++      fi
++
++      # Quote for eval.
++      case $func_quote_portable_result in
++        *[\\\`\"\$]*)
++          case $func_quote_portable_result in
++            *[\[\*\?]*)
++              func_quote_portable_result=`$ECHO "$func_quote_portable_result" | $SED "$sed_quote_subst"`
++              break
+               ;;
+-            esac
++          esac
++
++          func_quote_portable_old_IFS=$IFS
++          for _G_char in '\' '`' '"' '$'
++          do
++            # STATE($1) PREV($2) SEPARATOR($3)
++            set start "" ""
++            func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy
++            IFS=$_G_char
++            for _G_part in $func_quote_portable_result
++            do
++              case $1 in
++              quote)
++                func_append func_quote_portable_result "$3$2"
++                set quote "$_G_part" "\\$_G_char"
++                ;;
++              start)
++                set first "" ""
++                func_quote_portable_result=
++                ;;
++              first)
++                set quote "$_G_part" ""
++                ;;
++              esac
++            done
+           done
+-          IFS=$func_quote_old_IFS
+-        done
++          IFS=$func_quote_portable_old_IFS
++          ;;
++        *) ;;
++      esac
++      break
++    done
++
++    func_quote_portable_unquoted_result=$func_quote_portable_result
++    case $func_quote_portable_result in
++      # double-quote args containing shell metacharacters to delay
++      # word splitting, command substitution and variable expansion
++      # for a subsequent eval.
++      # many bourne shells cannot handle close brackets correctly
++      # in scan sets, so we specify it separately.
++      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
++        func_quote_portable_result=\"$func_quote_portable_result\"
+         ;;
+-      *) ;;
+     esac
+ }
+ 
+ 
+-# func_quote_for_eval ARG...
+-# --------------------------
+-# Aesthetically quote ARGs to be evaled later.
+-# This function returns two values:
+-#   i) func_quote_for_eval_result
+-#      double-quoted, suitable for a subsequent eval
+-#  ii) func_quote_for_eval_unquoted_result
++# func_quotefast_eval ARG
++# -----------------------
++# Quote one ARG (internal).  This is equivalent to 'func_quote_arg eval ARG',
++# but optimized for speed.  Result is stored in $func_quotefast_eval.
++if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
++  func_quotefast_eval ()
++  {
++    printf -v func_quotefast_eval_result %q "$1"
++  }
++else
++  func_quotefast_eval ()
++  {
++    func_quote_portable false "$1"
++    func_quotefast_eval_result=$func_quote_portable_result
++  }
++fi
++
++
++# func_quote_arg MODEs ARG
++# ------------------------
++# Quote one ARG to be evaled later.  MODEs argument may contain zero ore more
++# specifiers listed below separated by ',' character.  This function returns two
++# values:
++#   i) func_quote_arg_result
++#      double-quoted (when needed), suitable for a subsequent eval
++#  ii) func_quote_arg_unquoted_result
+ #      has all characters that are still active within double
+-#      quotes backslashified.
+-func_quote_for_eval ()
++#      quotes backslashified.  Available only if 'unquoted' is specified.
++#
++# Available modes:
++# ----------------
++# 'eval' (default)
++#       - escape shell special characters
++# 'expand'
++#       - the same as 'eval';  but do not quote variable references
++# 'pretty'
++#       - request aesthetic output, i.e. '"a b"' instead of 'a\ b'.  This might
++#         later used in func_quote to get output like: 'echo "a b"' instead of
++#         'echo a\ b'.  This is slower than default on some shells.
++# 'unquoted'
++#       - produce also $func_quote_arg_unquoted_result which does not contain
++#         wrapping double-quotes.
++#
++# Examples for 'func_quote_arg pretty,unquoted string':
++#
++#   string      | *_result              | *_unquoted_result
++#   ------------+-----------------------+-------------------
++#   "           | \"                    | \"
++#   a b         | "a b"                 | a b
++#   "a b"       | "\"a b\""             | \"a b\"
++#   *           | "*"                   | *
++#   z="${x-$y}" | "z=\"\${x-\$y}\""     | z=\"\${x-\$y}\"
++#
++# Examples for 'func_quote_arg pretty,unquoted,expand string':
++#
++#   string        |   *_result          |  *_unquoted_result
++#   --------------+---------------------+--------------------
++#   z="${x-$y}"   | "z=\"${x-$y}\""     | z=\"${x-$y}\"
++func_quote_arg ()
+ {
+-    $debug_cmd
++    _G_quote_expand=false
++    case ,$1, in
++      *,expand,*)
++        _G_quote_expand=:
++        ;;
++    esac
+ 
+-    func_quote_for_eval_unquoted_result=
+-    func_quote_for_eval_result=
+-    while test 0 -lt $#; do
+-      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
+-        func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
+-      fi
++    case ,$1, in
++      *,pretty,*|*,expand,*|*,unquoted,*)
++        func_quote_portable $_G_quote_expand "$2"
++        func_quote_arg_result=$func_quote_portable_result
++        func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result
++        ;;
++      *)
++        # Faster quote-for-eval for some shells.
++        func_quotefast_eval "$2"
++        func_quote_arg_result=$func_quotefast_eval_result
++        ;;
++    esac
++}
+ 
+-      case $_G_unquoted_arg in
+-        # Double-quote args containing shell metacharacters to delay
+-        # word splitting, command substitution and variable expansion
+-        # for a subsequent eval.
+-        # Many Bourne shells cannot handle close brackets correctly
+-        # in scan sets, so we specify it separately.
+-        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+-          _G_quoted_arg=\"$_G_unquoted_arg\"
+-          ;;
+-        *)
+-          _G_quoted_arg=$_G_unquoted_arg
+-	  ;;
+-      esac
+ 
+-      if test -n "$func_quote_for_eval_result"; then
+-	func_append func_quote_for_eval_result " $_G_quoted_arg"
++# func_quote MODEs ARGs...
++# ------------------------
++# Quote all ARGs to be evaled later and join them into single command.  See
++# func_quote_arg's description for more info.
++func_quote ()
++{
++    $debug_cmd
++    _G_func_quote_mode=$1 ; shift
++    func_quote_result=
++    while test 0 -lt $#; do
++      func_quote_arg "$_G_func_quote_mode" "$1"
++      if test -n "$func_quote_result"; then
++        func_append func_quote_result " $func_quote_arg_result"
+       else
+-        func_append func_quote_for_eval_result "$_G_quoted_arg"
++        func_append func_quote_result "$func_quote_arg_result"
+       fi
+       shift
+     done
+ }
+ 
+ 
+-# func_quote_for_expand ARG
+-# -------------------------
+-# Aesthetically quote ARG to be evaled later; same as above,
+-# but do not quote variable references.
+-func_quote_for_expand ()
+-{
+-    $debug_cmd
+-
+-    case $1 in
+-      *[\\\`\"]*)
+-	_G_arg=`$ECHO "$1" | $SED \
+-	    -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
+-      *)
+-        _G_arg=$1 ;;
+-    esac
+-
+-    case $_G_arg in
+-      # Double-quote args containing shell metacharacters to delay
+-      # word splitting and command substitution for a subsequent eval.
+-      # Many Bourne shells cannot handle close brackets correctly
+-      # in scan sets, so we specify it separately.
+-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+-        _G_arg=\"$_G_arg\"
+-        ;;
+-    esac
+-
+-    func_quote_for_expand_result=$_G_arg
+-}
+-
+-
+ # func_stripname PREFIX SUFFIX NAME
+ # ---------------------------------
+ # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
+@@ -1197,8 +1246,8 @@ func_show_eval ()
+     _G_cmd=$1
+     _G_fail_exp=${2-':'}
+ 
+-    func_quote_for_expand "$_G_cmd"
+-    eval "func_notquiet $func_quote_for_expand_result"
++    func_quote_arg pretty,expand "$_G_cmd"
++    eval "func_notquiet $func_quote_arg_result"
+ 
+     $opt_dry_run || {
+       eval "$_G_cmd"
+@@ -1223,8 +1272,8 @@ func_show_eval_locale ()
+     _G_fail_exp=${2-':'}
+ 
+     $opt_quiet || {
+-      func_quote_for_expand "$_G_cmd"
+-      eval "func_echo $func_quote_for_expand_result"
++      func_quote_arg expand,pretty "$_G_cmd"
++      eval "func_echo $func_quote_arg_result"
+     }
+ 
+     $opt_dry_run || {
+diff --git a/build-aux/options-parser b/build-aux/options-parser
+index 4c7e9cba..c2bf9b48 100644
+--- a/build-aux/options-parser
++++ b/build-aux/options-parser
+@@ -1,7 +1,7 @@
+ #! /bin/sh
+ 
+ # Set a version string for this script.
+-scriptversion=2015-10-07.11; # UTC
++scriptversion=2015-10-12.13; # UTC
+ 
+ # A portable, pluggable option parser for Bourne shell.
+ # Written by Gary V. Vaughan, 2010
+@@ -211,8 +211,8 @@ func_run_hooks ()
+ #    '
+ #        # No change in '$@' (ignored completely by this hook).  There is
+ #        # no need to do the equivalent (but slower) action:
+-#        # func_quote_for_eval ${1+"$@"}
+-#        # my_options_prep_result=$func_quote_for_eval_result
++#        # func_quote eval ${1+"$@"}
++#        # my_options_prep_result=$func_quote_result
+ #        false
+ #    }
+ #    func_add_hook func_options_prep my_options_prep
+@@ -248,8 +248,8 @@ func_run_hooks ()
+ #        done
+ #
+ #        if $args_changed; then
+-#          func_quote_for_eval ${1+"$@"}
+-#          my_silent_option_result=$func_quote_for_eval_result
++#          func_quote eval ${1+"$@"}
++#          my_silent_option_result=$func_quote_result
+ #        fi
+ #
+ #        $args_changed
+@@ -316,8 +316,8 @@ func_options ()
+     if $_G_rc_options; then
+       func_options_result=$_G_res_var
+     else
+-      func_quote_for_eval ${1+"$@"}
+-      func_options_result=$func_quote_for_eval_result
++      func_quote eval ${1+"$@"}
++      func_options_result=$func_quote_result
+     fi
+ 
+     $_G_rc_options
+@@ -460,8 +460,8 @@ func_parse_options ()
+ 
+     if $_G_rc_parse_options; then
+       # save modified positional parameters for caller
+-      func_quote_for_eval ${1+"$@"}
+-      func_parse_options_result=$func_quote_for_eval_result
++      func_quote eval ${1+"$@"}
++      func_parse_options_result=$func_quote_result
+     fi
+ 
+     $_G_rc_parse_options
+diff --git a/libtoolize.in b/libtoolize.in
+index 798bd0ab..3fe61cef 100644
+--- a/libtoolize.in
++++ b/libtoolize.in
+@@ -151,11 +151,11 @@ libtoolize_environment_options ()
+ 
+     # Pass back the updated list of options.
+     if test -n "$envopts"; then
+-      func_quote_for_eval "$envopts" ${1+"$@"}
++      func_quote eval "$envopts" ${1+"$@"}
+     else
+-      func_quote_for_eval ${1+"$@"}
++      func_quote eval ${1+"$@"}
+     fi
+-    libtoolize_environment_options_result=$func_quote_for_eval_result
++    libtoolize_environment_options_result=$func_quote_result
+ }
+ func_add_hook func_options_prep libtoolize_environment_options
+ 
+@@ -181,8 +181,8 @@ libtoolize_options_prep ()
+     ltdl_mode=
+ 
+     # Pass back the list of options.
+-    func_quote_for_eval ${1+"$@"}
+-    libtoolize_options_prep_result=$func_quote_for_eval_result
++    func_quote eval ${1+"$@"}
++    libtoolize_options_prep_result=$func_quote_result
+ }
+ func_add_hook func_options_prep libtoolize_options_prep
+ 
+@@ -252,8 +252,8 @@ libtoolize_parse_options ()
+     done
+ 
+     # save modified positional parameters for caller
+-    func_quote_for_eval ${1+"$@"}
+-    libtoolize_parse_options_result=$func_quote_for_eval_result
++    func_quote eval ${1+"$@"}
++    libtoolize_parse_options_result=$func_quote_result
+ }
+ func_add_hook func_parse_options libtoolize_parse_options
+ 
+@@ -286,8 +286,8 @@ libtoolize_validate_options ()
+       func_fatal_help "unknown additional arguments: '${1+$@}'"
+ 
+     # Pass back the empty argument list
+-    func_quote_for_eval ${1+"$@"}
+-    libtoolize_validate_options_result=$func_quote_for_eval_result
++    func_quote eval ${1+"$@"}
++    libtoolize_validate_options_result=$func_quote_result
+ }
+ func_add_hook func_validate_options libtoolize_validate_options
+ 
+-- 
+2.11.0
+
diff -Nru libtool-2.4.6/debian/patches/0020-libtool-fix-GCC-clang-linking-with-fsanitize.patch libtool-2.4.6/debian/patches/0020-libtool-fix-GCC-clang-linking-with-fsanitize.patch
--- libtool-2.4.6/debian/patches/0020-libtool-fix-GCC-clang-linking-with-fsanitize.patch	2016-08-20 14:34:31.000000000 +0200
+++ libtool-2.4.6/debian/patches/0020-libtool-fix-GCC-clang-linking-with-fsanitize.patch	2018-01-19 11:37:19.000000000 +0100
@@ -29,8 +29,8 @@
        -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
 -      -specs=*)
 +      -specs=*|-fsanitize=*)
-         func_quote_for_eval "$arg"
- 	arg=$func_quote_for_eval_result
+         func_quote_arg pretty "$arg"
+ 	arg=$func_quote_arg_result
          func_append compile_command " $arg"
 -- 
 2.7.0.rc3
diff -Nru libtool-2.4.6/debian/patches/series libtool-2.4.6/debian/patches/series
--- libtool-2.4.6/debian/patches/series	2016-08-20 14:34:31.000000000 +0200
+++ libtool-2.4.6/debian/patches/series	2018-01-19 11:28:13.000000000 +0100
@@ -1,5 +1,8 @@
 0001-libtool-fix-GCC-linking-with-specs.patch
 0003-libtoolize-fix-infinite-recursion-in-m4.patch
+0010-libtool-mitigate-the-sed_quote_subst-slowdown.patch
+0011-libtool-optimizing-options-parser-hooks.patch
+0012-funclib-refactor-quoting-methods-a-bit.patch
 0015-syntax-check-fix-sed-syntax-errors.patch
 0020-libtool-fix-GCC-clang-linking-with-fsanitize.patch
 link_all_deplibs.patch

Attachment: signature.asc
Description: PGP signature

Reply via email to