From 857d60fcbc81739c594bb5d6e7c8828b4fb57c58 Mon Sep 17 00:00:00 2001 From: Noah Misch Date: Thu, 21 Oct 2004 16:51:07 +0000 Subject: [PATCH] * config/general.m4sh (sed_double_backslash): Improve this sed expression to correct left anchored $ input to double_quote_subst, as well as backslash escaped $ preceded by any odd-numbered amount of characters. --- ChangeLog | 8 ++++++++ config/general.m4sh | 14 ++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 64036ce94..fef23ce47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-10-21 Noah Misch , + Gary V. Vaughan + + * config/general.m4sh (sed_double_backslash): Improve this sed + expression to correct left anchored \$ input to + double_quote_subst, as well as backslash escaped $ preceded by + any odd-numbered amount of \ characters. + 2004-10-20 Gary V. Vaughan * config/general.m4sh (sed_double_backslash): New sed expression diff --git a/config/general.m4sh b/config/general.m4sh index efecf7cd6..af88d3845 100644 --- a/config/general.m4sh +++ b/config/general.m4sh @@ -94,12 +94,14 @@ sed_quote_subst='s/\([[`"$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' -# Save mangling of backslash escaped dollars by the above. Running this -# substitution after double_quote_subst notices and corrects expansion -# of already escaped meta-chars. \$x -> double_quote_subst -> \\$x, -# which doesn't protect $x from expansion. To correct this we do: -# \\$x -> sed_double_backslash -> \\\$x, properly protecting $x. -sed_double_backslash='s/\([[^\\]]\)\\\\$/\1\\\\\\$/g' +# Re-`\' parameter expansions in output of double_quote_subst that were +# `\'-ed in input to the same. If an odd number of `\' preceded a '$' +# in input to double_quote_subst, that '$' was protected from expansion. +# Since each input `\' is now two `\'s, look for any number of runs of +# four `\'s followed by two `\'s and then a '$'. `\' that '$'. Note +# that the embedded single quotes serve only to enhance readability. +sed_double_backslash='s/^\(\(''\\\\''\\\\''\)*''\\\\''\$\)/\\\1/; + s/\([[^\\]]\(''\\\\''\\\\''\)*''\\\\''\$\)/\\\1/g' # test EBCDIC or ASCII case `$ECHO A|tr A '\301'` in -- 2.47.2