* rclex.l: add code to suppress certain output from cpp, replace
all returns with MAYBE_RETURN (MAYBE_RETURN): new, implement the suppression by returning IGNORED_TOKEN as needed. (cpp_line): remember which file we're in, mark data from included *.h files for suppression. * rcparse.y (input): allow IGNORED_TOKEN outside of known constructs
This commit is contained in:
parent
c6c37250e9
commit
1a62478879
3 changed files with 128 additions and 85 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
1999-05-13 DJ Delorie <dj@cygnus.com>
|
||||||
|
|
||||||
|
* rclex.l: add code to suppress certain output from cpp, replace
|
||||||
|
all returns with MAYBE_RETURN
|
||||||
|
(MAYBE_RETURN): new, implement the suppression by returning
|
||||||
|
IGNORED_TOKEN as needed.
|
||||||
|
(cpp_line): remember which file we're in, mark data from included
|
||||||
|
*.h files for suppression.
|
||||||
|
* rcparse.y (input): allow IGNORED_TOKEN outside of known constructs
|
||||||
|
|
||||||
1999-05-10 DJ Delorie <dj@cygnus.com>
|
1999-05-10 DJ Delorie <dj@cygnus.com>
|
||||||
|
|
||||||
* windres.c (quot): Quote shell metacharacters in a string
|
* windres.c (quot): Quote shell metacharacters in a string
|
||||||
|
|
201
binutils/rclex.l
201
binutils/rclex.l
|
@ -37,6 +37,23 @@
|
||||||
|
|
||||||
static int rcdata_mode;
|
static int rcdata_mode;
|
||||||
|
|
||||||
|
/* Whether we are supressing lines from cpp (including windows.h or
|
||||||
|
headers from your C sources may bring in externs and typedefs).
|
||||||
|
When active, we return IGNORED_TOKEN, which lets us ignore these
|
||||||
|
outside of resource constructs. Thus, it isn't required to protect
|
||||||
|
all the non-preprocessor lines in your header files with #ifdef
|
||||||
|
RC_INVOKED. It also means your RC file can't include other RC
|
||||||
|
files if they're named "*.h". Sorry. Name them *.rch or whatever. */
|
||||||
|
|
||||||
|
static int suppress_cpp_data;
|
||||||
|
|
||||||
|
#define MAYBE_RETURN(x) return suppress_cpp_data ? IGNORED_TOKEN : (x)
|
||||||
|
|
||||||
|
/* The first filename we detect in the cpp output. We use this to
|
||||||
|
tell included files from the original file. */
|
||||||
|
|
||||||
|
static char *initial_fn;
|
||||||
|
|
||||||
/* List of allocated strings. */
|
/* List of allocated strings. */
|
||||||
|
|
||||||
struct alloc_string
|
struct alloc_string
|
||||||
|
@ -57,82 +74,82 @@ static char *get_string PARAMS ((int));
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
"BEGIN" { return BEG; }
|
"BEGIN" { MAYBE_RETURN (BEG); }
|
||||||
"{" { return BEG; }
|
"{" { MAYBE_RETURN (BEG); }
|
||||||
"END" { return END; }
|
"END" { MAYBE_RETURN (END); }
|
||||||
"}" { return END; }
|
"}" { MAYBE_RETURN (END); }
|
||||||
"ACCELERATORS" { return ACCELERATORS; }
|
"ACCELERATORS" { MAYBE_RETURN (ACCELERATORS); }
|
||||||
"VIRTKEY" { return VIRTKEY; }
|
"VIRTKEY" { MAYBE_RETURN (VIRTKEY); }
|
||||||
"ASCII" { return ASCII; }
|
"ASCII" { MAYBE_RETURN (ASCII); }
|
||||||
"NOINVERT" { return NOINVERT; }
|
"NOINVERT" { MAYBE_RETURN (NOINVERT); }
|
||||||
"SHIFT" { return SHIFT; }
|
"SHIFT" { MAYBE_RETURN (SHIFT); }
|
||||||
"CONTROL" { return CONTROL; }
|
"CONTROL" { MAYBE_RETURN (CONTROL); }
|
||||||
"ALT" { return ALT; }
|
"ALT" { MAYBE_RETURN (ALT); }
|
||||||
"BITMAP" { return BITMAP; }
|
"BITMAP" { MAYBE_RETURN (BITMAP); }
|
||||||
"CURSOR" { return CURSOR; }
|
"CURSOR" { MAYBE_RETURN (CURSOR); }
|
||||||
"DIALOG" { return DIALOG; }
|
"DIALOG" { MAYBE_RETURN (DIALOG); }
|
||||||
"DIALOGEX" { return DIALOGEX; }
|
"DIALOGEX" { MAYBE_RETURN (DIALOGEX); }
|
||||||
"EXSTYLE" { return EXSTYLE; }
|
"EXSTYLE" { MAYBE_RETURN (EXSTYLE); }
|
||||||
"CAPTION" { return CAPTION; }
|
"CAPTION" { MAYBE_RETURN (CAPTION); }
|
||||||
"CLASS" { return CLASS; }
|
"CLASS" { MAYBE_RETURN (CLASS); }
|
||||||
"STYLE" { return STYLE; }
|
"STYLE" { MAYBE_RETURN (STYLE); }
|
||||||
"AUTO3STATE" { return AUTO3STATE; }
|
"AUTO3STATE" { MAYBE_RETURN (AUTO3STATE); }
|
||||||
"AUTOCHECKBOX" { return AUTOCHECKBOX; }
|
"AUTOCHECKBOX" { MAYBE_RETURN (AUTOCHECKBOX); }
|
||||||
"AUTORADIOBUTTON" { return AUTORADIOBUTTON; }
|
"AUTORADIOBUTTON" { MAYBE_RETURN (AUTORADIOBUTTON); }
|
||||||
"CHECKBOX" { return CHECKBOX; }
|
"CHECKBOX" { MAYBE_RETURN (CHECKBOX); }
|
||||||
"COMBOBOX" { return COMBOBOX; }
|
"COMBOBOX" { MAYBE_RETURN (COMBOBOX); }
|
||||||
"CTEXT" { return CTEXT; }
|
"CTEXT" { MAYBE_RETURN (CTEXT); }
|
||||||
"DEFPUSHBUTTON" { return DEFPUSHBUTTON; }
|
"DEFPUSHBUTTON" { MAYBE_RETURN (DEFPUSHBUTTON); }
|
||||||
"EDITTEXT" { return EDITTEXT; }
|
"EDITTEXT" { MAYBE_RETURN (EDITTEXT); }
|
||||||
"GROUPBOX" { return GROUPBOX; }
|
"GROUPBOX" { MAYBE_RETURN (GROUPBOX); }
|
||||||
"LISTBOX" { return LISTBOX; }
|
"LISTBOX" { MAYBE_RETURN (LISTBOX); }
|
||||||
"LTEXT" { return LTEXT; }
|
"LTEXT" { MAYBE_RETURN (LTEXT); }
|
||||||
"PUSHBOX" { return PUSHBOX; }
|
"PUSHBOX" { MAYBE_RETURN (PUSHBOX); }
|
||||||
"PUSHBUTTON" { return PUSHBUTTON; }
|
"PUSHBUTTON" { MAYBE_RETURN (PUSHBUTTON); }
|
||||||
"RADIOBUTTON" { return RADIOBUTTON; }
|
"RADIOBUTTON" { MAYBE_RETURN (RADIOBUTTON); }
|
||||||
"RTEXT" { return RTEXT; }
|
"RTEXT" { MAYBE_RETURN (RTEXT); }
|
||||||
"SCROLLBAR" { return SCROLLBAR; }
|
"SCROLLBAR" { MAYBE_RETURN (SCROLLBAR); }
|
||||||
"STATE3" { return STATE3; }
|
"STATE3" { MAYBE_RETURN (STATE3); }
|
||||||
"USERBUTTON" { return USERBUTTON; }
|
"USERBUTTON" { MAYBE_RETURN (USERBUTTON); }
|
||||||
"BEDIT" { return BEDIT; }
|
"BEDIT" { MAYBE_RETURN (BEDIT); }
|
||||||
"HEDIT" { return HEDIT; }
|
"HEDIT" { MAYBE_RETURN (HEDIT); }
|
||||||
"IEDIT" { return IEDIT; }
|
"IEDIT" { MAYBE_RETURN (IEDIT); }
|
||||||
"FONT" { return FONT; }
|
"FONT" { MAYBE_RETURN (FONT); }
|
||||||
"ICON" { return ICON; }
|
"ICON" { MAYBE_RETURN (ICON); }
|
||||||
"LANGUAGE" { return LANGUAGE; }
|
"LANGUAGE" { MAYBE_RETURN (LANGUAGE); }
|
||||||
"CHARACTERISTICS" { return CHARACTERISTICS; }
|
"CHARACTERISTICS" { MAYBE_RETURN (CHARACTERISTICS); }
|
||||||
"VERSION" { return VERSIONK; }
|
"VERSION" { MAYBE_RETURN (VERSIONK); }
|
||||||
"MENU" { return MENU; }
|
"MENU" { MAYBE_RETURN (MENU); }
|
||||||
"MENUEX" { return MENUEX; }
|
"MENUEX" { MAYBE_RETURN (MENUEX); }
|
||||||
"MENUITEM" { return MENUITEM; }
|
"MENUITEM" { MAYBE_RETURN (MENUITEM); }
|
||||||
"SEPARATOR" { return SEPARATOR; }
|
"SEPARATOR" { MAYBE_RETURN (SEPARATOR); }
|
||||||
"POPUP" { return POPUP; }
|
"POPUP" { MAYBE_RETURN (POPUP); }
|
||||||
"CHECKED" { return CHECKED; }
|
"CHECKED" { MAYBE_RETURN (CHECKED); }
|
||||||
"GRAYED" { return GRAYED; }
|
"GRAYED" { MAYBE_RETURN (GRAYED); }
|
||||||
"HELP" { return HELP; }
|
"HELP" { MAYBE_RETURN (HELP); }
|
||||||
"INACTIVE" { return INACTIVE; }
|
"INACTIVE" { MAYBE_RETURN (INACTIVE); }
|
||||||
"MENUBARBREAK" { return MENUBARBREAK; }
|
"MENUBARBREAK" { MAYBE_RETURN (MENUBARBREAK); }
|
||||||
"MENUBREAK" { return MENUBREAK; }
|
"MENUBREAK" { MAYBE_RETURN (MENUBREAK); }
|
||||||
"MESSAGETABLE" { return MESSAGETABLE; }
|
"MESSAGETABLE" { MAYBE_RETURN (MESSAGETABLE); }
|
||||||
"RCDATA" { return RCDATA; }
|
"RCDATA" { MAYBE_RETURN (RCDATA); }
|
||||||
"STRINGTABLE" { return STRINGTABLE; }
|
"STRINGTABLE" { MAYBE_RETURN (STRINGTABLE); }
|
||||||
"VERSIONINFO" { return VERSIONINFO; }
|
"VERSIONINFO" { MAYBE_RETURN (VERSIONINFO); }
|
||||||
"FILEVERSION" { return FILEVERSION; }
|
"FILEVERSION" { MAYBE_RETURN (FILEVERSION); }
|
||||||
"PRODUCTVERSION" { return PRODUCTVERSION; }
|
"PRODUCTVERSION" { MAYBE_RETURN (PRODUCTVERSION); }
|
||||||
"FILEFLAGSMASK" { return FILEFLAGSMASK; }
|
"FILEFLAGSMASK" { MAYBE_RETURN (FILEFLAGSMASK); }
|
||||||
"FILEFLAGS" { return FILEFLAGS; }
|
"FILEFLAGS" { MAYBE_RETURN (FILEFLAGS); }
|
||||||
"FILEOS" { return FILEOS; }
|
"FILEOS" { MAYBE_RETURN (FILEOS); }
|
||||||
"FILETYPE" { return FILETYPE; }
|
"FILETYPE" { MAYBE_RETURN (FILETYPE); }
|
||||||
"FILESUBTYPE" { return FILESUBTYPE; }
|
"FILESUBTYPE" { MAYBE_RETURN (FILESUBTYPE); }
|
||||||
"VALUE" { return VALUE; }
|
"VALUE" { MAYBE_RETURN (VALUE); }
|
||||||
"MOVEABLE" { return MOVEABLE; }
|
"MOVEABLE" { MAYBE_RETURN (MOVEABLE); }
|
||||||
"FIXED" { return FIXED; }
|
"FIXED" { MAYBE_RETURN (FIXED); }
|
||||||
"PURE" { return PURE; }
|
"PURE" { MAYBE_RETURN (PURE); }
|
||||||
"IMPURE" { return IMPURE; }
|
"IMPURE" { MAYBE_RETURN (IMPURE); }
|
||||||
"PRELOAD" { return PRELOAD; }
|
"PRELOAD" { MAYBE_RETURN (PRELOAD); }
|
||||||
"LOADONCALL" { return LOADONCALL; }
|
"LOADONCALL" { MAYBE_RETURN (LOADONCALL); }
|
||||||
"DISCARDABLE" { return DISCARDABLE; }
|
"DISCARDABLE" { MAYBE_RETURN (DISCARDABLE); }
|
||||||
"NOT" { return NOT; }
|
"NOT" { MAYBE_RETURN (NOT); }
|
||||||
|
|
||||||
"BLOCK"[ \t\n]*"\""[^\#\n]*"\"" {
|
"BLOCK"[ \t\n]*"\""[^\#\n]*"\"" {
|
||||||
char *s, *send;
|
char *s, *send;
|
||||||
|
@ -146,11 +163,11 @@ static char *get_string PARAMS ((int));
|
||||||
if (strncmp (s, "StringFileInfo",
|
if (strncmp (s, "StringFileInfo",
|
||||||
sizeof "StringFileInfo" - 1) == 0
|
sizeof "StringFileInfo" - 1) == 0
|
||||||
&& s + sizeof "StringFileInfo" - 1 == send)
|
&& s + sizeof "StringFileInfo" - 1 == send)
|
||||||
return BLOCKSTRINGFILEINFO;
|
MAYBE_RETURN (BLOCKSTRINGFILEINFO);
|
||||||
else if (strncmp (s, "VarFileInfo",
|
else if (strncmp (s, "VarFileInfo",
|
||||||
sizeof "VarFileInfo" - 1) == 0
|
sizeof "VarFileInfo" - 1) == 0
|
||||||
&& s + sizeof "VarFileInfo" - 1 == send)
|
&& s + sizeof "VarFileInfo" - 1 == send)
|
||||||
return BLOCKVARFILEINFO;
|
MAYBE_RETURN (BLOCKVARFILEINFO);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *r;
|
char *r;
|
||||||
|
@ -159,7 +176,7 @@ static char *get_string PARAMS ((int));
|
||||||
strncpy (r, s, send - s);
|
strncpy (r, s, send - s);
|
||||||
r[send - s] = '\0';
|
r[send - s] = '\0';
|
||||||
yylval.s = r;
|
yylval.s = r;
|
||||||
return BLOCK;
|
MAYBE_RETURN (BLOCK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,13 +187,13 @@ static char *get_string PARAMS ((int));
|
||||||
[0-9][x0-9A-Fa-f]*L {
|
[0-9][x0-9A-Fa-f]*L {
|
||||||
yylval.i.val = strtoul (yytext, 0, 0);
|
yylval.i.val = strtoul (yytext, 0, 0);
|
||||||
yylval.i.dword = 1;
|
yylval.i.dword = 1;
|
||||||
return NUMBER;
|
MAYBE_RETURN (NUMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
[0-9][x0-9A-Fa-f]* {
|
[0-9][x0-9A-Fa-f]* {
|
||||||
yylval.i.val = strtoul (yytext, 0, 0);
|
yylval.i.val = strtoul (yytext, 0, 0);
|
||||||
yylval.i.dword = 0;
|
yylval.i.dword = 0;
|
||||||
return NUMBER;
|
MAYBE_RETURN (NUMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
("\""[^\"\n]*"\""[ \t]*)+ {
|
("\""[^\"\n]*"\""[ \t]*)+ {
|
||||||
|
@ -187,13 +204,13 @@ static char *get_string PARAMS ((int));
|
||||||
if (! rcdata_mode)
|
if (! rcdata_mode)
|
||||||
{
|
{
|
||||||
yylval.s = s;
|
yylval.s = s;
|
||||||
return QUOTEDSTRING;
|
MAYBE_RETURN (QUOTEDSTRING);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
yylval.ss.length = length;
|
yylval.ss.length = length;
|
||||||
yylval.ss.s = s;
|
yylval.ss.s = s;
|
||||||
return SIZEDSTRING;
|
MAYBE_RETURN (SIZEDSTRING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,12 +226,12 @@ static char *get_string PARAMS ((int));
|
||||||
s = get_string (strlen (yytext) + 1);
|
s = get_string (strlen (yytext) + 1);
|
||||||
strcpy (s, yytext);
|
strcpy (s, yytext);
|
||||||
yylval.s = s;
|
yylval.s = s;
|
||||||
return STRING;
|
MAYBE_RETURN (STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
[\n] { ++rc_lineno; }
|
[\n] { ++rc_lineno; }
|
||||||
[ \t\r]+ { /* ignore whitespace */ }
|
[ \t\r]+ { /* ignore whitespace */ }
|
||||||
. { return *yytext; }
|
. { MAYBE_RETURN (*yytext); }
|
||||||
|
|
||||||
%%
|
%%
|
||||||
#ifndef yywrap
|
#ifndef yywrap
|
||||||
|
@ -263,6 +280,20 @@ cpp_line (s)
|
||||||
|
|
||||||
free (rc_filename);
|
free (rc_filename);
|
||||||
rc_filename = fn;
|
rc_filename = fn;
|
||||||
|
|
||||||
|
if (!initial_fn)
|
||||||
|
{
|
||||||
|
initial_fn = xmalloc (strlen (fn) + 1);
|
||||||
|
strcpy(initial_fn, fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allow the initial file, regardless of name. Suppress all other
|
||||||
|
files if they end in ".h" (this allows included "*.rc") */
|
||||||
|
if (strcmp (initial_fn, fn) == 0
|
||||||
|
|| strcmp (fn + strlen (fn) - 2, ".h") != 0)
|
||||||
|
suppress_cpp_data = 0;
|
||||||
|
else
|
||||||
|
suppress_cpp_data = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle a quoted string. The quotes are stripped. A pair of quotes
|
/* Handle a quoted string. The quotes are stripped. A pair of quotes
|
||||||
|
|
|
@ -122,6 +122,7 @@ static unsigned long class;
|
||||||
%token <s> QUOTEDSTRING STRING
|
%token <s> QUOTEDSTRING STRING
|
||||||
%token <i> NUMBER
|
%token <i> NUMBER
|
||||||
%token <ss> SIZEDSTRING
|
%token <ss> SIZEDSTRING
|
||||||
|
%token IGNORED_TOKEN
|
||||||
|
|
||||||
%type <pacc> acc_entries
|
%type <pacc> acc_entries
|
||||||
%type <acc> acc_entry acc_event
|
%type <acc> acc_entry acc_event
|
||||||
|
@ -167,6 +168,7 @@ input:
|
||||||
| input newcmd stringtable
|
| input newcmd stringtable
|
||||||
| input newcmd user
|
| input newcmd user
|
||||||
| input newcmd versioninfo
|
| input newcmd versioninfo
|
||||||
|
| input newcmd IGNORED_TOKEN
|
||||||
;
|
;
|
||||||
|
|
||||||
newcmd:
|
newcmd:
|
||||||
|
|
Loading…
Reference in a new issue