m4-commit
[Top][All Lists]
Advanced

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

Changes to m4/m4/macro.c,v


From: Eric Blake
Subject: Changes to m4/m4/macro.c,v
Date: Thu, 12 Oct 2006 21:14:52 +0000

CVSROOT:        /sources/m4
Module name:    m4
Changes by:     Eric Blake <ericb>      06/10/12 21:14:50

Index: m4/macro.c
===================================================================
RCS file: /sources/m4/m4/m4/macro.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -b -r1.58 -r1.59
--- m4/macro.c  10 Oct 2006 12:47:23 -0000      1.58
+++ m4/macro.c  12 Oct 2006 21:14:50 -0000      1.59
@@ -98,7 +98,7 @@
 
     case M4_TOKEN_WORD:
       {
-       char *textp = text;
+       unsigned char *textp = text;
 
        if (m4_has_syntax (M4SYNTAX, *textp, M4_SYNTAX_ESCAPE))
          ++textp;
@@ -108,7 +108,7 @@
        if (symbol == NULL
            || (symbol->value->type == M4_SYMBOL_FUNC
                && BIT_TEST (SYMBOL_FLAGS (symbol), VALUE_BLIND_ARGS_BIT)
-               && m4__peek_token (context) != M4_TOKEN_OPEN))
+               && ! m4__next_token_is_open (context)))
          {
            m4_shipout_text (context, obs, text, strlen (text));
          }
@@ -138,7 +138,7 @@
 {
   m4__token_type type;
   m4_symbol_value token;
-  char *text;
+  unsigned char *text;
   int paren_level = 0;
   const char *file = m4_get_current_file (context);
   int line = m4_get_current_line (context);
@@ -229,6 +229,17 @@
   size_t my_call_id;
   m4_symbol_value *value;
 
+  /* Report errors at the location where the open parenthesis (if any)
+     was found, but after expansion, restore global state back to the
+     location of the close parenthesis.  This is safe since we
+     guarantee that macro expansion does not alter the state of
+     current_file/current_line (dnl, include, and sinclude are special
+     cased in the input engine to ensure this fact).  */
+  const char *loc_open_file = m4_get_current_file (context);
+  int loc_open_line = m4_get_current_line (context);
+  const char *loc_close_file;
+  int loc_close_line;
+
   /* Grab the current value of this macro, because it may change while
      collecting arguments.  Likewise, grab any state needed during
      tracing.  */
@@ -261,6 +272,11 @@
   argc = obstack_object_size (&argptr) / sizeof (m4_symbol_value *);
   argv = (m4_symbol_value **) obstack_finish (&argptr);
 
+  loc_close_file = m4_get_current_file (context);
+  loc_close_line = m4_get_current_line (context);
+  m4_set_current_file (context, loc_open_file);
+  m4_set_current_line (context, loc_open_line);
+
   if (traced)
     trace_pre (context, name, my_call_id, argc, argv);
 
@@ -272,6 +288,9 @@
     trace_post (context, name, my_call_id, argc, argv, expanded,
                trace_expansion);
 
+  m4_set_current_file (context, loc_close_file);
+  m4_set_current_line (context, loc_close_line);
+
   --expansion_level;
   --VALUE_PENDING (value);
   if (BIT_TEST (VALUE_FLAGS (value), VALUE_DELETED_BIT))
@@ -300,7 +319,7 @@
                                      sizeof (token));
   obstack_grow (argptr, (void *) &tokenp, sizeof (tokenp));
 
-  if (m4__peek_token (context) == M4_TOKEN_OPEN)
+  if (m4__next_token_is_open (context))
     {
       m4__next_token (context, &token);                /* gobble parenthesis */
       do
@@ -421,8 +440,8 @@
          else
            {
              size_t       len  = 0;
-             const char * endp;
-             const char * key;
+             const unsigned char *endp;
+             const char *key;
 
              for (endp = ++text;
                   *endp && m4_has_syntax (M4SYNTAX, *endp,




reply via email to

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