From 549351ab09c2173d067b3a6eeee5b45bf6098ca6 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 28 Jun 2007 14:10:07 +0200 Subject: [PATCH] wrc: Strip C code based on the name of the include file. Get rid of the old C code stripping support that wasn't used anymore. --- tools/wrc/parser.l | 74 ++++++++++------------------------------------ 1 file changed, 16 insertions(+), 58 deletions(-) diff --git a/tools/wrc/parser.l b/tools/wrc/parser.l index f9034a5451a..4b0a7db24a6 100644 --- a/tools/wrc/parser.l +++ b/tools/wrc/parser.l @@ -76,10 +76,7 @@ /* Exclusive comment eating... */ %x comment /* Set when stripping c-junk */ -%x pp_stripe -%x pp_strips -%x pp_stripp -%x pp_stripp_final +%x pp_cstrip /* Set when scanning #line style directives */ %x pp_line /* Set when scanning #pragma */ @@ -87,7 +84,7 @@ %x pp_code_page %option stack -%option nounput noyy_top_state +%option nounput noyy_top_state noyywrap %option 8bit never-interactive %option prefix="parser_" @@ -128,9 +125,6 @@ static int cbufalloc = 0; static WCHAR *wbuffer; static int wbufidx; static int wbufalloc = 0; -static int stripslevel = 0; /* Count {} during pp_strips/pp_stripe mode */ -static int stripplevel = 0; /* Count () during pp_strips mode */ -static int cjunk_tagline; /* Where did we start stripping (helps error tracking) */ static int current_codepage = -1; /* use language default */ @@ -321,10 +315,10 @@ static struct keyword *iskeyword(char *kw) * because we only want to know the linenumber and * filename. */ -^{ws}*\#{ws}*pragma{ws}+ yy_push_state(pp_pragma); -^{ws}*\#{ws}* yy_push_state(pp_line); +^{ws}*\#{ws}*pragma{ws}+ yy_push_state(pp_pragma); +^{ws}*\#{ws}* yy_push_state(pp_line); [^\n]* { - int lineno; + int lineno, len; char *cptr; char *fname; yy_pop_state(); @@ -341,6 +335,12 @@ static struct keyword *iskeyword(char *kw) *cptr = '\0'; line_number = lineno - 1; /* We didn't read the newline */ input_name = xstrdup(fname); + /* ignore contents of C include files */ + len = strlen(input_name); + if (len > 1 && !strcasecmp( input_name + len - 2, ".h" )) + BEGIN(pp_cstrip); + else + BEGIN(INITIAL); } code_page[^\n]* yyless(9); yy_pop_state(); yy_push_state(pp_code_page); @@ -366,30 +366,8 @@ static struct keyword *iskeyword(char *kw) * into account braces {} for structures, * classes and enums. */ -\{ stripslevel++; -\} stripslevel--; -; if(!stripslevel) yy_pop_state(); -\/[^*\n] ; /* To catch comments */ -[^\{\};\n#/]* ; /* Ignore rest */ -\n line_number++; char_number = 1; - -\( stripplevel++; -\) { - stripplevel--; - if(!stripplevel) - { - yy_pop_state(); - yy_push_state(pp_stripp_final); - } - } -\/[^*\n] ; /* To catch comments */ -[^\(\);\n#/]* ; /* Ignore rest */ -\n line_number++; char_number = 1; - -{ws}* ; /* Ignore */ -; yy_pop_state(); /* Kill the semicolon */ -\n line_number++; char_number = 1; yy_pop_state(); -. yyless(0); yy_pop_state(); +\n line_number++; char_number = 1; +. ; /* ignore */ \{ return tBEGIN; \} return tEND; @@ -546,7 +524,7 @@ L\" { * Comment stripping * Should never occur after preprocessing */ -"/*" { +"/*" { yy_push_state(comment); save_wanted_id = wanted_id; if(!no_preprocess) @@ -574,13 +552,6 @@ L\" { . return yytext[0]; -<> { - if(YY_START == pp_strips || YY_START == pp_stripe || YY_START == pp_stripp || YY_START == pp_stripp_final) - parser_error("Unexpected end of file during c-junk scanning (started at %d)", cjunk_tagline); - else - yyterminate(); - } - <*>.|\n { /* Catch all rule to find any unmatched text */ if(*yytext == '\n') @@ -588,25 +559,12 @@ L\" { line_number++; char_number = 1; } - parser_warning("Unmatched text '%c' (0x%02x) YY_START=%d stripslevel=%d", - isprint(*yytext & 0xff) ? *yytext : '.', *yytext, YY_START,stripslevel); + parser_warning("Unmatched text '%c' (0x%02x) YY_START=%d", + isprint(*yytext & 0xff) ? *yytext : '.', *yytext, YY_START); } %% -#ifndef parser_wrap -int parser_wrap(void) -{ -#if 0 - if(bufferstackidx > 0) - { - return 0; - } -#endif - return 1; -} -#endif - /* These dup functions copy the enclosed '\0' from * the resource string. */