From: Eric Blake Date: Thu, 20 Nov 2008 19:08:14 +0000 (-0700) Subject: Speed up _AS_QUOTE. X-Git-Tag: v2.63b~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a144bc25ecb4dba3d9ee3a7200257a91a059096;p=thirdparty%2Fautoconf.git Speed up _AS_QUOTE. * lib/m4sugar/m4sh.m4 (_AS_QUOTE_IFELSE): Inline into... (_AS_QUOTE): ...here, delete unused second paramenter, and factor choice into... (_AS_QUOTE_MODERN, _AS_QUOTE_OLD): ...new helpers. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index 10bd336ce..22c98d091 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-11-20 Eric Blake + + Speed up _AS_QUOTE. + * lib/m4sugar/m4sh.m4 (_AS_QUOTE_IFELSE): Inline into... + (_AS_QUOTE): ...here, delete unused second paramenter, and factor + choice into... + (_AS_QUOTE_MODERN, _AS_QUOTE_OLD): ...new helpers. + 2008-11-20 Alfred G. de Wijn (tiny change) For consistency, make temporary variable match language name. diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index 8863c82c6..0b3244056 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/m4sh.m4 @@ -669,8 +669,11 @@ m4_define([_AS_ESCAPE], [$1], [m4_bpatsubst([$1], [[$2]], [\\\&])])]) -# _AS_QUOTE_IFELSE(STRING, IF-MODERN-QUOTATION, IF-OLD-QUOTATION) -# --------------------------------------------------------------- +# _AS_QUOTE(STRING) +# ----------------- +# If there are quoted (via backslash) backquotes, output STRING +# literally and warn; otherwise, output STRING with ` and " quoted. +# # Compatibility glue between the old AS_MSG suite which did not # quote anything, and the modern suite which quotes the quotes. # If STRING contains `\\' or `\$', it's modern. @@ -685,25 +688,20 @@ m4_define([_AS_ESCAPE], # [$2]) # The current implementation caters to the common case of no backslashes, # to minimize m4_index expansions (hence the nested if). -m4_define([_AS_QUOTE_IFELSE], -[m4_cond([m4_index([$1], [\])], [-1], [$2], - [m4_eval(m4_index([$1], [\\]) >= 0)], [1], [$2], - [m4_eval(m4_index([$1], [\$]) >= 0)], [1], [$2], - [m4_eval(m4_index([$1], [\`]) >= 0)], [1], [$3], - [m4_eval(m4_index([$1], [\"]) >= 0)], [1], [$3], - [$2])]) - - -# _AS_QUOTE(STRING, [CHARS = `"]) -# ------------------------------- -# If there are quoted (via backslash) backquotes do nothing, else -# backslash all the quotes. m4_define([_AS_QUOTE], -[_AS_QUOTE_IFELSE([$1], - [_AS_ESCAPE([$1], m4_default([$2], [`""]))], - [m4_warn([obsolete], - [back quotes and double quotes must not be escaped in: $1])dnl -$1])]) +[m4_cond([m4_index([$1], [\])], [-1], [_AS_QUOTE_MODERN], + [m4_eval(m4_index(m4_translit([[$1]], [$], [\]), [\\]) >= 0)], +[1], [_AS_QUOTE_MODERN], + [m4_eval(m4_index(m4_translit([[$1]], ["], [`]), [\`]) >= 0)],dnl" +[1], [_AS_QUOTE_OLD], + [_AS_QUOTE_MODERN])([$1])]) + +m4_define([_AS_QUOTE_MODERN], +[_AS_ESCAPE([$1], [`""])]) + +m4_define([_AS_QUOTE_OLD], +[m4_warn([obsolete], + [back quotes and double quotes must not be escaped in: $1])$1]) # _AS_ECHO_UNQUOTED(STRING, [FD = AS_MESSAGE_FD])