]> gcc.gnu.org Git - gcc.git/commitdiff
cpplib.h (parse_underflow_t, [...]): Delete.
authorZack Weinberg <zack@wolery.cumb.org>
Wed, 8 Mar 2000 20:37:23 +0000 (20:37 +0000)
committerZack Weinberg <zack@gcc.gnu.org>
Wed, 8 Mar 2000 20:37:23 +0000 (20:37 +0000)
* cpplib.h (parse_underflow_t, CPP_NULL_BUFFER): Delete.
(struct cpp_buffer): Remove fname and underflow fields.
(struct cpp_reader): Remove get_token field.
(struct include_hash): Rename to struct ihash.  Add typedef to
IHASH.
(struct if_stack): Remove fname field.
(IF_STACK_FRAME): Rename to IF_STACK.

* cpperror.c (print_containing_files): Trust that there are no
macro buffers below the top file buffer.
* cppfiles.c: Replace all references to 'struct include_hash'
with 'IHASH'.  Rename initialize_input_buffer to
init_input_buffer.  Don't set or reference cpp_buffer->fname,
use buffer->ihash->name instead.
* cpphash.c (special_symbol): Use cpp_file_buffer.  Use NULL
not CPP_NULL_BUFFER.
* cppinit.c: Use NULL not CPP_NULL_BUFFER, IF_STACK not
IF_STACK_FRAME, IHASH not struct include_hash.
* cpplib.c: Rename eval_if_expression to eval_if_expr.  Remove
null_underflow.  Use IF_STACK not IF_STACK_FRAME, IHASH not
struct include_hash, NULL not CPP_NULL_BUFFER.  Remove all
references to cpp_buffer->fname (delete entirely, or use
->ihash->name instead) and IF_STACK->fname.
(cpp_push_buffer): Don't set new->underflow.
(do_include): Use cpp_file_buffer.

* cpphash.c (collect_formal_parameters): Remove duplicate
increment of argslen.  Pedwarn in C99 mode if __VA_ARGS__ is
used as a macro argument name.  Don't append "..." to namebuf
for varargs macros.  After we're done scanning, go through
namebuf and make it NUL separated, not comma separated.
(_cpp_compare_defs): Remove register tag from variables.
Expect defn->argnames to be NUL separated.
(_cpp_dump_definition): Expect defn->argnames to be NUL
separated and in forward order.
* cpphash.h: Update documentation of argnames field.

From-SVN: r32430

gcc/ChangeLog
gcc/cpperror.c
gcc/cppfiles.c
gcc/cpphash.c
gcc/cpphash.h
gcc/cppinit.c
gcc/cpplib.c
gcc/cpplib.h

index b3a8130d86c7e4821c0bca2b30ecfbf3773f66b4..be50eae86910d59611d3324692ff40a0565c2c10 100644 (file)
@@ -1,3 +1,42 @@
+2000-03-08  Zack Weinberg  <zack@wolery.cumb.org>
+
+       * cpplib.h (parse_underflow_t, CPP_NULL_BUFFER): Delete.
+       (struct cpp_buffer): Remove fname and underflow fields.
+       (struct cpp_reader): Remove get_token field.
+       (struct include_hash): Rename to struct ihash.  Add typedef to
+       IHASH.
+       (struct if_stack): Remove fname field.
+       (IF_STACK_FRAME): Rename to IF_STACK.
+
+       * cpperror.c (print_containing_files): Trust that there are no
+       macro buffers below the top file buffer.
+       * cppfiles.c: Replace all references to 'struct include_hash'
+       with 'IHASH'.  Rename initialize_input_buffer to
+       init_input_buffer.  Don't set or reference cpp_buffer->fname,
+       use buffer->ihash->name instead.
+       * cpphash.c (special_symbol): Use cpp_file_buffer.  Use NULL
+       not CPP_NULL_BUFFER.
+       * cppinit.c: Use NULL not CPP_NULL_BUFFER, IF_STACK not
+       IF_STACK_FRAME, IHASH not struct include_hash.
+       * cpplib.c: Rename eval_if_expression to eval_if_expr.  Remove
+       null_underflow.  Use IF_STACK not IF_STACK_FRAME, IHASH not
+       struct include_hash, NULL not CPP_NULL_BUFFER.  Remove all
+       references to cpp_buffer->fname (delete entirely, or use
+       ->ihash->name instead) and IF_STACK->fname.
+       (cpp_push_buffer): Don't set new->underflow.
+       (do_include): Use cpp_file_buffer.
+
+       * cpphash.c (collect_formal_parameters): Remove duplicate
+       increment of argslen.  Pedwarn in C99 mode if __VA_ARGS__ is
+       used as a macro argument name.  Don't append "..." to namebuf
+       for varargs macros.  After we're done scanning, go through
+       namebuf and make it NUL separated, not comma separated.
+       (_cpp_compare_defs): Remove register tag from variables.
+       Expect defn->argnames to be NUL separated.
+       (_cpp_dump_definition): Expect defn->argnames to be NUL
+       separated and in forward order.
+       * cpphash.h: Update documentation of argnames field.
+
 2000-03-08  Richard Henderson  <rth@cygnus.com>
 
        * builtins.c (expand_builtin_strlen): Be prepared for strlensi
index 577840b3e9743aa6cc47e4fdad89993a33f64428..969907b537c3ffa6f7ac58164bb040cdc6216962 100644 (file)
@@ -50,34 +50,31 @@ print_containing_files (pfile, ip)
     return;
 
   /* Find the other, outer source files.  */
-  for (ip = CPP_PREV_BUFFER (ip);
-       ip != CPP_NULL_BUFFER (pfile);
-       ip = CPP_PREV_BUFFER (ip))
-    if (ip->fname != NULL)
-      {
-       long line;
-       cpp_buf_line_and_col (ip, &line, NULL);
-       if (first)
-         {
-           first = 0;
-           fprintf (stderr,  _("In file included from %s:%ld"),
-                    ip->nominal_fname, line);
-         }
-       else
-         /* Translators note: this message is used in conjunction
-            with "In file included from %s:%ld" and some other
-            tricks.  We want something like this:
-
-            In file included from sys/select.h:123,
-                             from sys/types.h:234,
-                             from userfile.c:31:
-            bits/select.h:45: <error message here>
-
-            The trailing comma is at the beginning of this message,
-            and the trailing colon is not translated.  */
-         fprintf (stderr, _(",\n                 from %s:%ld"),
+  for (ip = CPP_PREV_BUFFER (ip); ip != NULL; ip = CPP_PREV_BUFFER (ip))
+    {
+      long line;
+      cpp_buf_line_and_col (ip, &line, NULL);
+      if (first)
+       {
+         first = 0;
+         fprintf (stderr,  _("In file included from %s:%ld"),
                   ip->nominal_fname, line);
-      }
+       }
+      else
+       /* Translators note: this message is used in conjunction
+          with "In file included from %s:%ld" and some other
+          tricks.  We want something like this:
+
+          In file included from sys/select.h:123,
+                           from sys/types.h:234,
+                           from userfile.c:31:
+          bits/select.h:45: <error message here>
+
+          The trailing comma is at the beginning of this message,
+          and the trailing colon is not translated.  */
+       fprintf (stderr, _(",\n                 from %s:%ld"),
+                ip->nominal_fname, line);
+    }
   if (first == 0)
     fputs (":\n", stderr);
 
index dc56b24ada5c4300050d4920962c510592427697..f4d2423b285f8f01c04d89dc5146eacbfc4fdbfd 100644 (file)
@@ -29,26 +29,21 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #include "cpplib.h"
 #include "intl.h"
 
-static struct include_hash *include_hash PARAMS ((cpp_reader *,
-                                                 const char *, int));
-static struct include_hash *redundant_include_p
-                                       PARAMS ((cpp_reader *,
-                                                struct include_hash *,
-                                                struct file_name_list *));
+static IHASH *include_hash     PARAMS ((cpp_reader *, const char *, int));
+static IHASH *redundant_include_p PARAMS ((cpp_reader *, IHASH *,
+                                          struct file_name_list *));
 static struct file_name_map *read_name_map
-                                       PARAMS ((cpp_reader *, const char *));
-static char *read_filename_string      PARAMS ((int, FILE *));
-static char *remap_filename            PARAMS ((cpp_reader *, char *,
-                                                struct file_name_list *));
-static long read_and_prescan           PARAMS ((cpp_reader *, cpp_buffer *,
-                                                int, size_t));
+                               PARAMS ((cpp_reader *, const char *));
+static char *read_filename_string PARAMS ((int, FILE *));
+static char *remap_filename    PARAMS ((cpp_reader *, char *,
+                                        struct file_name_list *));
+static long read_and_prescan   PARAMS ((cpp_reader *, cpp_buffer *,
+                                        int, size_t));
 static struct file_name_list *actual_directory
-                                       PARAMS ((cpp_reader *, const char *));
-static void initialize_input_buffer    PARAMS ((cpp_reader *, int,
-                                                struct stat *));
-static int file_cleanup                        PARAMS ((cpp_buffer *, cpp_reader *));
-static U_CHAR *find_position           PARAMS ((U_CHAR *, U_CHAR *,
-                                                unsigned long *));
+                               PARAMS ((cpp_reader *, const char *));
+static void init_input_buffer  PARAMS ((cpp_reader *, int, struct stat *));
+static int file_cleanup                PARAMS ((cpp_buffer *, cpp_reader *));
+static U_CHAR *find_position   PARAMS ((U_CHAR *, U_CHAR *, unsigned long *));
 
 #if 0
 static void hack_vms_include_specification PARAMS ((char *));
@@ -205,14 +200,14 @@ _cpp_merge_include_chains (opts)
  #include name (there are at least three ways this can happen).  The
  hash function could probably be improved a bit. */
 
-static struct include_hash *
+static IHASH *
 include_hash (pfile, fname, add)
      cpp_reader *pfile;
      const char *fname;
      int add;
 {
   unsigned int hash = 0;
-  struct include_hash *l, *m;
+  IHASH *l, *m;
   const char *f = fname;
 
   while (*f)
@@ -227,7 +222,7 @@ include_hash (pfile, fname, add)
   if (!add)
     return 0;
   
-  l = (struct include_hash *) xmalloc (sizeof (struct include_hash));
+  l = (IHASH *) xmalloc (sizeof (IHASH));
   l->next = NULL;
   l->next_this_file = NULL;
   l->foundhere = NULL;
@@ -263,14 +258,14 @@ include_hash (pfile, fname, add)
    so the test below (i->foundhere == l) may be false even when
    the directories are in fact the same.  */
 
-static struct include_hash *
+static IHASH *
 redundant_include_p (pfile, ihash, ilist)
      cpp_reader *pfile;
-     struct include_hash *ihash;
+     IHASH *ihash;
      struct file_name_list *ilist;
 {
   struct file_name_list *l;
-  struct include_hash *i;
+  IHASH *i;
 
   if (! ihash->foundhere)
     return 0;
@@ -285,7 +280,7 @@ redundant_include_p (pfile, ihash, ilist)
         return (i->control_macro
                 && (i->control_macro[0] == '\0'
                     || cpp_defined (pfile, i->control_macro, -1)))
-            ? (struct include_hash *)-1 : i;
+            ? (IHASH *)-1 : i;
 
   return 0;
 }
@@ -297,7 +292,7 @@ cpp_included (pfile, fname)
      cpp_reader *pfile;
      const char *fname;
 {
-  struct include_hash *ptr;
+  IHASH *ptr;
 
   ptr = include_hash (pfile, fname, 0);
   return (ptr != NULL);
@@ -330,11 +325,11 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before)
      cpp_reader *pfile;
      const char *fname;
      struct file_name_list *search_start;
-     struct include_hash **ihash;
+     IHASH **ihash;
      int *before;
 {
   struct file_name_list *l;
-  struct include_hash *ih, *jh;
+  IHASH *ih, *jh;
   int f, len;
   char *name;
   
@@ -347,7 +342,7 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before)
       *before = 1;
       *ihash = jh;
 
-      if (jh == (struct include_hash *)-1)
+      if (jh == (IHASH *)-1)
        return -2;
       else
        return open (jh->name, O_RDONLY, 0666);
@@ -358,7 +353,7 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before)
        Allocate another include_hash block and add it to the next_this_file
        chain. */
     {
-      jh = (struct include_hash *)xmalloc (sizeof (struct include_hash));
+      jh = (IHASH *) xmalloc (sizeof (IHASH));
       while (ih->next_this_file) ih = ih->next_this_file;
 
       ih->next_this_file = jh;
@@ -422,7 +417,7 @@ _cpp_find_include_file (pfile, fname, search_start, ihash, before)
        free (ih);
       }
     free (name);
-    *ihash = (struct include_hash *)-1;
+    *ihash = (IHASH *)-1;
     return -1;
 }
 
@@ -627,7 +622,7 @@ cpp_read_file (pfile, fname)
      cpp_reader *pfile;
      const char *fname;
 {
-  struct include_hash *ih_fake;
+  IHASH *ih_fake;
   int f;
 
   if (fname == NULL || *fname == 0)
@@ -655,7 +650,7 @@ cpp_read_file (pfile, fname)
   /* Gin up an include_hash structure for this file and feed it
      to finclude.  */
 
-  ih_fake = (struct include_hash *) xmalloc (sizeof (struct include_hash));
+  ih_fake = (IHASH *) xmalloc (sizeof (IHASH));
   ih_fake->next = 0;
   ih_fake->next_this_file = 0;
   ih_fake->foundhere = ABSOLUTE_PATH;  /* well sort of ... */
@@ -687,7 +682,7 @@ int
 _cpp_read_include_file (pfile, fd, ihash)
      cpp_reader *pfile;
      int fd;
-     struct include_hash *ihash;
+     IHASH *ihash;
 {
   struct stat st;
   size_t st_size;
@@ -749,12 +744,12 @@ _cpp_read_include_file (pfile, fd, ihash)
     }
 
   if (pfile->input_buffer == NULL)
-    initialize_input_buffer (pfile, fd, &st);
+    init_input_buffer (pfile, fd, &st);
 
   /* Read the file, converting end-of-line characters and trigraphs
      (if enabled). */
   fp->ihash = ihash;
-  fp->nominal_fname = fp->fname = ihash->name;
+  fp->nominal_fname = ihash->name;
   length = read_and_prescan (pfile, fp, fd, st_size);
   if (length < 0)
     goto fail;
@@ -774,7 +769,7 @@ _cpp_read_include_file (pfile, fd, ihash)
   /* The ->actual_dir field is only used when ignore_srcdir is not in effect;
      see do_include */
   if (!CPP_OPTIONS (pfile)->ignore_srcdir)
-    fp->actual_dir = actual_directory (pfile, fp->fname);
+    fp->actual_dir = actual_directory (pfile, ihash->name);
 
   pfile->input_stack_listing_current = 0;
   return 1;
@@ -1176,7 +1171,7 @@ read_and_prescan (pfile, fp, desc, len)
   return -1;
 
  error:
-  cpp_error_from_errno (pfile, fp->fname);
+  cpp_error_from_errno (pfile, fp->ihash->name);
   free (buf);
   return -1;
 }
@@ -1187,7 +1182,7 @@ read_and_prescan (pfile, fp, desc, len)
    the duration of the cpp run.  */
 
 static void
-initialize_input_buffer (pfile, fd, st)
+init_input_buffer (pfile, fd, st)
      cpp_reader *pfile;
      int fd;
      struct stat *st;
index 410c9162cb18db5e8465a8741a47b998d7516f72..fc4051b8d4c914e91109ba5c483bbc5ad8f303c1 100644 (file)
@@ -548,7 +548,7 @@ collect_formal_parameters (pfile)
 {
   struct arglist *result = 0;
   struct arg *argv = 0;
-  U_CHAR *namebuf = xstrdup ("");
+  U_CHAR *namebuf = (U_CHAR *) xstrdup ("");
 
   U_CHAR *name, *tok;
   size_t argslen = 1;
@@ -587,6 +587,10 @@ collect_formal_parameters (pfile)
              cpp_error (pfile, "duplicate macro argument name `%s'", tok);
              continue;
            }
+         if (CPP_PEDANTIC (pfile) && CPP_OPTIONS (pfile)->c99
+             && strncmp (tok, "__VA_ARGS__", sizeof "__VA_ARGS__" - 1))
+           cpp_pedwarn (pfile,
+       "C99 does not permit use of `__VA_ARGS__' as a macro argument name");
          namebuf = xrealloc (namebuf, argslen + len + 1);
          name = &namebuf[argslen - 1];
          argslen += len + 1;
@@ -637,8 +641,6 @@ collect_formal_parameters (pfile)
       name = &namebuf[argslen - 1];
       argslen += len;
       memcpy (name, "__VA_ARGS__", len);
-
-      argslen += len + 1;
       argv[argc].len = len;
     }
   else
@@ -646,9 +648,6 @@ collect_formal_parameters (pfile)
       cpp_pedwarn (pfile, "ISO C does not permit named varargs macros");
 
   argv[argc].rest_arg = 1;
-  namebuf = xrealloc (namebuf, argslen + 3);
-  memcpy (&namebuf[argslen - 1], "...", 4);
-  argslen += 3;
   
   token = get_directive_token (pfile);
   if (token != CPP_RPAREN)
@@ -664,6 +663,7 @@ collect_formal_parameters (pfile)
     {
       argv[i].name = namebuf + len;
       len += argv[i].len + 1;
+      namebuf[len - 1] = '\0';
     }
 
   CPP_SET_WRITTEN (pfile, old_written);
@@ -834,16 +834,10 @@ special_symbol (hp, pfile)
     case T_FILE:
     case T_BASE_FILE:
       {
-       ip = CPP_BUFFER (pfile);
+       ip = cpp_file_buffer (pfile);
        if (hp->type == T_BASE_FILE)
          {
-           while (CPP_PREV_BUFFER (ip) != CPP_NULL_BUFFER (pfile))
-             ip = CPP_PREV_BUFFER (ip);
-         }
-       else
-         {
-           ip = CPP_BUFFER (pfile);
-           while (!ip->nominal_fname && ip != CPP_NULL_BUFFER (pfile))
+           while (CPP_PREV_BUFFER (ip) != NULL)
              ip = CPP_PREV_BUFFER (ip);
          }
 
@@ -858,11 +852,10 @@ special_symbol (hp, pfile)
 
     case T_INCLUDE_LEVEL:
       {
-       int true_indepth = 0;
-       ip = CPP_BUFFER (pfile);
-       for (; ip != CPP_NULL_BUFFER (pfile); ip = CPP_PREV_BUFFER (ip))
-         if (ip->fname != NULL)
-           true_indepth++;
+       int true_indepth = 1;
+       ip = cpp_file_buffer (pfile);
+       while ((ip = CPP_PREV_BUFFER (ip)) != NULL)
+         true_indepth++;
 
        CPP_RESERVE (pfile, 10);
        sprintf (CPP_PWRITTEN (pfile), "%d", true_indepth);
@@ -895,9 +888,7 @@ special_symbol (hp, pfile)
     case T_STDC:
       CPP_RESERVE (pfile, 2);
 #ifdef STDC_0_IN_SYSTEM_HEADERS
-      ip = CPP_BUFFER (pfile);
-      while (!ip->nominal_fname && ip != CPP_NULL_BUFFER (pfile))
-       ip = CPP_PREV_BUFFER (ip);
+      ip = cpp_file_buffer (pfile);
       if (ip->system_header_p
          && !cpp_defined (pfile, (const U_CHAR *) "__STRICT_ANSI__", 15))
        CPP_PUTC_Q (pfile, '0');
@@ -1488,17 +1479,29 @@ _cpp_compare_defs (pfile, d1, d2)
      cpp_reader *pfile;
      DEFINITION *d1, *d2;
 {
-  register struct reflist *a1, *a2;
-  register U_CHAR *p1 = d1->expansion;
-  register U_CHAR *p2 = d2->expansion;
+  struct reflist *a1, *a2;
+  U_CHAR *p1 = d1->expansion;
+  U_CHAR *p2 = d2->expansion;
   int first = 1;
 
   if (d1->nargs != d2->nargs)
     return 1;
   if (CPP_PEDANTIC (pfile)
-      && d1->argnames && d2->argnames
-      && strcmp ((char *) d1->argnames, (char *) d2->argnames))
-    return 1;
+      && d1->argnames && d2->argnames)
+    {
+      U_CHAR *arg1 = d1->argnames;
+      U_CHAR *arg2 = d2->argnames;
+      size_t len;
+      int i = d1->nargs;
+      while (i--)
+       {
+         len = strlen (arg1);
+         if (strcmp (arg1, arg2))
+           return 1;
+         arg1 += len;
+         arg2 += len;
+       }
+    }
   for (a1 = d1->pattern, a2 = d2->pattern; a1 && a2;
        a1 = a1->next, a2 = a2->next)
     {
@@ -1602,7 +1605,6 @@ _cpp_dump_definition (pfile, sym, len, defn)
   else
     {
       struct reflist *r;
-      unsigned char *argnames = (unsigned char *) xstrdup (defn->argnames);
       unsigned char **argv = (unsigned char **) alloca (defn->nargs *
                                                        sizeof(char *));
       int *argl = (int *) alloca (defn->nargs * sizeof(int));
@@ -1610,18 +1612,12 @@ _cpp_dump_definition (pfile, sym, len, defn)
       int i;
 
       /* First extract the argument list. */
-      x = argnames;
-      i = defn->nargs;
-      while (i--)
+      x = defn->argnames;
+      for (i = 0; i < defn->nargs; i++)
        {
          argv[i] = x;
-         while (*x != ',' && *x != '\0') x++;
-         argl[i] = x - argv[i];
-         if (*x == ',')
-           {
-             *x = '\0';
-             x += 2;  /* skip the space after the comma */
-           }
+         argl[i] = strlen (x);
+         x += argl[i] + 1;
        }
       
       /* Now print out the argument list. */
@@ -1629,15 +1625,15 @@ _cpp_dump_definition (pfile, sym, len, defn)
       for (i = 0; i < defn->nargs; i++)
        {
          CPP_RESERVE (pfile, argl[i] + 2);
-         CPP_PUTS_Q (pfile, argv[i], argl[i]);
+         if (!(i == defn->nargs-1 && defn->rest_args
+               && !strcmp (argv[i], "__VA_ARGS__")))
+           CPP_PUTS_Q (pfile, argv[i], argl[i]);
          if (i < defn->nargs-1)
            CPP_PUTS_Q (pfile, ", ", 2);
        }
-
       if (defn->rest_args)
-       CPP_PUTS (pfile, "...) ", 5);
-      else
-       CPP_PUTS (pfile, ") ", 2);
+       CPP_PUTS (pfile, "...", 3);
+      CPP_PUTS (pfile, ") ", 2);
 
       /* Now the definition. */
       x = defn->expansion;
index 53af56510b191cf501bc42fbd477f061db734953..814dccd98621b4b34f9aa05af4202b2f7ba10aa2 100644 (file)
@@ -64,7 +64,7 @@ struct definition
   char rest_args;              /* Nonzero if last arg. absorbs the rest */
   struct reflist *pattern;
 
-  /* Names of macro args, concatenated in order with commas between
+  /* Names of macro args, concatenated in order with \0 between
      them.  The only use of this is that we warn on redefinition if
      this differs between the old and new definitions.  */
   U_CHAR *argnames;
index 04129aaecc6e16d48d33ef76e91a45194900fbe5..74ddd5b4dbcdc01c0938efc58958082a16d82d1b 100644 (file)
@@ -398,7 +398,7 @@ cpp_cleanup (pfile)
      cpp_reader *pfile;
 {
   int i;
-  while (CPP_BUFFER (pfile) != CPP_NULL_BUFFER (pfile))
+  while (CPP_BUFFER (pfile) != NULL)
     cpp_pop_buffer (pfile);
 
   if (pfile->token_buffer)
@@ -420,22 +420,20 @@ cpp_cleanup (pfile)
 
   while (pfile->if_stack)
     {
-      IF_STACK_FRAME *temp = pfile->if_stack;
+      IF_STACK *temp = pfile->if_stack;
       pfile->if_stack = temp->next;
       free (temp);
     }
 
   for (i = ALL_INCLUDE_HASHSIZE; --i >= 0; )
     {
-      struct include_hash *imp = pfile->all_include_files[i];
-      while (imp)
+      IHASH *imp, *next;
+      for (imp = pfile->all_include_files[i]; imp; imp = next)
        {
-         struct include_hash *next = imp->next;
-
+         next = imp->next;
          free ((PTR) imp->name);
          free ((PTR) imp->nshort);
          free (imp);
-         imp = next;
        }
       pfile->all_include_files[i] = 0;
     }
@@ -846,7 +844,7 @@ cpp_finish (pfile)
 {
   struct cpp_options *opts = CPP_OPTIONS (pfile);
 
-  if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) != CPP_NULL_BUFFER (pfile))
+  if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) != NULL)
     cpp_ice (pfile, "buffers still stacked in cpp_finish");
   cpp_pop_buffer (pfile);
 
index b0924ed7bfbc07c175f1120fd9da800a3c3e61cd..4f00f401ef8667d7bca8b99062a255ca7c102642 100644 (file)
@@ -78,7 +78,7 @@ static int do_warning PARAMS ((cpp_reader *, const struct directive *));
 /* Forward declarations.  */
 
 static void validate_else              PARAMS ((cpp_reader *, const char *));
-static HOST_WIDEST_INT eval_if_expression PARAMS ((cpp_reader *));
+static HOST_WIDEST_INT eval_if_expr    PARAMS ((cpp_reader *));
 static void conditional_skip           PARAMS ((cpp_reader *, int,
                                                enum node_type, U_CHAR *));
 static void skip_if_group              PARAMS ((cpp_reader *));
@@ -87,7 +87,6 @@ static void parse_string              PARAMS ((cpp_reader *, int));
 static int parse_assertion             PARAMS ((cpp_reader *));
 static const char *if_directive_name   PARAMS ((cpp_reader *,
                                                 struct if_stack *));
-static enum cpp_token null_underflow   PARAMS ((cpp_reader *));
 static int null_cleanup                        PARAMS ((cpp_buffer *, cpp_reader *));
 static int skip_comment                        PARAMS ((cpp_reader *, int));
 static int copy_comment                        PARAMS ((cpp_reader *, int));
@@ -100,8 +99,8 @@ static void pass_thru_directive              PARAMS ((const U_CHAR *, size_t,
                                                 const struct directive *));
 static int read_line_number            PARAMS ((cpp_reader *, int *));
 static U_CHAR *detect_if_not_defined   PARAMS ((cpp_reader *));
-static int consider_directive_while_skipping PARAMS ((cpp_reader *,
-                                                     IF_STACK_FRAME *));
+static int consider_directive_while_skipping
+                                       PARAMS ((cpp_reader *, IF_STACK *));
 static void skip_block_comment         PARAMS ((cpp_reader *));
 static void skip_line_comment          PARAMS ((cpp_reader *));
 static void parse_set_mark             PARAMS ((cpp_reader *));
@@ -264,13 +263,6 @@ cpp_defined (pfile, id, len)
   return (hp != NULL);
 }
 
-static enum cpp_token
-null_underflow (pfile)
-     cpp_reader *pfile ATTRIBUTE_UNUSED;
-{
-  return CPP_EOF;
-}
-
 static int
 null_cleanup (pbuf, pfile)
      cpp_buffer *pbuf ATTRIBUTE_UNUSED;
@@ -758,7 +750,6 @@ cpp_push_buffer (pfile, buffer, length)
 
   new->if_stack = pfile->if_stack;
   new->cleanup = null_cleanup;
-  new->underflow = null_underflow;
   new->buf = new->cur = buffer;
   new->alimit = new->rlimit = buffer + length;
   new->prev = buf;
@@ -805,8 +796,7 @@ cpp_scan_buffer (pfile)
            break;
          if (token == CPP_POP && CPP_BUFFER (pfile) == buffer)
            {
-             if (CPP_PREV_BUFFER (CPP_BUFFER (pfile))
-                 != CPP_NULL_BUFFER (pfile))
+             if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) != NULL)
                cpp_pop_buffer (pfile);
              break;
            }
@@ -822,8 +812,7 @@ cpp_scan_buffer (pfile)
            break;
          if (token == CPP_POP && CPP_BUFFER (pfile) == buffer)
            {
-             if (CPP_PREV_BUFFER (CPP_BUFFER (pfile))
-                 != CPP_NULL_BUFFER (pfile))
+             if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) != NULL)
                cpp_pop_buffer (pfile);
              break;
            }
@@ -903,10 +892,10 @@ cpp_buffer *
 cpp_file_buffer (pfile)
      cpp_reader *pfile;
 {
-  cpp_buffer *ip = CPP_BUFFER (pfile);
+  cpp_buffer *ip;
 
-  for ( ; ip != CPP_NULL_BUFFER (pfile); ip = CPP_PREV_BUFFER (ip))
-    if (ip->fname != NULL)
+  for (ip = CPP_BUFFER (pfile); ip; ip = CPP_PREV_BUFFER (ip))
+    if (ip->ihash != NULL)
       return ip;
   return NULL;
 }
@@ -1058,7 +1047,7 @@ do_include (pfile, keyword)
   enum cpp_token token;
 
   /* Chain of dirs to search */
-  struct include_hash *ihash;
+  IHASH *ihash;
   struct file_name_list *search_start;
   
   long old_written = CPP_WRITTEN (pfile);
@@ -1151,23 +1140,13 @@ do_include (pfile, keyword)
 
   search_start = 0;
 
-  for (fp = CPP_BUFFER (pfile);
-       fp != CPP_NULL_BUFFER (pfile);
-       fp = CPP_PREV_BUFFER (fp))
-    if (fp->fname != NULL)
-      break;
+  fp = cpp_file_buffer (pfile);
 
-  if (fp == CPP_NULL_BUFFER (pfile))
-    {
-      cpp_ice (pfile, "fp == NULL_BUFFER in do_include");
-      return 0;
-    }
-  
   /* For #include_next, skip in the search path past the dir in which the
      containing file was found.  Treat files specified using an absolute path
      as if there are no more directories to search.  Treat the primary source
      file like any other included source, but generate a warning.  */
-  if (skip_dirs && CPP_PREV_BUFFER(fp) != CPP_NULL_BUFFER (pfile))
+  if (skip_dirs && CPP_PREV_BUFFER (fp))
     {
       if (fp->ihash->foundhere != ABSOLUTE_PATH)
        search_start = fp->ihash->foundhere->next;
@@ -1257,7 +1236,7 @@ do_include (pfile, keyword)
   if (CPP_OPTIONS(pfile)->print_include_names)
     {
       fp = CPP_BUFFER (pfile);
-      while ((fp = CPP_PREV_BUFFER (fp)) != CPP_NULL_BUFFER (pfile))
+      while ((fp = CPP_PREV_BUFFER (fp)) != NULL)
        putc ('.', stderr);
       fprintf (stderr, " %s\n", ihash->name);
     }
@@ -1390,8 +1369,8 @@ do_line (pfile, keyword)
       if (strcmp (fname, ip->nominal_fname))
        {
          const char *newname, *oldname;
-         if (!strcmp (fname, ip->fname))
-           newname = ip->fname;
+         if (!strcmp (fname, ip->ihash->name))
+           newname = ip->ihash->name;
          else if (ip->last_nominal_fname
                   && !strcmp (fname, ip->last_nominal_fname))
            newname = ip->last_nominal_fname;
@@ -1404,10 +1383,10 @@ do_line (pfile, keyword)
          if (ip->last_nominal_fname
              && ip->last_nominal_fname != oldname
              && ip->last_nominal_fname != newname
-             && ip->last_nominal_fname != ip->fname)
+             && ip->last_nominal_fname != ip->ihash->name)
            free ((void *) ip->last_nominal_fname);
 
-         if (newname == ip->fname)
+         if (newname == ip->ihash->name)
            ip->last_nominal_fname = NULL;
          else
            ip->last_nominal_fname = oldname;
@@ -1676,18 +1655,12 @@ do_pragma_once (pfile)
 {
   cpp_buffer *ip = CPP_BUFFER (pfile);
 
-  if (ip->fname == NULL)
-    {
-      cpp_ice (pfile, "ip->fname == NULL in do_pragma_once");
-      return 1;
-    }
-  
   /* Allow #pragma once in system headers, since that's not the user's
      fault.  */
   if (!ip->system_header_p)
     cpp_warning (pfile, "`#pragma once' is obsolete");
       
-  if (CPP_PREV_BUFFER (ip) == CPP_NULL_BUFFER (pfile))
+  if (CPP_PREV_BUFFER (ip) == NULL)
     cpp_warning (pfile, "`#pragma once' outside include file");
   else
     ip->ihash->control_macro = "";  /* never repeat */
@@ -1887,7 +1860,7 @@ do_if (pfile, keyword)
      const struct directive *keyword ATTRIBUTE_UNUSED;
 {
   U_CHAR *control_macro = detect_if_not_defined (pfile);
-  HOST_WIDEST_INT value = eval_if_expression (pfile);
+  HOST_WIDEST_INT value = eval_if_expr (pfile);
   conditional_skip (pfile, value == 0, T_IF, control_macro);
   return 0;
 }
@@ -1922,7 +1895,7 @@ do_elif (pfile, keyword)
     skip_if_group (pfile);
   else
     {
-      HOST_WIDEST_INT value = eval_if_expression (pfile);
+      HOST_WIDEST_INT value = eval_if_expr (pfile);
       if (value == 0)
        skip_if_group (pfile);
       else
@@ -1940,7 +1913,7 @@ do_elif (pfile, keyword)
  */
 
 static HOST_WIDEST_INT
-eval_if_expression (pfile)
+eval_if_expr (pfile)
      cpp_reader *pfile;
 {
   HOST_WIDEST_INT value;
@@ -1968,7 +1941,6 @@ do_xifdef (pfile, keyword)
      const struct directive *keyword;
 {
   int skip;
-  cpp_buffer *ip = CPP_BUFFER (pfile);
   U_CHAR *ident;
   int ident_length;
   enum cpp_token token;
@@ -1977,7 +1949,7 @@ do_xifdef (pfile, keyword)
   int old_written = CPP_WRITTEN (pfile);
 
   /* Detect a #ifndef at start of file (not counting comments).  */
-  if (ip->fname != 0 && keyword->type == T_IFNDEF)
+  if (keyword->type == T_IFNDEF)
     start_of_file = pfile->only_seen_white == 2;
 
   pfile->no_macro_expand++;
@@ -2038,10 +2010,9 @@ conditional_skip (pfile, skip, type, control_macro)
      enum node_type type;
      U_CHAR *control_macro;
 {
-  IF_STACK_FRAME *temp;
+  IF_STACK *temp;
 
-  temp = (IF_STACK_FRAME *) xcalloc (1, sizeof (IF_STACK_FRAME));
-  temp->fname = CPP_BUFFER (pfile)->nominal_fname;
+  temp = (IF_STACK *) xcalloc (1, sizeof (IF_STACK));
   temp->lineno = CPP_BUFFER (pfile)->lineno;
   temp->next = pfile->if_stack;
   temp->control_macro = control_macro;
@@ -2066,11 +2037,11 @@ conditional_skip (pfile, skip, type, control_macro)
 static int
 consider_directive_while_skipping (pfile, stack)
     cpp_reader *pfile;
-    IF_STACK_FRAME *stack; 
+    IF_STACK *stack; 
 {
   long ident_len, ident;
   const struct directive *kt;
-  IF_STACK_FRAME *temp;
+  IF_STACK *temp;
     
   cpp_skip_hspace (pfile);
 
@@ -2088,10 +2059,9 @@ consider_directive_while_skipping (pfile, stack)
        case T_IF:
        case T_IFDEF:
        case T_IFNDEF:
-           temp = (IF_STACK_FRAME *) xmalloc (sizeof (IF_STACK_FRAME));
+           temp = (IF_STACK *) xmalloc (sizeof (IF_STACK));
            temp->next = pfile->if_stack;
            pfile->if_stack = temp;
-           temp->fname = CPP_BUFFER(pfile)->nominal_fname;
            temp->type = kt->type;
            return 0;
 
@@ -2138,7 +2108,7 @@ skip_if_group (pfile)
     cpp_reader *pfile;
 {
   int c;
-  IF_STACK_FRAME *save_if_stack = pfile->if_stack; /* don't pop past here */
+  IF_STACK *save_if_stack = pfile->if_stack; /* don't pop past here */
   U_CHAR *beg_of_line;
   long old_written;
 
@@ -2241,7 +2211,7 @@ do_endif (pfile, keyword)
     cpp_error (pfile, "`#endif' not within a conditional");
   else
     {
-      IF_STACK_FRAME *temp = pfile->if_stack;
+      IF_STACK *temp = pfile->if_stack;
       pfile->if_stack = temp->next;
       if (temp->control_macro != 0)
        {
@@ -2266,11 +2236,7 @@ do_endif (pfile, keyword)
                 that contains all of the file (aside from whitespace).
                 Arrange not to include the file again
                 if the macro that was tested is defined. */
-             struct cpp_buffer *ip;
-             for (ip = CPP_BUFFER (pfile); ; ip = CPP_PREV_BUFFER (ip))
-               if (ip->fname != NULL)
-                 break;
-             ip->ihash->control_macro = temp->control_macro;
+             CPP_BUFFER (pfile)->ihash->control_macro = temp->control_macro;
            }
         }
       free (temp);
@@ -2337,7 +2303,7 @@ cpp_get_token (pfile)
        return CPP_EOF;
       else if (CPP_BUFFER (pfile)->seen_eof)
        {
-         if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) == CPP_NULL_BUFFER (pfile))
+         if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) == NULL)
            return CPP_EOF;
 
          cpp_pop_buffer (pfile);
@@ -2362,8 +2328,7 @@ cpp_get_token (pfile)
            }
          pfile->if_stack = ifs;
 
-         if (CPP_BUFFER (pfile)->nominal_fname
-             && next_buf != CPP_NULL_BUFFER (pfile))
+         if (CPP_BUFFER (pfile)->nominal_fname && next_buf != NULL)
            {
              /* We're about to return from an #include file.
                 Emit #line information now (as part of the CPP_POP) result.
index 435f9ddc15f1294b202674e49fb4d2266bdd3bcf..a0544808d7d74a4c8c47477f768a9c683e675081 100644 (file)
@@ -61,7 +61,6 @@ enum cpp_token
   CPP_POP              /* We're about to pop the buffer stack.  */
 };
 
-typedef enum cpp_token (*parse_underflow_t) PARAMS((cpp_reader *));
 typedef int (*parse_cleanup_t) PARAMS((cpp_buffer *, cpp_reader *));
 
 extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
@@ -82,8 +81,6 @@ struct cpp_buffer
 
   struct cpp_buffer *prev;
 
-  /* Real filename.  (Alias to ->ihash->fname, obsolete). */
-  const char *fname;
   /* Filename specified with #line command.  */
   const char *nominal_fname;
   /* Last filename specified with #line command.  */
@@ -93,12 +90,11 @@ struct cpp_buffer
 
   /* Pointer into the include hash table.  Used for include_next and
      to record control macros. */
-  struct include_hash *ihash;
+  struct ihash *ihash;
 
   long lineno; /* Line number at CPP_LINE_BASE. */
   long colno; /* Column number at CPP_LINE_BASE. */
   long mark;  /* Saved position for lengthy backtrack. */
-  parse_underflow_t underflow;
   parse_cleanup_t cleanup;
   void *data;
 
@@ -146,7 +142,6 @@ struct file_name_map_list;
 
 struct cpp_reader
 {
-  parse_underflow_t get_token;
   cpp_buffer *buffer;
   cpp_options *opts;
 
@@ -175,7 +170,7 @@ struct cpp_reader
 
   /* Hash table of other included files.  See cppfiles.c */
 #define ALL_INCLUDE_HASHSIZE 71
-  struct include_hash *all_include_files[ALL_INCLUDE_HASHSIZE];
+  struct ihash *all_include_files[ALL_INCLUDE_HASHSIZE];
 
   /* Chain of `actual directory' file_name_list entries,
      for "" inclusion. */
@@ -284,8 +279,6 @@ struct cpp_reader
 #define CPP_OPTIONS(PFILE) ((PFILE)->opts)
 #define CPP_BUFFER(PFILE) ((PFILE)->buffer)
 #define CPP_PREV_BUFFER(BUFFER) ((BUFFER)->prev)
-/* The bottom of the buffer stack. */
-#define CPP_NULL_BUFFER(PFILE) NULL
 
 /* The `pending' structure accumulates all the options that are not
    actually processed until we hit cpp_start_read.  It consists of
@@ -528,12 +521,12 @@ struct file_name_list
 /* This structure is used for the table of all includes.  It is
    indexed by the `short name' (the name as it appeared in the
    #include statement) which is stored in *nshort.  */
-struct include_hash
+struct ihash
 {
-  struct include_hash *next;
+  struct ihash *next;
   /* Next file with the same short name but a
      different (partial) pathname). */
-  struct include_hash *next_this_file;
+  struct ihash *next_this_file;
 
   /* Location of the file in the include search path.
      Used for include_next */
@@ -545,6 +538,7 @@ struct include_hash
   char *buf, *limit;           /* for file content cache,
                                   not yet implemented */
 };
+typedef struct ihash IHASH;
 
 /* Name under which this program was invoked.  */
 
@@ -623,17 +617,15 @@ extern unsigned char _cpp_IStable[256];
 /* Stack of conditionals currently in progress
    (including both successful and failing conditionals).  */
 
-struct if_stack {
-  struct if_stack *next;       /* for chaining to the next stack frame */
-  const char *fname;           /* copied from input when frame is made */
-  int lineno;                  /* similarly */
-  int if_succeeded;            /* true if a leg of this if-group
-                                   has been passed through rescan */
-  U_CHAR *control_macro;       /* For #ifndef at start of file,
-                                  this is the macro name tested.  */
+struct if_stack
+{
+  struct if_stack *next;
+  int lineno;                  /* line number where condition started */
+  int if_succeeded;            /* truth of last condition in this group */
+  const U_CHAR *control_macro; /* macro name for #ifndef around entire file */
   enum node_type type;         /* type of last directive seen in this group */
 };
-typedef struct if_stack IF_STACK_FRAME;
+typedef struct if_stack IF_STACK;
 
 extern void cpp_buf_line_and_col PARAMS((cpp_buffer *, long *, long *));
 extern cpp_buffer *cpp_file_buffer PARAMS((cpp_reader *));
@@ -700,10 +692,8 @@ extern void _cpp_simplify_pathname PARAMS ((char *));
 extern void _cpp_merge_include_chains  PARAMS ((struct cpp_options *));
 extern int _cpp_find_include_file      PARAMS ((cpp_reader *, const char *,
                                                struct file_name_list *,
-                                               struct include_hash **,
-                                               int *));
-extern int _cpp_read_include_file      PARAMS ((cpp_reader *, int,
-                                               struct include_hash *));
+                                               IHASH **, int *));
+extern int _cpp_read_include_file      PARAMS ((cpp_reader *, int, IHASH *));
 
 /* In cppexp.c */
 extern HOST_WIDEST_INT _cpp_parse_expr PARAMS ((cpp_reader *));
This page took 0.125085 seconds and 5 git commands to generate.