autoconf-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Autoconf source repository branch, master, updated. v2.64-69-g


From: Eric Blake
Subject: [SCM] GNU Autoconf source repository branch, master, updated. v2.64-69-g81c80d1
Date: Thu, 29 Oct 2009 02:35:25 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Autoconf source repository".

http://git.sv.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=81c80d1bf6c8ddf732d0b89f6fc5e306dac9705e

The branch, master has been updated
       via  81c80d1bf6c8ddf732d0b89f6fc5e306dac9705e (commit)
       via  cff1fccb6e80125166972354f1e3e8c59703c374 (commit)
       via  820a430f4688f7b374a05c9fa05bcb334321aae4 (commit)
       via  2943c63f52dbed9926a4c87988a0b53c5939679e (commit)
      from  693b541dea84d484c2f65ddf0b8eb9f4426ebbc9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 81c80d1bf6c8ddf732d0b89f6fc5e306dac9705e
Author: Eric Blake <address@hidden>
Date:   Wed Oct 28 15:58:43 2009 -0600

    Fix corner cases in AS_LITERAL_IF and AS_TR_SH.
    
    * lib/m4sugar/m4sh.m4 (AS_LITERAL_IF): Fix bug with unbalanced
    parens.  Move guts...
    (_AS_LITERAL_IF): into new helper.
    (AS_TR_SH, AS_TR_CPP): Fix bugs with expansion of wrong macro.
    Move guts...
    (_AS_TR_SH, _AS_TR_SH_LITERAL, _AS_TR_SH_INDIR, _AS_TR_CPP)
    (_AS_TR_CPP_LITERAL, _AS_TR_CPP_INDIR): ...into new helpers.
    (AS_VAR_PUSHDEF): Hoist m4_require, by moving guts...
    (_AS_VAR_PUSHDEF): ...into new helper.
    * tests/m4sh.at (AS@&address@hidden): Enhance test.
    
    Signed-off-by: Eric Blake <address@hidden>

commit cff1fccb6e80125166972354f1e3e8c59703c374
Author: Eric Blake <address@hidden>
Date:   Wed Oct 28 12:21:36 2009 -0600

    Minor optimizations to m4sh.
    
    * lib/m4sugar/m4sh.m4 (AS_VAR_IF, AS_IDENTIFIER_IF)
    (AS_LITERAL_IF): Parse fewer bytes during expansion, by visiting
    if-true and if-false arguments only once.
    
    Signed-off-by: Eric Blake <address@hidden>

commit 820a430f4688f7b374a05c9fa05bcb334321aae4
Author: Eric Blake <address@hidden>
Date:   Wed Oct 28 11:23:45 2009 -0600

    Optimize m4_escape for common case.
    
    * lib/m4sugar/m4sugar.m4 (m4_escape): Don't use regex if string is
    already sane, by copying from AS_LITERAL_IF.  Move guts...
    (_m4_escape): ...into new helper.
    
    Signed-off-by: Eric Blake <address@hidden>

commit 2943c63f52dbed9926a4c87988a0b53c5939679e
Author: Eric Blake <address@hidden>
Date:   Wed Oct 28 08:17:27 2009 -0600

    Fix m4_text_wrap handling of quoted whitespace.
    
    * lib/m4sugar/m4sugar.m4 (m4_escape): New macro.
    (m4_text_wrap): Use it to avoid issues with embedded [ and ].
    * tests/m4sugar.at (m4@&address@hidden): Test it.
    * NEWS: Document this.
    * doc/autoconf.texi (Text processing Macros) <m4_escape>:
    Likewise.
    Reported by Mike Frysinger.
    
    Signed-off-by: Eric Blake <address@hidden>

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog              |   33 +++++++++++++++++++
 NEWS                   |    8 +++++
 doc/autoconf.texi      |    7 ++++
 lib/m4sugar/m4sh.m4    |   82 ++++++++++++++++++++++++++++--------------------
 lib/m4sugar/m4sugar.m4 |   33 ++++++++++++++++++-
 tests/m4sh.at          |    4 +-
 tests/m4sugar.at       |   15 +++++++--
 7 files changed, 142 insertions(+), 40 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f96f511..f688b26 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2009-10-28  Eric Blake  <address@hidden>
+
+       Fix corner cases in AS_LITERAL_IF and AS_TR_SH.
+       * lib/m4sugar/m4sh.m4 (AS_LITERAL_IF): Fix bug with unbalanced
+       parens.  Move guts...
+       (_AS_LITERAL_IF): into new helper.
+       (AS_TR_SH, AS_TR_CPP): Fix bugs with expansion of wrong macro.
+       Move guts...
+       (_AS_TR_SH, _AS_TR_SH_LITERAL, _AS_TR_SH_INDIR, _AS_TR_CPP)
+       (_AS_TR_CPP_LITERAL, _AS_TR_CPP_INDIR): ...into new helpers.
+       (AS_VAR_PUSHDEF): Hoist m4_require, by moving guts...
+       (_AS_VAR_PUSHDEF): ...into new helper.
+       * tests/m4sh.at (AS@&address@hidden): Enhance test.
+
+       Minor optimizations to m4sh.
+       * lib/m4sugar/m4sh.m4 (AS_VAR_IF, AS_IDENTIFIER_IF)
+       (AS_LITERAL_IF): Parse fewer bytes during expansion, by visiting
+       if-true and if-false arguments only once.
+
+       Optimize m4_escape for common case.
+       * lib/m4sugar/m4sugar.m4 (m4_escape): Don't use regex if string is
+       already sane, by copying from AS_LITERAL_IF.  Move guts...
+       (_m4_escape): ...into new helper.
+
+       Fix m4_text_wrap handling of quoted whitespace.
+       * lib/m4sugar/m4sugar.m4 (m4_escape): New macro.
+       (m4_text_wrap): Use it to avoid issues with embedded [ and ].
+       * tests/m4sugar.at (m4@&address@hidden): Test it.
+       * NEWS: Document this.
+       * doc/autoconf.texi (Text processing Macros) <m4_escape>:
+       Likewise.
+       Reported by Mike Frysinger.
+
 2009-10-27  Eric Blake  <address@hidden>
 
        Mention another feature of AC_RUN_IFELSE.
diff --git a/NEWS b/NEWS
index 666cd4f..4fca50c 100644
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,14 @@ GNU Autoconf NEWS - User visible changes.
 ** The following m4sugar macros now quote their expansion:
    m4_toupper  m4_tolower
 
+** The following m4sugar macros are new:
+   m4_escape
+
+** The m4sugar macro m4_text_wrap now copes with embedded quoting without
+   requiring quadrigraphs.  For uses like AC_ARG_VAR([a], [[b c]]),
+   this gives the intuitive behavior of "[b c]" in the output (2.63
+   gave the output of "[b], [c]", and 2.64 encountered a failure).
+
 ** The `$tmp' temporary directory used in config.status is documented for
    public use now.
 
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index a713a06..6049b59 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -12298,6 +12298,13 @@ m4_combine([, ], [[]], [-], [1], [2])
 @end example
 @end defmac
 
address@hidden m4_escape (@var{string})
address@hidden
+Convert all instances of @samp{[}, @samp{]}, @samp{#}, and @samp{$}
+within @var{string} into their respective quadrigraphs.  The result is
+still a quoted string.
address@hidden defmac
+
 @defmac m4_flatten (@var{string})
 @msindex{flatten}
 Flatten @var{string} into a single line.  Delete all backslash-newline
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 4864088..50dc71c 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -1507,15 +1507,15 @@ m4_define([AS_HELP_STRING],
 # we worry if the first character also matches m4_cr_symbol1 (ie. does not
 # match m4_cr_digit).
 m4_define([AS_IDENTIFIER_IF],
-[m4_if(m4_index([$1], address@hidden), [-1],
-       [_$0($@)],
-       [_$0(m4_bpatsubst([[$1]], [@&address@hidden), [$2], [$3])])])
+[m4_if(_$0(m4_if(m4_index([$1], address@hidden), [-1],
+  [[$1]], [m4_bpatsubst([[$1]], [@&address@hidden)])), [-], [$2], [$3])])
+
 m4_define([_AS_IDENTIFIER_IF],
-[m4_cond([[$1]], [], [$3],
+[m4_cond([[$1]], [], [],
         [m4_eval(m4_len(m4_translit([[$1]], ]]dnl
-m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[)) > 0)], [1], [$3],
+m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[)) > 0)], [1], [],
         [m4_len(m4_translit(m4_format([[%.1s]], [$1]), ]]dnl
-m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], [0], [$2], [$3])])
+m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], [0], [-])])
 
 
 # AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
@@ -1537,20 +1537,20 @@ m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], 
[0], [$2], [$3])])
 # profiling shows that it is faster to use m4_translit.
 #
 # Because the translit is stripping quotes, it must also neutralize anything
-# that might be in a macro name, as well as comments and commas.  All the
-# problem characters are unified so that a single m4_index can scan the
-# result.
+# that might be in a macro name, as well as comments, commas, or unbalanced
+# parentheses.  All the problem characters are unified so that a single
+# m4_index can scan the result.
 #
 # Rather than expand m4_defn every time AS_LITERAL_IF is expanded, we
 # inline its expansion up front.
 m4_define([AS_LITERAL_IF],
-[m4_cond([m4_eval(m4_index(m4_quote($1), address@hidden|@]) == -1)], [0], [$3],
-        [m4_index(m4_translit(m4_quote($1),
-                              [[]`,#]]]dnl
-m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[,
-                              [$$$]),
-                  [$])], [-1], [$2],
-        [$3])])
+[_$0(m4_expand([$1]), [$2], [$3])])
+
+m4_define([_AS_LITERAL_IF],
+[m4_if(m4_cond([m4_eval(m4_index([$1], address@hidden|@]) == -1)], [0], [],
+  [m4_index(m4_translit([$1], [[]`,#()]]]dnl
+m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[, [$$$]), [$])],
+  [-1], [-]), [-], [$2], [$3])])
 
 
 # AS_TMPDIR(PREFIX, [DIRECTORY = $TMPDIR [= /tmp]])
@@ -1736,13 +1736,18 @@ as_tr_sh="eval sed 'y%*+%pp%;s%[[^_$as_cr_alnum]]%_%g'"
 # For speed, we inline the literal definitions that can be computed up front.
 m4_defun_init([AS_TR_SH],
 [AS_REQUIRE([_$0_PREPARE])],
-[AS_LITERAL_IF([$1],
-             [m4_translit([$1], [*+[]]]]dnl
-m4_dquote(m4_dquote(m4_defn([m4_cr_not_symbols2])))[[,
-                                [pp[]]]]dnl
-m4_dquote(m4_dquote(m4_for(,1,255,,[[_]])))[[)],
-  [`AS_ECHO(["_AS_ESCAPE(m4_dquote(m4_expand([$1])),
-    [`], [\])"]) | $as_tr_sh`])])
+[_$0(m4_expand([$1]))])
+
+m4_define([_AS_TR_SH],
+[_AS_LITERAL_IF([$1], [$0_LITERAL], [$0_INDIR])([$1])])
+
+m4_define([_AS_TR_SH_LITERAL],
+[m4_translit([[$1]],
+  [*+[]]]m4_dquote(m4_defn([m4_cr_not_symbols2]))[,
+  [pp[]]]m4_dquote(m4_for(,1,255,,[[_]]))[)])
+
+m4_define([_AS_TR_SH_INDIR],
+[`AS_ECHO(["_AS_ESCAPE([[$1]], [`], [\])"]) | $as_tr_sh`])
 
 
 # _AS_TR_CPP_PREPARE
@@ -1763,12 +1768,18 @@ as_tr_cpp="eval sed 
'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[[^_$as_cr_alnum]]%_%g
 # See implementation comments in AS_TR_SH.
 m4_defun_init([AS_TR_CPP],
 [AS_REQUIRE([_$0_PREPARE])],
-[AS_LITERAL_IF([$1],
-             [m4_translit([$1], [*[]]]]dnl
-m4_dquote(m4_dquote(m4_defn([m4_cr_letters])m4_defn([m4_cr_not_symbols2])))[[,
-                                [P[]]]]dnl
-m4_dquote(m4_dquote(m4_defn([m4_cr_LETTERS])m4_for(,1,255,,[[_]])))[[)],
-             [`AS_ECHO(["$1"]) | $as_tr_cpp`])])
+[_$0(m4_expand([$1]))])
+
+m4_define([_AS_TR_CPP],
+[_AS_LITERAL_IF([$1], [$0_LITERAL], [$0_INDIR])([$1])])
+
+m4_define([_AS_TR_CPP_LITERAL],
+[m4_translit([$1],
+  [*[]]]m4_dquote(m4_defn([m4_cr_letters])m4_defn([m4_cr_not_symbols2]))[,
+  [P[]]]m4_dquote(m4_defn([m4_cr_LETTERS])m4_for(,1,255,,[[_]]))[)])
+
+m4_define([_AS_TR_CPP_INDIR],
+[`AS_ECHO(["$1"]) | $as_tr_cpp`])
 
 
 # _AS_TR_PREPARE
@@ -1909,9 +1920,9 @@ m4_define([AS_VAR_GET],
 # Polymorphic, and avoids sh expansion error upon interrupt or term signal.
 m4_define([AS_VAR_IF],
 [AS_LITERAL_IF([$1],
-  [AS_IF([test "x$$1" = x""$2], [$3], [$4])],
+  [AS_IF([test "x$$1" = x""$2]],
   [AS_VAR_COPY([as_val], [$1])
-   AS_IF([test "x$as_val" = x""$2], [$3], [$4])])])
+   AS_IF([test "x$as_val" = x""$2]]), [$3], [$4])])
 
 
 # AS_VAR_PUSHDEF and AS_VAR_POPDEF
@@ -1959,9 +1970,12 @@ m4_define([AS_VAR_POPDEF],
 # don't work.  Therefore, we must require the preparation ourselves.
 m4_defun_init([AS_VAR_PUSHDEF],
 [AS_REQUIRE([_AS_TR_SH_PREPARE])],
-[AS_LITERAL_IF([$2],
-              [m4_pushdef([$1], [AS_TR_SH($2)])],
-              [as_$1=AS_TR_SH($2)
+[_$0([$1], m4_expand([$2]))])
+
+m4_define([_AS_VAR_PUSHDEF],
+[_AS_LITERAL_IF([$2],
+               [m4_pushdef([$1], [_AS_TR_SH_LITERAL([$2])])],
+               [as_$1=_AS_TR_SH_INDIR([$2])
 m4_pushdef([$1], [$as_[$1]])])])
 
 
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index 2e53ea3..e0cacfb 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -2542,6 +2542,36 @@ m4_define([m4_append_uniq_w],
 [m4_map_args_w([$2], [_m4_append_uniq([$1],], [, [ ])])])
 
 
+# m4_escape(STRING)
+# -----------------
+# Output quoted STRING, but with embedded #, $, [ and ] turned into
+# quadrigraphs.
+#
+# It is faster to check if STRING is already good using m4_translit
+# than to blindly perform four m4_bpatsubst.
+#
+# Because the translit is stripping quotes, it must also neutralize
+# anything that might be in a macro name, as well as comments, commas,
+# and parentheses.  All the problem characters are unified so that a
+# single m4_index can scan the result.
+#
+# Rather than expand m4_defn every time m4_escape is expanded, we
+# inline its expansion up front.
+m4_define([m4_escape],
+[m4_if(m4_index(m4_translit([$1],
+   [[]#,()]]m4_dquote(m4_defn([m4_cr_symbols2]))[, [$$$]), [$]),
+  [-1], [m4_echo], [_$0])([$1])])
+
+m4_define([_m4_escape],
+[m4_changequote([-=<{(],[)}>=-])]dnl
+[m4_bpatsubst(m4_bpatsubst(m4_bpatsubst(m4_bpatsubst(
+         -=<{(-=<{(-=<{(-=<{(-=<{($1)}>=-)}>=-)}>=-)}>=-)}>=-,
+       -=<{(#)}>=-, -=<{(@%:@)}>=-),
+      -=<{(\[)}>=-, -=<{(@<:@)}>=-),
+    -=<{(\])}>=-, -=<{(@:>@)}>=-),
+  -=<{(\$)}>=-, -=<{(@S|@)}>=-)m4_changequote([,])])
+
+
 # m4_text_wrap(STRING, [PREFIX], [FIRST-PREFIX], [WIDTH])
 # -------------------------------------------------------
 # Expands into STRING wrapped to hold in WIDTH columns (default = 79).
@@ -2592,8 +2622,9 @@ m4_define([m4_append_uniq_w],
 # with m4_do, to avoid time wasted on dnl during expansion (since this is
 # already a time-consuming macro).
 m4_define([m4_text_wrap],
-[_$0([$1], [$2], m4_default_quoted([$3], [$2]),
+[_$0(m4_escape([$1]), [$2], m4_default_quoted([$3], [$2]),
      m4_default_quoted([$4], [79]))])
+
 m4_define([_m4_text_wrap],
 m4_do(dnl set up local variables, to avoid repeated calculations
 [[m4_pushdef([m4_Indent], m4_qlen([$2]))]],
diff --git a/tests/m4sh.at b/tests/m4sh.at
index 4627a48..5ff9fe8 100644
--- a/tests/m4sh.at
+++ b/tests/m4sh.at
@@ -1041,13 +1041,13 @@ AT_DATA_M4SH([script.as], [[dnl
 AS_INIT
 echo AS_LITERAL_IF([lit], [ok], [ERR]) 1
 echo AS_LITERAL_IF([l$it], [ERR], [ok]) 2
-echo AS_LITERAL_IF([l``it], [ERR], [ok]) 3
+echo AS_LITERAL_IF([l`case a in b) ;; esac`it], [ERR], [ok]) 3
 m4_define([mac], [lit])
 echo AS_LITERAL_IF([mac], [ok], [ERR]) 4
 echo AS_LITERAL_IF([mac($, ``)], [ok], [ERR]) 5
 m4_define([mac], [l$it])
 echo AS_LITERAL_IF([mac], [ERR], [ok]) 6
-m4_define([mac], [l`it])
+m4_define([mac], [l``it])
 echo AS_LITERAL_IF([mac], [ERR], [ok]) 7
 ]])
 
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
index d37681b..aa30291 100644
--- a/tests/m4sugar.at
+++ b/tests/m4sugar.at
@@ -1127,6 +1127,7 @@ AT_CLEANUP
 ## -------------- ##
 
 AT_SETUP([m4@&address@hidden)
+AT_KEYWORDS([m4@&address@hidden)
 
 # m4_text_wrap is used to display the help strings.  Also, check that
 # commas and $ are not swallowed.  This can easily happen because of
@@ -1134,6 +1135,11 @@ AT_SETUP([m4@&address@hidden)
 
 AT_DATA_M4SUGAR([script.4s],
 [[m4_init[]m4_divert([0])dnl
+m4_define([a], [OOPS])dnl
+m4_escape([a[b $c#]d])
+m4_if(m4_escape([a[b $c#]d]), [a[b $c#]d], [oops],
+      m4_escape([a[b $c#]d]), [a@<:@b @S|@address@hidden:@@:>@d], [pass], 
[oops])
+
 m4_text_wrap([Short string */], [   ], [/* ], 20)
 
 m4_text_wrap([Much longer string */], [   ], [/* ], 20)
@@ -1144,13 +1150,16 @@ m4_text_wrap([Short doc.], [          ], [  
--too-wide], 30)
 
 m4_text_wrap([Super long documentation.], [          ], [  --too-wide], 30)
 
-m4_text_wrap([First, second  , third, [,quoted]])
+m4_text_wrap([First, second  , third, [,quoted  space]])
 m4_define([xfff], [oops])
 m4_text_wrap([Some $1 $2 $3 $4 embedded dollars.], [ $* ], [ $@ ], [0xfff & 
20])
 ]])
 
 AT_DATA([expout],
-[[/* Short string */
+[[a[b $c#]d
+pass
+
+/* Short string */
 
 /* Much longer
    string */
@@ -1164,7 +1173,7 @@ AT_DATA([expout],
           Super long
           documentation.
 
-First, second , third, [,quoted]
+First, second , third, [,quoted space]
 
  $@ Some $1 $2 $3
  $* $4 embedded


hooks/post-receive
-- 
GNU Autoconf source repository




reply via email to

[Prev in Thread] Current Thread [Next in Thread]