m4-commit
[Top][All Lists]
Advanced

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

[SCM] GNU M4 source repository branch, master, updated. 7c180fa335356cd5


From: Eric Blake
Subject: [SCM] GNU M4 source repository branch, master, updated. 7c180fa335356cd55727a75979554b0d6f1e2c2c
Date: Thu, 01 Nov 2007 13:21:11 +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 M4 source repository".

http://git.sv.gnu.org/gitweb/?p=m4.git;a=commitdiff;h=7c180fa335356cd55727a75979554b0d6f1e2c2c

The branch, master has been updated
       via  7c180fa335356cd55727a75979554b0d6f1e2c2c (commit)
      from  8cf99d7ccdace1cddb3db6a127634afc6dcf06b5 (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 7c180fa335356cd55727a75979554b0d6f1e2c2c
Author: Eric Blake <address@hidden>
Date:   Thu Nov 1 07:08:35 2007 -0600

    Improve error message when early end of file occurs.
    
    * doc/m4.texinfo (Macro Arguments, Changequote, Changecom)
    (M4wrap): Adjust to new messages.
    (Improved capitalize): Enhance test.
    * m4/m4private.h (m4__next_token): Adjust prototype.
    * m4/input.c (m4__next_token): Add new parameter, and improve
    error message.
    * m4/macro.c (m4_macro_expand_input, collect_arguments): Adjust
    callers.
    (expand_argument): Likewise, and add parameter.
    
    Signed-off-by: Eric Blake <address@hidden>

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

Summary of changes:
 ChangeLog      |   13 +++++++++++++
 doc/m4.texinfo |   30 ++++++++++++++++++++----------
 m4/input.c     |   19 +++++++++++++++----
 m4/m4private.h |    3 ++-
 m4/macro.c     |   35 ++++++++++++++++++++---------------
 5 files changed, 70 insertions(+), 30 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f953db2..4e3e81d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2007-11-01  Eric Blake  <address@hidden>
+
+       Improve error message when early end of file occurs.
+       * doc/m4.texinfo (Macro Arguments, Changequote, Changecom)
+       (M4wrap): Adjust to new messages.
+       (Improved capitalize): Enhance test.
+       * m4/m4private.h (m4__next_token): Adjust prototype.
+       * m4/input.c (m4__next_token): Add new parameter, and improve
+       error message.
+       * m4/macro.c (m4_macro_expand_input, collect_arguments): Adjust
+       callers.
+       (expand_argument): Likewise, and add parameter.
+
 2007-10-31  Eric Blake  <address@hidden>
 
        Test more corner cases.
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index 4014344..0265f27 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -1656,7 +1656,7 @@ hello world
 @result{}hello world
 define(
 ^D
address@hidden:stdin:2: end of file in argument list
address@hidden:stdin:2: define: end of file in argument list
 @end example
 
 @node Quoting Arguments
@@ -4198,6 +4198,13 @@ It is an error if the end of file occurs within a quoted 
string.
 @error{}m4:stdin:2: end of file in string
 @end example
 
address@hidden status: 1
address@hidden
+ifelse(`dangling quote
+^D
address@hidden:stdin:1: ifelse: end of file in string
address@hidden example
+
 @node Changecom
 @section Changing the comment delimiters
 
@@ -4354,6 +4361,15 @@ changecom(`/*', `*/')
 @error{}m4:stdin:2: end of file in comment
 @end example
 
address@hidden status: 1
address@hidden
+changecom(`/*', `*/')
address@hidden
+len(/*dangling comment
+^D
address@hidden:stdin:2: len: end of file in comment
address@hidden example
+
 @node Changeresyntax
 @section Changing the regular expression syntax
 
@@ -4950,7 +4966,7 @@ file condition between two input files.
 m4wrap(`m4wrap(`)')len(abc')
 @result{}
 ^D
address@hidden:stdin:1: end of file in argument list
address@hidden:stdin:1: len: end of file in argument list
 @end example
 
 @node File Inclusion
@@ -8523,14 +8539,8 @@ define(`active', `act1, ive')dnl
 define(`Active', `Act2, Ive')dnl
 define(`ACTIVE', `ACT3, IVE')dnl
 define(`A', `OOPS')dnl
-capitalize(active)
address@hidden,Ive
-capitalize(`active')
address@hidden, Ive
-capitalize(``active'')
address@hidden
-capitalize(```actIVE''')
address@hidden'
+capitalize(active; `active'; ``active''; ```actIVE''')
address@hidden,Ive; Act2, Ive; Active; `Active'
 undivert(`capitalize2.m4')dnl
 @result{}divert(`-1')
 @result{}# upcase(text)
diff --git a/m4/input.c b/m4/input.c
index e5e7c92..646a169 100644
--- a/m4/input.c
+++ b/m4/input.c
@@ -577,7 +577,7 @@ composite_read (m4_input_block *me, m4 *context, bool retry)
 
   /* See if current block has real character.  */
   ch = subblock->funcs->read_func (subblock, context, retry);
-  if (ch != CHAR_RETRY || ! retry)
+  if (ch != CHAR_RETRY || !retry)
     {
       me->line = subblock->line;
       return ch;
@@ -740,7 +740,7 @@ init_builtin_token (m4 *context, m4_symbol_value *token)
   m4_input_block *block = isp;
   if (block->funcs == &composite_funcs)
     block = block->u.u_c.current;
-  assert (block->funcs->read_func == builtin_read && ! block->u.u_b.read);
+  assert (block->funcs->read_func == builtin_read && !block->u.u_b.read);
 
   m4_set_symbol_value_builtin (token, block->u.u_b.builtin);
   VALUE_MODULE (token)         = block->u.u_b.module;
@@ -777,7 +777,7 @@ next_char (m4 *context, bool retry)
 
       assert (isp->funcs->read_func);
       while ((ch = isp->funcs->read_func (isp, context, retry)) != CHAR_RETRY
-            || ! retry)
+            || !retry)
        {
          /* if (!IS_IGNORE (ch)) */
          return ch;
@@ -992,6 +992,8 @@ m4_input_exit (void)
    that is a potential macro name; and M4_TOKEN_SIMPLE for any single
    character that is not a part of any of the previous types.  If LINE
    is not NULL, set *LINE to the line number where the token starts.
+   Report errors (unterminated comments or strings) on behalf of
+   CALLER, if non-NULL.
 
    M4__next_token () returns the token type, and passes back a pointer to
    the token data through TOKEN.  The token text is collected on the obstack
@@ -999,7 +1001,8 @@ m4_input_exit (void)
    The storage pointed to by the fields in TOKEN is therefore subject to
    change the next time m4__next_token () is called.  */
 m4__token_type
-m4__next_token (m4 *context, m4_symbol_value *token, int *line)
+m4__next_token (m4 *context, m4_symbol_value *token, int *line,
+               const char *caller)
 {
   int ch;
   int quote_level;
@@ -1069,6 +1072,8 @@ m4__next_token (m4 *context, m4_symbol_value *token, int 
*line)
            ch = next_char (context, true);
            if (ch == CHAR_EOF)
              m4_error_at_line (context, EXIT_FAILURE, 0, file, *line,
+                               "%s%s%s", caller ? caller : "",
+                               caller ? ": " : "",
                                _("end of file in string"));
 
            if (m4_has_syntax (M4SYNTAX, ch, M4_SYNTAX_RQUOTE))
@@ -1096,6 +1101,8 @@ m4__next_token (m4 *context, m4_symbol_value *token, int 
*line)
            ch = next_char (context, true);
            if (ch == CHAR_EOF)
              m4_error_at_line (context, EXIT_FAILURE, 0, file, *line,
+                               "%s%s%s", caller ? caller : "",
+                               caller ? ": " : "",
                                _("end of file in string"));
            if (MATCH (context, ch, context->syntax->rquote.string, true))
              {
@@ -1125,6 +1132,8 @@ m4__next_token (m4 *context, m4_symbol_value *token, int 
*line)
          obstack_1grow (&token_stack, ch);
        else
          m4_error_at_line (context, EXIT_FAILURE, 0, file, *line,
+                           "%s%s%s", caller ? caller : "",
+                           caller ? ": " : "",
                            _("end of file in comment"));
        type = (m4_get_discard_comments_opt (context)
                ? M4_TOKEN_NONE : M4_TOKEN_STRING);
@@ -1142,6 +1151,8 @@ m4__next_token (m4 *context, m4_symbol_value *token, int 
*line)
                        context->syntax->ecomm.length);
        else
          m4_error_at_line (context, EXIT_FAILURE, 0, file, *line,
+                           "%s%s%s", caller ? caller : "",
+                           caller ? ": " : "",
                            _("end of file in comment"));
        type = (m4_get_discard_comments_opt (context)
                ? M4_TOKEN_NONE : M4_TOKEN_STRING);
diff --git a/m4/m4private.h b/m4/m4private.h
index a616ca9..9d8a089 100644
--- a/m4/m4private.h
+++ b/m4/m4private.h
@@ -344,7 +344,8 @@ typedef enum {
   M4_TOKEN_MACDEF              /* a macro's definition (see "defn") */
 } m4__token_type;
 
-extern m4__token_type  m4__next_token (m4 *, m4_symbol_value *, int *);
+extern m4__token_type  m4__next_token (m4 *, m4_symbol_value *, int *,
+                                       const char *);
 extern bool            m4__next_token_is_open (m4 *);
 
 
diff --git a/m4/macro.c b/m4/macro.c
index 3628a49..2108c99 100644
--- a/m4/macro.c
+++ b/m4/macro.c
@@ -34,7 +34,8 @@ static void    collect_arguments (m4 *, const char *, 
m4_symbol *,
 static void    expand_macro      (m4 *, const char *, m4_symbol *);
 static void    expand_token      (m4 *, m4_obstack *, m4__token_type,
                                  m4_symbol_value *, int);
-static bool    expand_argument   (m4 *, m4_obstack *, m4_symbol_value *);
+static bool    expand_argument   (m4 *, m4_obstack *, m4_symbol_value *,
+                                 const char *);
 static void    process_macro    (m4 *, m4_symbol_value *, m4_obstack *, int,
                                  m4_symbol_value **);
 
@@ -81,7 +82,8 @@ m4_macro_expand_input (m4 *context)
   obstack_init (&argc_stack);
   obstack_init (&argv_stack);
 
-  while ((type = m4__next_token (context, &token, &line)) != M4_TOKEN_EOF)
+  while ((type = m4__next_token (context, &token, &line, NULL))
+        != M4_TOKEN_EOF)
     expand_token (context, (m4_obstack *) NULL, type, &token, line);
 
   obstack_free (&argc_stack, NULL);
@@ -144,15 +146,17 @@ expand_token (m4 *context, m4_obstack *obs,
 }
 
 
-/* This function parses one argument to a macro call.  It expects the first
-   left parenthesis, or the separating comma to have been read by the
-   caller.  It skips leading whitespace, and reads and expands tokens,
-   until it finds a comma or a right parenthesis at the same level of
-   parentheses.  It returns a flag indicating whether the argument read is
-   the last for the active macro call.  The arguments are built on the
-   obstack OBS, indirectly through expand_token ().  */
+/* This function parses one argument to a macro call.  It expects the
+   first left parenthesis or the separating comma to have been read by
+   the caller.  It skips leading whitespace, then reads and expands
+   tokens, until it finds a comma or a right parenthesis at the same
+   level of parentheses.  It returns a flag indicating whether the
+   argument read is the last for the active macro call.  The arguments
+   are built on the obstack OBS, indirectly through expand_token ().
+   Report errors on behalf of CALLER.  */
 static bool
-expand_argument (m4 *context, m4_obstack *obs, m4_symbol_value *argp)
+expand_argument (m4 *context, m4_obstack *obs, m4_symbol_value *argp,
+                const char *caller)
 {
   m4__token_type type;
   m4_symbol_value token;
@@ -166,7 +170,7 @@ expand_argument (m4 *context, m4_obstack *obs, 
m4_symbol_value *argp)
   /* Skip leading white space.  */
   do
     {
-      type = m4__next_token (context, &token, NULL);
+      type = m4__next_token (context, &token, NULL, caller);
     }
   while (type == M4_TOKEN_SPACE);
 
@@ -202,7 +206,7 @@ expand_argument (m4 *context, m4_obstack *obs, 
m4_symbol_value *argp)
 
        case M4_TOKEN_EOF:
           m4_error_at_line (context, EXIT_FAILURE, 0, file, line,
-                            _("end of file in argument list"));
+                            _("%s: end of file in argument list"), caller);
          break;
 
        case M4_TOKEN_WORD:
@@ -221,7 +225,7 @@ expand_argument (m4 *context, m4_obstack *obs, 
m4_symbol_value *argp)
          abort ();
        }
 
-      type = m4__next_token (context, &token, NULL);
+      type = m4__next_token (context, &token, NULL, caller);
     }
 }
 
@@ -350,14 +354,15 @@ collect_arguments (m4 *context, const char *name, 
m4_symbol *symbol,
   tokenp = (m4_symbol_value *) obstack_alloc (arguments, sizeof *tokenp);
   m4_set_symbol_value_text (tokenp, (char *) obstack_copy0 (arguments, name,
                                                            strlen (name)));
+  name = m4_get_symbol_value_text (tokenp);
   obstack_ptr_grow (argptr, tokenp);
 
   if (m4__next_token_is_open (context))
     {
-      m4__next_token (context, &token, NULL); /* gobble parenthesis */
+      m4__next_token (context, &token, NULL, name); /* gobble parenthesis */
       do
        {
-         more_args = expand_argument (context, arguments, &token);
+         more_args = expand_argument (context, arguments, &token, name);
 
          if (!groks_macro_args && m4_is_symbol_value_func (&token))
            {


hooks/post-receive
--
GNU M4 source repository




reply via email to

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