]> granicus.if.org Git - flex/commitdiff
Removed #undef of start conditions.
authorJohn Millaway <john43@users.sourceforge.net>
Sun, 18 Aug 2002 20:32:11 +0000 (20:32 +0000)
committerJohn Millaway <john43@users.sourceforge.net>
Sun, 18 Aug 2002 20:32:11 +0000 (20:32 +0000)
main.c

diff --git a/main.c b/main.c
index 35ddc28adf3867d3826165a7b50a12694ceafe80..37dd03750742c98cf20ca0f46dd5520cae0610ac 100644 (file)
--- a/main.c
+++ b/main.c
@@ -556,11 +556,13 @@ int exit_status;
 
             fprintf(header_out,"#line %d \"%s\"\n", (++nlines)+1, headerfilename);
 
-            /* Print the prefixed start conditions. */
+            /* Print the start conditions. */
             fprintf(header_out,"#ifdef YY_HEADER_EXPORT_START_CONDITIONS\n");
             fprintf(header_out,"/* Beware! Start conditions are not prefixed. */\n");
-                   
-            for (i=1; i <= lastsc; i++)
+            
+            /* Special case for "INITIAL" */
+            fprintf(header_out,"#undef INITIAL\n#define INITIAL 0\n");
+            for (i=2; i <= lastsc; i++)
                 fprintf(header_out, "#define %s %d\n",scname[i], i-1);
             fprintf(header_out,"#endif /* YY_HEADER_EXPORT_START_CONDITIONS */\n\n");
 
@@ -576,7 +578,6 @@ int exit_status;
             fprintf(header_out,"#undef EOB_ACT_LAST_MATCH\n");
             fprintf(header_out,"#undef FLEX_SCANNER\n");
             fprintf(header_out,"#undef FLEX_STD\n");
-            fprintf(header_out,"#undef INITIAL\n");
             fprintf(header_out,"#undef REJECT\n");
             fprintf(header_out,"#undef YYLMAX\n");
             fprintf(header_out,"#undef YYSTATE\n");
@@ -717,8 +718,13 @@ int exit_status;
             fprintf(header_out,"#undef yyfree\n");
 
                        /* undef any of the auto-generated symbols. */
-                       for(i=0; i < defs_buf.nelts; i++)
+                       for(i=0; i < defs_buf.nelts; i++){
+
+                /* don't undef start conditions */
+                if (sclookup(((char**)defs_buf.elts)[i]) > 0 )
+                    continue;
                                fprintf(header_out, "#undef %s\n", ((char**)defs_buf.elts)[i]);
+            }
 
             fprintf(header_out,"#endif /* !YY_HEADER_NO_UNDEFS */\n");
                        fprintf(header_out, "\n");