diff options
author | John Millaway <john43@users.sourceforge.net> | 2002-08-13 19:16:44 +0000 |
---|---|---|
committer | John Millaway <john43@users.sourceforge.net> | 2002-08-13 19:16:44 +0000 |
commit | b19fc6297a8238f7e722641ad30db95840eaf054 (patch) | |
tree | 0dbc0c6e244fb2d02ac85ea6d85730dae55e34fe | |
parent | 5c3d0566c866a0f3a581d4b4a39edde6f7c684b5 (diff) |
Omit user code and tables from generated header file.
-rw-r--r-- | flexdef.h | 4 | ||||
-rw-r--r-- | main.c | 12 |
2 files changed, 14 insertions, 2 deletions
@@ -1068,8 +1068,8 @@ extern struct Buf userdef_buf; extern struct Buf defs_buf; /* For blocking out code from the header file. */ -#define OUT_BEGIN_CODE() out_str("#ifndef %sIN_HEADER\n",prefix) -#define OUT_END_CODE() out_str("#endif /* !%sIN_HEADER */\n",prefix); +#define OUT_BEGIN_CODE() out_str("#ifndef %sIN_HEADER /* YY-DISCARD-FROM-HEADER */\n",prefix) +#define OUT_END_CODE() out_str("#endif /* !%sIN_HEADER YY-END-DISCARD-FROM-HEADER */\n",prefix); /* For setjmp/longjmp (instead of calling exit(2)). Linkage in main.c */ extern jmp_buf flex_main_jmp_buf; @@ -532,6 +532,7 @@ int exit_status; FILE *header_out; char linebuf[LINE_SZ]; int nlines=0; + int discard = 0; /* rewind the outfile file. */ fflush(stdout); @@ -548,6 +549,16 @@ int exit_status; nlines=4; while(fgets(linebuf, LINE_SZ, stdout)) { + if (strstr(linebuf, "YY-DISCARD-FROM-HEADER")) + discard++; + else if (strstr(linebuf, "YY-END-DISCARD-FROM-HEADER")){ + discard--; + continue; + } + + if (discard) + continue; + fix_line_dirs(linebuf, outfilename, headerfilename, nlines); fputs(linebuf, header_out); nlines++; @@ -555,6 +566,7 @@ int exit_status; /* Kill ALL flex-related macros. This is so the user * can #include more than one generated header file. */ + fprintf(header_out,"#line %d \"%s\"", (++nlines)+1, headerfilename); fprintf(header_out,"\n"); fprintf(header_out,"#undef BEGIN\n"); fprintf(header_out,"#undef ECHO\n"); |