cpplib: Fix off-by-one bug

Neil Booth neil@daikokuya.demon.co.uk
Sun Jan 28 23:59:00 GMT 2001


This has been there for ages; thanks to Rodney Brown for helping me
track it down.

The effect was, on most systems, that #sccs was not a recognised
directive when it should have been.  Since no-one has complained, I
wonder if we should scrap it?

The effect on systems without SCCS_DIRECTIVE is that #unassert was not
available to them, resulting in testsuite failures.

I'll commit this after a bootstrap.

Neil.

	* cpplib.c (T_BAD_DIRECTIVE): Remove.
	(_cpp_init_stacks): Loop from 0 to N_DIRECTIVES - 1.

Index: cpplib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.c,v
retrieving revision 1.237
diff -u -p -r1.237 cpplib.c
--- cpplib.c	2001/01/18 06:32:47	1.237
+++ cpplib.c	2001/01/29 07:56:57
@@ -161,7 +161,6 @@ DIRECTIVE_TABLE
 #define D(n, tag, o, f) tag,
 enum
 {
-  T_BAD_DIRECTIVE,
   DIRECTIVE_TABLE
   N_DIRECTIVES
 };
@@ -1870,17 +1869,17 @@ void
 _cpp_init_stacks (pfile)
      cpp_reader *pfile;
 {
-  int i;
+  unsigned int i;
   cpp_hashnode *node;
 
   pfile->buffer_ob = xnew (struct obstack);
   obstack_init (pfile->buffer_ob);
 
   /* Register the directives.  */
-  for (i = 1; i < N_DIRECTIVES; i++)
+  for (i = 0; i < N_DIRECTIVES; i++)
     {
-      node = cpp_lookup (pfile, dtable[i - 1].name, dtable[i - 1].length);
-      node->directive_index = i;
+      node = cpp_lookup (pfile, dtable[i].name, dtable[i].length);
+      node->directive_index = i + 1;
     }
 }
 



More information about the Gcc-patches mailing list