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.65-115-


From: Eric Blake
Subject: [SCM] GNU Autoconf source repository branch, master, updated. v2.65-115-g64954f9
Date: Fri, 02 Jul 2010 19:39:21 +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=64954f9188cc3ba018d04c66349809383a49f627

The branch, master has been updated
       via  64954f9188cc3ba018d04c66349809383a49f627 (commit)
       via  73720645e99acbf8164e05c209ea0eb122f14fc1 (commit)
       via  ac6824d442301dbbfcd69f7a9160a5aa13396a7f (commit)
       via  e960d7be02c5d2e33b4b631359b5cb98c87faafa (commit)
       via  71972deac8c02dd9eff4e2dd0fc137add0eb8720 (commit)
       via  07263c965a03c979f4712c6c5cfe9243911af0f9 (commit)
       via  be4bf08802b79244f184dfd8dffa0fd5901df8f2 (commit)
      from  b6a515746aeeafac36b5faddb0ed1514b0569364 (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 64954f9188cc3ba018d04c66349809383a49f627
Author: Eric Blake <address@hidden>
Date:   Mon Mar 1 17:17:40 2010 -0700

    Optimize AS_BOX.
    
    * lib/m4sugar/m4sh.m4 (AS_BOX): Use less m4 time.
    (_AS_BOX_LITERAL): Use fewer forks in the common case.
    * doc/autoconf.texi (Common Shell Constructs) <AS_BOX>: Document
    the macro.
    * NEWS: Mention it.
    
    Signed-off-by: Eric Blake <address@hidden>

commit 73720645e99acbf8164e05c209ea0eb122f14fc1
Author: Eric Blake <address@hidden>
Date:   Sat Feb 27 11:43:21 2010 -0700

    Use new AS_LITERAL_IF argument when appropriate.
    
    * lib/m4sugar/m4sh.m4 (AS_VAR_SET): Reduce m4 overhead.
    (AS_VAR_IF, AS_VAR_TEST_SET): Provide shorter variant for simple
    references.
    Suggested by Bruno Haible.
    
    Signed-off-by: Eric Blake <address@hidden>

commit ac6824d442301dbbfcd69f7a9160a5aa13396a7f
Author: Eric Blake <address@hidden>
Date:   Tue Mar 16 18:49:07 2010 -0600

    Add tests for AS_BOX.
    
    * tests/m4sugar.at (m4@&address@hidden): New test.
    * tests/m4sh.at (AS@&address@hidden): Likewise.
    * lib/m4sugar/m4sugar.m4 (m4_text_box): Support comma.
    * doc/autoconf.texi (Text processing Macros) <m4_text_box>:
    Document further limitations.
    
    Signed-off-by: Eric Blake <address@hidden>

commit e960d7be02c5d2e33b4b631359b5cb98c87faafa
Author: Eric Blake <address@hidden>
Date:   Tue Mar 16 18:12:02 2010 -0600

    Add optional argument to AS_LITERAL_IF.
    
    * lib/m4sugar/m4sh.m4 (_AS_LITERAL_IF): Rewrite to generate macro
    name, without using m4_cond.
    (_AS_LITERAL_IF_, _AS_LITERAL_IF_YES, _AS_LITERAL_IF_NO): New
    helpers.
    (AS_LITERAL_IF, AS_LITERAL_WORD_IF, _AS_TR_SH, _AS_TR_CPP)
    (_AS_VAR_PUSHDEF): Adjust callers.
    * lib/autoconf/types.m4 (AC_CHECK_ALIGNOF): Relax restrictions on
    invalid bytes, since this allows inline struct layouts.
    (_AC_CHECK_ALIGNOF): New helper macro.
    * tests/m4sh.at (AS@&address@hidden): Update test.
    * doc/autoconf.texi (Polymorphic Variables) <AS_LITERAL_IF>:
    Update documentation.
    
    Signed-off-by: Eric Blake <address@hidden>

commit 71972deac8c02dd9eff4e2dd0fc137add0eb8720
Author: Eric Blake <address@hidden>
Date:   Tue Mar 16 17:52:12 2010 -0600

    Use AS_LITERAL_WORD_IF as appropriate.
    
    * lib/autoconf/autoheader.m4 (AH_VERBATIM): Use new macro.
    * lib/autoconf/general.m4 (AC_REQUIRE_AUX_FILE, AC_CACHE_VAL)
    (AS_CACHE_CHECK, AC_DEFINE_TRACE, _AC_LIBOBJ): Likewise.
    * lib/autoconf/libs.m4 (AC_CHECK_LIB): Likewise.
    * lib/autoconf/status.m4 (AC_CONFIG_SUBDIRS): Likewise.
    * lib/m4sugar/m4sh.m4 (AS_UNSET, AS_VAR_COPY, AS_VAR_GET)
    (AS_VAR_IF, AS_VAR_SET, AS_VAR_TEST_SET): Likewise.
    
    Signed-off-by: Eric Blake <address@hidden>

commit 07263c965a03c979f4712c6c5cfe9243911af0f9
Author: Eric Blake <address@hidden>
Date:   Tue Mar 16 15:51:23 2010 -0600

    Add AS_LITERAL_WORD_IF.
    
    * lib/m4sugar/m4sh.m4 (_AS_LITERAL_IF): Also reject shell quoting
    characters as non-literal, and provide way to reject space.
    (AS_LITERAL_WORD_IF): New macro.
    * doc/autoconf.texi (Polymorphic Variables) <AS_LITERAL_IF>:
    Document new macro.  Fix example to match reality.
    * NEWS: Document change and new macro.
    * tests/m4sh.at (AS@&address@hidden): Update test.
    
    Signed-off-by: Eric Blake <address@hidden>

commit be4bf08802b79244f184dfd8dffa0fd5901df8f2
Author: Eric Blake <address@hidden>
Date:   Tue Mar 16 15:48:44 2010 -0600

    Optimize AC_DEFINE.
    
    * lib/autoconf/general.m4 (_AC_DEFINE_Q): Avoid overhead of
    AS_LITERAL_IF.
    
    Signed-off-by: Eric Blake <address@hidden>

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

Summary of changes:
 ChangeLog                  |   58 +++++++++++++++++++++
 NEWS                       |    9 +++
 doc/autoconf.texi          |   65 ++++++++++++++++++++----
 lib/autoconf/autoheader.m4 |    2 +-
 lib/autoconf/general.m4    |   14 +++---
 lib/autoconf/libs.m4       |    2 +-
 lib/autoconf/status.m4     |    2 +-
 lib/autoconf/types.m4      |   22 ++++++---
 lib/m4sugar/m4sh.m4        |  120 ++++++++++++++++++++++++++++++--------------
 lib/m4sugar/m4sugar.m4     |    6 +-
 tests/m4sh.at              |   84 +++++++++++++++++++++++++++----
 tests/m4sugar.at           |   24 +++++++++
 12 files changed, 329 insertions(+), 79 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9f5c879..a559c16 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,61 @@
+2010-07-02  Eric Blake  <address@hidden>
+
+       Optimize AS_BOX.
+       * lib/m4sugar/m4sh.m4 (AS_BOX): Use less m4 time.
+       (_AS_BOX_LITERAL): Use fewer forks in the common case.
+       * doc/autoconf.texi (Common Shell Constructs) <AS_BOX>: Document
+       the macro.
+       * NEWS: Mention it.
+
+       Use new AS_LITERAL_IF argument when appropriate.
+       * lib/m4sugar/m4sh.m4 (AS_VAR_SET): Reduce m4 overhead.
+       (AS_VAR_IF, AS_VAR_TEST_SET): Provide shorter variant for simple
+       references.
+       Suggested by Bruno Haible.
+
+       Add tests for AS_BOX.
+       * tests/m4sugar.at (m4@&address@hidden): New test.
+       * tests/m4sh.at (AS@&address@hidden): Likewise.
+       * lib/m4sugar/m4sugar.m4 (m4_text_box): Support comma.
+       * doc/autoconf.texi (Text processing Macros) <m4_text_box>:
+       Document further limitations.
+
+       Add optional argument to AS_LITERAL_IF.
+       * lib/m4sugar/m4sh.m4 (_AS_LITERAL_IF): Rewrite to generate macro
+       name, without using m4_cond.
+       (_AS_LITERAL_IF_, _AS_LITERAL_IF_YES, _AS_LITERAL_IF_NO): New
+       helpers.
+       (AS_LITERAL_IF, AS_LITERAL_WORD_IF, _AS_TR_SH, _AS_TR_CPP)
+       (_AS_VAR_PUSHDEF): Adjust callers.
+       * lib/autoconf/types.m4 (AC_CHECK_ALIGNOF): Relax restrictions on
+       invalid bytes, since this allows inline struct layouts.
+       (_AC_CHECK_ALIGNOF): New helper macro.
+       * tests/m4sh.at (AS@&address@hidden): Update test.
+       * doc/autoconf.texi (Polymorphic Variables) <AS_LITERAL_IF>:
+       Update documentation.
+
+       Use AS_LITERAL_WORD_IF as appropriate.
+       * lib/autoconf/autoheader.m4 (AH_VERBATIM): Use new macro.
+       * lib/autoconf/general.m4 (AC_REQUIRE_AUX_FILE, AC_CACHE_VAL)
+       (AS_CACHE_CHECK, AC_DEFINE_TRACE, _AC_LIBOBJ): Likewise.
+       * lib/autoconf/libs.m4 (AC_CHECK_LIB): Likewise.
+       * lib/autoconf/status.m4 (AC_CONFIG_SUBDIRS): Likewise.
+       * lib/m4sugar/m4sh.m4 (AS_UNSET, AS_VAR_COPY, AS_VAR_GET)
+       (AS_VAR_IF, AS_VAR_SET, AS_VAR_TEST_SET): Likewise.
+
+       Add AS_LITERAL_WORD_IF.
+       * lib/m4sugar/m4sh.m4 (_AS_LITERAL_IF): Also reject shell quoting
+       characters as non-literal, and provide way to reject space.
+       (AS_LITERAL_WORD_IF): New macro.
+       * doc/autoconf.texi (Polymorphic Variables) <AS_LITERAL_IF>:
+       Document new macro.  Fix example to match reality.
+       * NEWS: Document change and new macro.
+       * tests/m4sh.at (AS@&address@hidden): Update test.
+
+       Optimize AC_DEFINE.
+       * lib/autoconf/general.m4 (_AC_DEFINE_Q): Avoid overhead of
+       AS_LITERAL_IF.
+
 2010-07-02  Stefano Lattarini  <address@hidden>
        and Eric Blake  <address@hidden>
 
diff --git a/NEWS b/NEWS
index eecb9f6..8acc6e7 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,15 @@ GNU Autoconf NEWS - User visible changes.
    AT_ARG_OPTION has been changed in that the negative of a long option
    --OPTION is now --no-OPTION rather than --noOPTION.
 
+** The macro AS_LITERAL_IF is slightly more conservative; text
+   containing shell quotes are no longer treated as literals.
+   Furthermore, a new macro, AS_LITERAL_WORD_IF, adds an additional
+   level of checking that no whitespace occurs in literals.
+
+** The following macros are now documented:
+   AS_BOX
+
+
 * Major changes in Autoconf 2.65 (2009-11-21) [stable]
   Released by Eric Blake, based on git versions 2.64.*.
 
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 6353f87..f531ed6 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -12523,7 +12523,9 @@ quickly test if @var{string} has only whitespace, use 
@code{m4_ifblank}.
 @defmac m4_text_box (@var{message}, @dvar{frame, -})
 @msindex{text_box}
 Add a text box around @var{message}, using @var{frame} as the border
-character above and below the message.  The frame correctly accounts for
+character above and below the message.  The @var{frame} argument must be
+a single byte, and does not support quadrigraphs.
+The frame correctly accounts for
 the subsequent expansion of @var{message}.  For example:
 @example
 m4_define([macro], [abc])dnl
@@ -13084,6 +13086,17 @@ if @code{$file} is @samp{/one/two/three}, the command
 @end defmac
 @end ignore
 
address@hidden AS_BOX (@var{text}, @dvar{char, -})
address@hidden
+Expand into shell code that will output @var{text} surrounded by a box
+with @var{char} in the top and bottom border.  @var{text} should not
+contain a newline, but may contain shell expansions valid for unquoted
+here-documents.  @var{char} defaults to @samp{-}, but can be any
+character except @samp{/}, @samp{'}, @samp{"}, @samp{\},
address@hidden&}, or @samp{`}.  This is useful for outputting a comment box into
+log files to separate distinct phases of script operation.
address@hidden defmac
+
 @defmac AS_CASE (@var{word}, @ovar{pattern1}, @ovar{if-matched1}, @
   @dots{}, @ovar{default})
 @asindex{CASE}
@@ -13298,24 +13311,54 @@ names and output shell code appropriate for both use 
cases.  Behavior is
 undefined if expansion of an indirect variable does not result in a
 literal variable name.
 
address@hidden AS_LITERAL_IF (@var{expression}, @ovar{if-literal}, 
@ovar{if-not})
address@hidden AS_LITERAL_IF (@var{expression}, @ovar{if-literal}, 
@ovar{if-not}, @
+  @dvar{if-simple-ref, @var{if-not}})
address@hidden AS_LITERAL_WORD_IF (@var{expression}, @ovar{if-literal}, @
+  @ovar{if-not}, @dvar{if-simple-ref, @var{if-not}})
 @asindex{LITERAL_IF}
address@hidden
 If the expansion of @var{expression} is definitely a shell literal,
 expand @var{if-literal}.  If the expansion of @var{expression} looks
 like it might contain shell indirections (such as @code{$var} or
address@hidden), then @var{if-not} is expanded.  In order to reduce the
-time spent deciding whether an expression is literal, the implementation
-is somewhat conservative (for example, @samp{'[$]'} is a single-quoted
-shell literal, but causes @var{if-not} to be expanded).  While this
-macro is often used for recognizing shell variable names, it can also be
-used in other contexts.
address@hidden), then @var{if-not} is expanded.  Sometimes, it is
+possible to output optimized code if @var{expression} consists only of
+shell variable expansions (such as @address@hidden@}}), in which case
address@hidden can be provided; but defaulting to @var{if-not}
+should always be safe.  @code{AS_LITERAL_WORD_IF} only expands
address@hidden if @var{expression} looks like a single shell word,
+containing no whitespace; while @code{AS_LITERAL_IF} allows whitespace
+in @var{expression}.
+
+In order to reduce the time spent recognizing whether an
address@hidden qualifies as a literal or a simple indirection, the
+implementation is somewhat conservative: @var{expression} must be a
+single shell word (possibly after stripping whitespace), consisting only
+of bytes that would have the same meaning whether unquoted or enclosed
+in double quotes (for example, @samp{a.b} results in @var{if-literal},
+even though it is not a valid shell variable name; while both @samp{'a'}
+and @samp{[$]} result in @var{if-not}, because they behave differently
+than @samp{"'a'"} and @samp{"[$]"}).  This macro can be used in contexts
+for recognizing portable file names (such as in the implementation of
address@hidden), or coupled with some transliterations for forming
+valid variable names (such as in the implementation of @code{AS_TR_SH},
+which uses an additional @code{m4_translit} to convert @samp{.} to
address@hidden).
+
+This example shows how to read the contents of the shell variable
address@hidden, exercising all three arguments to @code{AS_LITERAL_IF}.  It
+results in a script that will output the line @samp{hello} three times.
 
 @example
 AC_DEFUN([MY_ACTION],
 [AS_LITERAL_IF([$1],
-[echo "$1"],
-[AS_VAR_COPY([tmp], [$1])
-echo "$tmp"])])
+  [echo "$$1"],
+  [AS_VAR_COPY([tmp], [$1])
+   echo "$tmp"],
+  [eval 'echo "$'"$1"\"])])
+foo=bar bar=hello
+MY_ACTION([bar])
+MY_ACTION([`echo bar`])
+MY_ACTION([$foo])
 @end example
 @end defmac
 
diff --git a/lib/autoconf/autoheader.m4 b/lib/autoconf/autoheader.m4
index 920c81f..f89d042 100644
--- a/lib/autoconf/autoheader.m4
+++ b/lib/autoconf/autoheader.m4
@@ -45,7 +45,7 @@ m4_define([AH_OUTPUT], [])
 #
 # Quote for Perl '' strings, which are those used by Autoheader.
 m4_define([AH_VERBATIM],
-[AS_LITERAL_IF([$1],
+[AS_LITERAL_WORD_IF([$1],
               [AH_OUTPUT(_m4_expand([$1]), AS_ESCAPE([[$2]], [\']))])])
 
 
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index cadec67..fc4905b 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -1733,7 +1733,7 @@ AC_DEFUN([AC_CONFIG_MACRO_DIR], [])
 # This macro does nothing, it's a hook to be read with `autoconf --trace'.
 # It announces FILE is required in the auxdir.
 m4_define([AC_REQUIRE_AUX_FILE],
-[AS_LITERAL_IF([$1], [],
+[AS_LITERAL_WORD_IF([$1], [],
               [m4_fatal([$0: requires a literal argument])])])
 
 
@@ -2008,7 +2008,7 @@ rm -f confcache[]dnl
 # The name of shell var CACHE-ID must contain `_cv_' in order to get saved.
 # Should be dnl'ed.  Try to catch common mistakes.
 m4_defun([AC_CACHE_VAL],
-[AS_LITERAL_IF([$1], [m4_if(m4_index(m4_quote($1), [_cv_]), [-1],
+[AS_LITERAL_WORD_IF([$1], [m4_if(m4_index(m4_quote($1), [_cv_]), [-1],
                            [AC_DIAGNOSE([syntax],
 [$0($1, ...): suspicious cache-id, must contain _cv_ to be cached])])])dnl
 m4_if(m4_index([$2], [AC_DEFINE]), [-1], [],
@@ -2031,7 +2031,7 @@ AS_VAR_SET_IF([$1],
 m4_defun([AC_CACHE_CHECK],
 [AC_MSG_CHECKING([$1])
 AC_CACHE_VAL([$2], [$3])dnl
-AS_LITERAL_IF([$2],
+AS_LITERAL_WORD_IF([$2],
              [AC_MSG_RESULT([$$2])],
              [AS_VAR_COPY([ac_res], [$2])
               AC_MSG_RESULT([$ac_res])])dnl
@@ -2067,7 +2067,7 @@ AS_IDENTIFIER_IF([$1], [],
 # This macro is a wrapper around AC_DEFINE_TRACE_LITERAL which filters
 # out non literal symbols.  CPP-SYMBOL must not include any parameters.
 m4_define([AC_DEFINE_TRACE],
-[AS_LITERAL_IF([$1], [AC_DEFINE_TRACE_LITERAL(_m4_expand([$1]))])])
+[AS_LITERAL_WORD_IF([$1], [AC_DEFINE_TRACE_LITERAL(_m4_expand([$1]))])])
 
 
 # AC_DEFINE(VARIABLE, [VALUE], [DESCRIPTION])
@@ -2123,8 +2123,8 @@ m4_define([_AC_DEFINE_Q],
 [AC_DEFINE_TRACE(AC_name)]dnl
 [m4_cond([m4_index([$3], [
 ])], [-1], [],
-       [AS_LITERAL_IF([$3], [m4_bregexp([[$3]], [[^\\]
-], [-])])], [], [],
+       [m4_bregexp([[$3]], [[^\\]
+], [-])], [], [],
        [m4_warn([syntax], [AC_DEFINE]m4_if([$1], [_AC_DEFINE], [],
   [[_UNQUOTED]])[: `$3' is not a valid preprocessor define value])])]dnl
 [m4_ifval([$4], [AH_TEMPLATE(AC_name, [$4])
@@ -2904,7 +2904,7 @@ AC_DEFUN([AC_LIBSOURCES],
 # --------------------------------------------
 # We need `FILE-NAME-NOEXT.o', save this into `LIBOBJS'.
 m4_define([_AC_LIBOBJ],
-[AS_LITERAL_IF([$1],
+[AS_LITERAL_WORD_IF([$1],
               [AC_LIBSOURCE([$1.c])],
               [$2])dnl
 case " $LIB@&address@hidden " in
diff --git a/lib/autoconf/libs.m4 b/lib/autoconf/libs.m4
index e3fa36d..ec961aa 100644
--- a/lib/autoconf/libs.m4
+++ b/lib/autoconf/libs.m4
@@ -99,7 +99,7 @@ AS_VAR_POPDEF([ac_Search])dnl
 # freedom.
 AC_DEFUN([AC_CHECK_LIB],
 [m4_ifval([$3], , [AH_CHECK_LIB([$1])])dnl
-AS_LITERAL_IF([$1],
+AS_LITERAL_WORD_IF([$1],
              [AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$2])],
              [AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1''_$2])])dnl
 AC_CACHE_CHECK([for $2 in -l$1], [ac_Lib],
diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index b9e7026..52b7a3d 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -1102,7 +1102,7 @@ AC_DEFUN([AC_CONFIG_SUBDIRS],
   _AC_CONFIG_COMPUTE_DEST(], [))])]dnl
 [m4_append([_AC_LIST_SUBDIRS], [$1], [
 ])]dnl
-[AS_LITERAL_IF([$1], [],
+[AS_LITERAL_WORD_IF([$1], [],
               [AC_DIAGNOSE([syntax], [$0: you should use literals])])]dnl
 [AC_SUBST([subdirs], ["$subdirs m4_normalize([$1])"])])
 
diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4
index 646b1dc..ee07148 100644
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -785,25 +785,32 @@ AC_DEFINE_UNQUOTED(AS_TR_CPP(sizeof_$1), 
$AS_TR_SH([ac_cv_sizeof_$1]),
 
 # AC_CHECK_ALIGNOF(TYPE, [INCLUDES = DEFAULT-INCLUDES])
 # -----------------------------------------------------
+# TYPE can include braces and semicolon, which AS_TR_CPP and AS_TR_SH
+# (correctly) recognize as potential shell metacharacters.  So we
+# have to flatten problematic characters ourselves to guarantee that
+# AC_DEFINE_UNQUOTED will see a literal.
 AC_DEFUN([AC_CHECK_ALIGNOF],
-[AS_LITERAL_IF([$1], [],
-              [m4_fatal([$0: requires literal arguments])])]dnl
+[m4_if(m4_index(m4_translit([[$1]], [`\"], [$]), [$]), [-1], [],
+       [m4_fatal([$0: requires literal arguments])])]dnl
+[_$0([$1], [$2], m4_translit([[$1]], [{;}], [___]))])
+
+m4_define([_AC_CHECK_ALIGNOF],
 [# The cast to long int works around a bug in the HP C Compiler,
 # see AC_CHECK_SIZEOF for more information.
-_AC_CACHE_CHECK_INT([alignment of $1], [AS_TR_SH([ac_cv_alignof_$1])],
+_AC_CACHE_CHECK_INT([alignment of $1], [AS_TR_SH([ac_cv_alignof_$3])],
   [(long int) offsetof (ac__type_alignof_, y)],
   [AC_INCLUDES_DEFAULT([$2])
 #ifndef offsetof
 # define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0)
 #endif
 typedef struct { char x; $1 y; } ac__type_alignof_;],
-  [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
+  [if test "$AS_TR_SH([ac_cv_type_$3])" = yes; then
      AC_MSG_FAILURE([cannot compute alignment of $1], 77)
    else
-     AS_TR_SH([ac_cv_alignof_$1])=0
+     AS_TR_SH([ac_cv_alignof_$3])=0
    fi])
 
-AC_DEFINE_UNQUOTED(AS_TR_CPP(alignof_$1), $AS_TR_SH([ac_cv_alignof_$1]),
+AC_DEFINE_UNQUOTED(AS_TR_CPP(alignof_$3), $AS_TR_SH([ac_cv_alignof_$3]),
                   [The normal alignment of `$1', in bytes.])
 ])# AC_CHECK_ALIGNOF
 
@@ -878,7 +885,8 @@ AC_DEFUN([AC_CHECK_MEMBER],
      INCLUDES, setting cache variable VAR accordingly.])],
     [_$0_BODY])]dnl
 [AS_LITERAL_IF([$1], [], [m4_fatal([$0: requires literal arguments])])]dnl
-[m4_if(m4_index([$1], [.]), -1, [m4_fatal([$0: Did not see any dot in 
`$1'])])]dnl
+[m4_if(m4_index([$1], [.]), [-1],
+  [m4_fatal([$0: Did not see any dot in `$1'])])]dnl
 [AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])]dnl
 [ac_fn_[]_AC_LANG_ABBREV[]_check_member "$LINENO" ]dnl
 [m4_bpatsubst([$1], [^\([^.]*\)\.\(.*\)], ["\1" "\2"]) "ac_Member" ]dnl
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 024498d..2a4faf3 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -628,7 +628,7 @@ as_unset=as_fn_unset])
 # a variable that is not already set.  You should not unset MAIL and
 # MAILCHECK, as that triggers a bug in Bash 2.01.
 m4_defun([AS_UNSET],
-[{ AS_LITERAL_IF([$1], [], [eval ])$1=; unset $1;}])
+[{ AS_LITERAL_WORD_IF([$1], [], [eval ])$1=; unset $1;}])
 
 
 
@@ -1377,17 +1377,17 @@ as_executable_p=$as_test_x
 # Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which
 # must not be `/').
 m4_define([AS_BOX],
-[AS_LITERAL_IF([$1],
-              [_AS_BOX_LITERAL($@)],
-              [_AS_BOX_INDIR($@)])])
+[_$0(m4_expand([$1]), [$2])])
+
+m4_define([_AS_BOX],
+[m4_if(m4_index(m4_translit([[$1]], [`\"], [$$$]), [$]),
+  [-1], [$0_LITERAL], [$0_INDIR])($@)])
 
 
 # _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = `-'])
 # -------------------------------------------------
 m4_define([_AS_BOX_LITERAL],
-[cat <<\_ASBOX
-m4_text_box($@)
-_ASBOX])
+[AS_ECHO(["_AS_ESCAPE(m4_expand([m4_text_box($@)]), [`], [\"$])"])])
 
 
 # _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = `-'])
@@ -1517,17 +1517,31 @@ m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[)) > 
0)], [1], [],
 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], [0], [-])])
 
 
-# AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
+# AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL,
+#               [IF-SIMPLE-REF = IF-NOT-LITERAL])
 # -----------------------------------------------------
-# If EXPRESSION has shell indirections ($var or `expr`), expand
-# IF-LITERAL, else IF-NOT-LITERAL.
-# This is an *approximation*: for instance EXPRESSION = `\$' is
-# definitely a literal, but will not be recognized as such.
+# If EXPRESSION has no shell indirections ($var or `expr`), expand
+# IF-LITERAL, else IF-NOT-LITERAL.  In some cases, IF-NOT-LITERAL
+# must be complex to safely deal with ``, while a simpler
+# expression IF-SIMPLE-REF can be used if the indirection
+# involves only shell variable expansion (as in ${varname}).
+#
+# EXPRESSION is treated as a literal if it results in the same
+# interpretation whether it is unquoted or contained within double
+# quotes, with the exception that whitespace is ignored (on the
+# assumption that it will be flattened to _).  Therefore, neither `\$'
+# nor `a''b' is a literal, since both backslash and single quotes have
+# different quoting behavior in the two contexts; and `a*' is not a
+# literal, because it has different globbing.  Note, however, that
+# while `${a+b}' is neither a literal nor a simple ref, `a+b' is a
+# literal.  This macro is an *approximation*: it is possible that
+# there are some EXPRESSIONs which the shell would treat as literals,
+# but which this macro does not recognize.
 #
 # Why do we reject EXPRESSION expanding with `[' or `]' as a literal?
 # Because AS_TR_SH is MUCH faster if it can use m4_translit on literals
 # instead of m4_bpatsubst; but m4_translit is much tougher to do safely
-# if `[' is translated.
+# if `[' is translated.  That, and file globbing matters.
 #
 # Note that the quadrigraph @S|@ can result in non-literals, but outright
 # rejecting all @ would make AC_INIT complain on its bug report address.
@@ -1535,21 +1549,48 @@ m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], 
[0], [-])])
 # We used to use m4_bmatch(m4_quote($1), [[`$]], [$3], [$2]), but
 # 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, commas, or unbalanced
-# parentheses.  All the problem characters are unified so that a single
-# m4_index can scan the result.
+# Because the translit is stripping quotes, it must also neutralize
+# anything that might be in a macro name, as well as comments, commas,
+# or unbalanced parentheses.  Valid shell variable characters and
+# unambiguous literal characters are deleted (`a.b'), and remaining
+# characters are normalized into `$' if they can form simple refs
+# (${a}), `+' if they can potentially form literals (a+b), ``' if they
+# can interfere with m4 parsing, or left alone otherwise.  If both `$'
+# and `+' are left, it is treated as a complex reference (${a+b}),
+# even though it could technically be a simple reference (${a}+b).
+# _AS_LITERAL_IF_ only has to check for an empty string after removing
+# one of the two normalized characters.
 #
 # Rather than expand m4_defn every time AS_LITERAL_IF is expanded, we
-# inline its expansion up front.
+# inline its expansion up front.  _AS_LITERAL_IF expands to the name
+# of a macro that takes three arguments: IF-SIMPLE-REF,
+# IF-NOT-LITERAL, IF-LITERAL.  It also takes an optional argument of
+# any additional characters to allow as literals (useful for AS_TR_SH
+# and AS_TR_CPP to perform inline conversion of whitespace to _).  The
+# order of the arguments allows reuse of m4_default.
 m4_define([AS_LITERAL_IF],
-[_$0(m4_expand([$1]), [$2], [$3])])
+[_$0(m4_expand([$1]), [         ][
+])([$4], [$3], [$2])])
 
 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])])
+[m4_if(m4_index([$1], address@hidden|@]), [-1], [$0_(m4_translit([$1],
+  [-:%/@{}[]#(),.$2]]]m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[,
+  [+++++$$`````]))], [$0_NO])])
+
+m4_define([_AS_LITERAL_IF_],
+[m4_if(m4_translit([$1], [+]), [], [$0YES],
+       m4_translit([$1], [$]), [], [m4_default], [$0NO])])
+
+m4_define([_AS_LITERAL_IF_YES], [$3])
+m4_define([_AS_LITERAL_IF_NO], [$2])
+
+# AS_LITERAL_WORD_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL,
+#                    [IF-SIMPLE-REF = IF-NOT-LITERAL])
+# ----------------------------------------------------------
+# Like AS_LITERAL_IF, except that spaces and tabs in EXPRESSION
+# are treated as non-literal.
+m4_define([AS_LITERAL_WORD_IF],
+[_AS_LITERAL_IF(m4_expand([$1]))([$4], [$3], [$2])])
 
 
 # AS_TMPDIR(PREFIX, [DIRECTORY = $TMPDIR [= /tmp]])
@@ -1738,7 +1779,8 @@ m4_defun_init([AS_TR_SH],
 [_$0(m4_expand([$1]))])
 
 m4_define([_AS_TR_SH],
-[_AS_LITERAL_IF([$1], [$0_LITERAL], [$0_INDIR])([$1])])
+[_AS_LITERAL_IF([$1], [         ][
+])([], [$0_INDIR], [$0_LITERAL])([$1])])
 
 m4_define([_AS_TR_SH_LITERAL],
 [m4_translit([[$1]],
@@ -1770,7 +1812,8 @@ m4_defun_init([AS_TR_CPP],
 [_$0(m4_expand([$1]))])
 
 m4_define([_AS_TR_CPP],
-[_AS_LITERAL_IF([$1], [$0_LITERAL], [$0_INDIR])([$1])])
+[_AS_LITERAL_IF([$1], [         ][
+])([], [$0_INDIR], [$0_LITERAL])([$1])])
 
 m4_define([_AS_TR_CPP_LITERAL],
 [m4_translit([$1],
@@ -1897,7 +1940,7 @@ m4_defun_init([AS_VAR_ARITH],
 # Set the polymorphic shell variable DEST to the contents of the polymorphic
 # shell variable SOURCE.
 m4_define([AS_VAR_COPY],
-[AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
+[AS_LITERAL_WORD_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
 
 
 # AS_VAR_GET(VARIABLE)
@@ -1908,7 +1951,7 @@ m4_define([AS_VAR_COPY],
 # This macro is deprecated because it sometimes mishandles trailing newlines;
 # use AS_VAR_COPY instead.
 m4_define([AS_VAR_GET],
-[AS_LITERAL_IF([$1],
+[AS_LITERAL_WORD_IF([$1],
               [$$1],
   [`eval 'as_val=${'_AS_ESCAPE([[$1]], [`], [\])'};AS_ECHO(["$as_val"])'`])])
 
@@ -1918,10 +1961,12 @@ m4_define([AS_VAR_GET],
 # Implement a shell `if test $VARIABLE = VALUE; then-else'.
 # Polymorphic, and avoids sh expansion error upon interrupt or term signal.
 m4_define([AS_VAR_IF],
-[AS_LITERAL_IF([$1],
+[AS_LITERAL_WORD_IF([$1],
   [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]],
+  [AS_IF([eval test \"x\$"$1"\" = x"_AS_ESCAPE([$2], [`], [\"$])"]]),
+[$3], [$4])])
 
 
 # AS_VAR_PUSHDEF and AS_VAR_POPDEF
@@ -1972,10 +2017,10 @@ m4_defun_init([AS_VAR_PUSHDEF],
 [_$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]])])])
+[_AS_LITERAL_IF([$2], [         ][
+])([], [as_$1=_AS_TR_SH_INDIR([$2])
+m4_pushdef([$1], [$as_[$1]])],
+[m4_pushdef([$1], [_AS_TR_SH_LITERAL([$2])])])])
 
 
 # AS_VAR_SET(VARIABLE, VALUE)
@@ -1984,9 +2029,9 @@ m4_pushdef([$1], [$as_[$1]])])])
 # expansion of VALUE.  VALUE is immune to field splitting and file
 # name expansion.
 m4_define([AS_VAR_SET],
-[AS_LITERAL_IF([$1],
+[AS_LITERAL_WORD_IF([$1],
               [$1=$2],
-              [eval "$1=AS_ESCAPE([$2])"])])
+              [eval "$1=_AS_ESCAPE([$2], [`], [\"$])"])])
 
 
 # AS_VAR_SET_IF(VARIABLE, IF-TRUE, IF-FALSE)
@@ -2002,9 +2047,10 @@ m4_define([AS_VAR_SET_IF],
 # Expands into the `test' expression which is true if VARIABLE
 # is set.  Polymorphic.
 m4_define([AS_VAR_TEST_SET],
-[AS_LITERAL_IF([$1],
+[AS_LITERAL_WORD_IF([$1],
               [test "${$1+set}" = set],
-              [{ as_var=$1; eval "test \"\${$as_var+set}\" = set"; }])])
+              [{ as_var=$1; eval "test \"\${$as_var+set}\" = set"; }],
+              [eval "test \"\${$1+set}\"" = set])])
 
 
 ## -------------------- ##
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index 15fbd35..95b7bcf 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -2675,11 +2675,11 @@ m4_define([_m4_text_wrap_word],
 # will post-process.
 m4_define([m4_text_box],
 [m4_pushdef([m4_Border],
-           m4_translit(m4_format([%*s], m4_decr(m4_qlen(_m4_expand([$1
+           m4_translit(m4_format([[[%*s]]], m4_decr(m4_qlen(_m4_expand([$1
 ]))), []), [ ], m4_default_quoted([$2], [-])))]dnl
-[[##] m4_Border [##]
+[[##] _m4_defn([m4_Border]) [##]
 [##] $1 [##]
-[##] m4_Border [##]_m4_popdef([m4_Border])])
+[##] _m4_defn([m4_Border]) [##]_m4_popdef([m4_Border])])
 
 
 # m4_qlen(STRING)
diff --git a/tests/m4sh.at b/tests/m4sh.at
index 05cea85..f5ea7e2 100644
--- a/tests/m4sh.at
+++ b/tests/m4sh.at
@@ -124,9 +124,51 @@ AT_CHECK([$CONFIG_SHELL ./script])
 AT_CLEANUP
 
 
-## ------------- ##
-## AS_BASENAME.  ##
-## ------------- ##
+## -------- ##
+## AS_BOX.  ##
+## -------- ##
+
+# Output a framed one-line message.
+AT_SETUP([AS@&address@hidden)
+AT_KEYWORDS([m4sh])
+
+AT_DATA_M4SH([script.as],
+[[AS_INIT
+echo
+AS_BOX([Send a simple message, to address@hidden)
+AS_BOX([Send a simple message, to address@hidden, [$])
+m4_define([msg], [$complex])
+complex='Not quite as simple |$[1]'
+AS_BOX([msg])
+AS_BOX([msg], [,])
+AS_EXIT(0)
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([sed -n '/ -\{44\} /,/ -\{44\} /p' script ]dnl
+[| sed '1 s/.*## -/## -/; 3 s/- ##.*/- ##/'], [],
+[[## -------------------------------------------- ##
+## Send a simple message, to address@hidden ##
+## -------------------------------------------- ##
+]])
+
+AT_CHECK([$CONFIG_SHELL ./script], [], [[
+## -------------------------------------------- ##
+## Send a simple message, to address@hidden ##
+## -------------------------------------------- ##
+## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ##
+## Send a simple message, to address@hidden ##
+## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ##
+## ----------------------- ##
+## Not quite as simple |$1 ##
+## ----------------------- ##
+## ,,,,,,,,,,,,,,,,,,,,,,, ##
+## Not quite as simple |$1 ##
+## ,,,,,,,,,,,,,,,,,,,,,,, ##
+]])
+
+AT_CLEANUP
+
 
 # Strip path from file.
 AT_SETUP([AS@&address@hidden)
@@ -1077,20 +1119,31 @@ AT_CLEANUP
 ## --------------- ##
 
 AT_SETUP([AS@&address@hidden)
-AT_KEYWORDS([m4sh])
+AT_KEYWORDS([m4sh AS@&address@hidden)
 
 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`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
+echo AS_LITERAL_IF([l-/.it], [ok], [ERR]) 2
+echo AS_LITERAL_IF([l''it], [ERR], [ok]) 3
+echo AS_LITERAL_IF([l$it], [ERR], [ok]) 4
+echo AS_LITERAL_IF([l$it], [ERR1], [ERR2], [ok]) 5
+echo AS_LITERAL_IF([l${it}], [ERR1], [ERR2], [ok]) 6
+echo AS_LITERAL_IF([l`case a in b) ;; esac`it], [ERR], [ok]) 7
+echo AS_LITERAL_IF([l`case a in b) ;; esac`it], [ERR1], [ok], [ERR2]) 8
+m4_define([mac], [l-/.it])
+echo AS_LITERAL_IF([mac], [ok], [ERR]) 9
+echo AS_LITERAL_IF([mac($, ``)], [ok], [ERR]) 10
 m4_define([mac], [l$it])
-echo AS_LITERAL_IF([mac], [ERR], [ok]) 6
+echo AS_LITERAL_IF([mac], [ERR], [ok]) 11
+echo AS_LITERAL_IF([mac], [ERR1], [ERR2], [ok]) 12
 m4_define([mac], [l``it])
-echo AS_LITERAL_IF([mac], [ERR], [ok]) 7
+echo AS_LITERAL_IF([mac], [ERR], [ok]) 13
+echo AS_LITERAL_IF([mac], [ERR1], [ok], [ERR2]) 14
+echo AS_LITERAL_IF([   a ][
+b], [ok], [ok]) 15
+echo AS_LITERAL_WORD_IF([      a ][
+b], [ERR], [ok]) 16
 ]])
 
 AT_CHECK_M4SH
@@ -1102,6 +1155,15 @@ ok 4
 ok 5
 ok 6
 ok 7
+ok 8
+ok 9
+ok 10
+ok 11
+ok 12
+ok 13
+ok 14
+ok 15
+ok 16
 ]])
 
 AT_CLEANUP
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
index 7069309..50a7b00 100644
--- a/tests/m4sugar.at
+++ b/tests/m4sugar.at
@@ -1130,6 +1130,30 @@ a
 AT_CLEANUP
 
 
+## ------------- ##
+## m4_text_box.  ##
+## ------------- ##
+
+AT_SETUP([m4@&address@hidden)
+
+AT_CHECK_M4SUGAR_TEXT([[
+m4_text_box([a $1 @&address@hidden)
+m4_text_box([a $1 @&address@hidden, [$])
+m4_text_box([a $1 @&address@hidden, [,])
+]], [[
+## ------ ##
+## a $1 b ##
+## ------ ##
+## $$$$$$ ##
+## a $1 b ##
+## $$$$$$ ##
+## ,,,,,, ##
+## a $1 b ##
+## ,,,,,, ##
+]])
+
+AT_CLEANUP
+
 ## -------------- ##
 ## m4_text_wrap.  ##
 ## -------------- ##


hooks/post-receive
-- 
GNU Autoconf source repository



reply via email to

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