From 24b5050a7f5281469e1de92f36461c69c1a094ec Mon Sep 17 00:00:00 2001 From: Bertho Stultiens Date: Sat, 8 Jul 2000 11:49:29 +0000 Subject: [PATCH] - Bugfix: Macro expansion of strings would assert an internal error or a segfault due to a lacking '\0' in the expansion. - Bugfix: Prevent buffer overflow in reallocation of macro expansion buffers. - Bugfix: Wrc's version information was not passed as numerical to the preprocessor due to an error in the definition of the macro. - Relaxed the newline constraint in global LANGUAGE statements, which was introduced in version 1.1.3, so that some fancy preprocessor constructs can work. - Removed the gcc-style #line handling from the resource-parser to the resource-scanner so that it is possible to include files at any stage of the source, independent of the parser-state. - Bugfix: Stringtables were not correctly searched for duplicates because the language comparison disregarded the sublanguage. - Eliminated a repetitive warning when writing stringtables with zero length string entries. These are perfectly valid (but make no sense:-). Warnings are now only generated during parse in pedantic mode. --- tools/wrc/CHANGES | 22 +++++++++++++++ tools/wrc/README.wrc | 10 +++---- tools/wrc/genres.c | 2 +- tools/wrc/parser.l | 41 +++++++++++++++++++++++++++ tools/wrc/parser.y | 66 +++++++++++++++++++++++--------------------- tools/wrc/ppl.l | 7 +++-- tools/wrc/wrc.c | 8 +++--- tools/wrc/wrc.h | 8 ++++-- tools/wrc/wrc.man | 2 +- 9 files changed, 118 insertions(+), 48 deletions(-) diff --git a/tools/wrc/CHANGES b/tools/wrc/CHANGES index 1a9ffc6ea38..e0f4bbbc2e3 100644 --- a/tools/wrc/CHANGES +++ b/tools/wrc/CHANGES @@ -1,3 +1,25 @@ +--------------------------------------------------------------------------- +Version 1.1.6 (05-Jun-2000) + +Bertho Stultiens +- Bugfix: Macro expansion of strings would assert an internal error + or a segfault due to a lacking '\0' in the expansion. +- Bugfix: Prevent buffer overflow in reallocation of macro expansion + buffers. +- Bugfix: Wrc's version information was not passed as numerical to the + preprocessor due to an error in the definition of the macro. +- Relaxed the newline constraint in global LANGUAGE statements, which + was introduced in version 1.1.3, so that some fancy preprocessor + constructs can work. +- Removed the gcc-style #line handling from the resource-parser to the + resource-scanner so that it is possible to include files at any stage + of the source, independent of the parser-state. +- Bugfix: Stringtables were not correctly searched for duplicates + because the language comparison disregarded the sublanguage. +- Eliminated a repetitive warning when writing stringtables with zero + length string entries. These are perfectly valid (but make no sense:-). + Warning are now only generated during parse in pedantic mode. + --------------------------------------------------------------------------- Version 1.1.5 (12-Jun-2000) diff --git a/tools/wrc/README.wrc b/tools/wrc/README.wrc index c787d5b8e3a..91993685f40 100644 --- a/tools/wrc/README.wrc +++ b/tools/wrc/README.wrc @@ -1,4 +1,4 @@ -Release 1.1.5 of wrc (12-Jun-2000), the wine resource compiler. +Release 1.1.6 of wrc (05-Jul-2000), the wine resource compiler. See the file CHANGES for differences between the version and what has been corrected in the current version. @@ -101,8 +101,8 @@ but not expanded properly. This will be corrected in the future. The preprocessor handles the special defines and aditionally defines an extra set of defines: - Define | Value | Comment ------------+-------------------+--------------- + Define | Value | Comment +---------------+---------------+--------------- RC_INVOKED | 1 | Always defined __FLAT__ | 1 | Only defined if win32 compile __WIN32__ | 1 | Only defined if win32 compile @@ -112,8 +112,8 @@ __TIME__ | "23:59:59" | Timestring of compilation __DATE__ | "May 1 2000" | Datestring of compilation __WRC__  1 | Wrc's major version __WRC_MINOR__ | 1 | Wrc's minor version -__WRC_MICRO__ | 0 | Wrc's minor version -__WRC_PATCH__ | 0 | Alias of __WRC_MICRO__ +__WRC_MICRO__ | 6 | Wrc's minor version +__WRC_PATCH__ | 6 | Alias of __WRC_MICRO__ Include-files are not read twice if they are protected with this scheme: #ifndef SOME_DEFINE diff --git a/tools/wrc/genres.c b/tools/wrc/genres.c index c544c7cf335..58f01ff9600 100644 --- a/tools/wrc/genres.c +++ b/tools/wrc/genres.c @@ -1416,7 +1416,7 @@ static res_t *stringtable2res(stringtable_t *stt) restag = put_res_header(res, WRC_RT_STRING, NULL, &name, stt->memopt, win32 ? &(stt->lvc) : NULL); for(i = 0; i < stt->nentries; i++) { - if(stt->entries[i].str) + if(stt->entries[i].str && stt->entries[i].str->size) { if(win32) put_word(res, stt->entries[i].str->size); diff --git a/tools/wrc/parser.l b/tools/wrc/parser.l index 1d7b4341bcf..5a5d773aa2d 100644 --- a/tools/wrc/parser.l +++ b/tools/wrc/parser.l @@ -65,6 +65,8 @@ %x pp_strips %x pp_stripp %x pp_stripp_final +/* Set when scanning #line style directives */ +%x pp_line %option stack %option never-interactive @@ -290,6 +292,45 @@ static struct keyword *iskeyword(char *kw) ************************************************************************** */ %% + /* + * Catch the GCC-style line statements here and parse them. + * This has the advantage that you can #include at any + * stage in the resource file. + * The preprocessor generates line directives in the format: + * # "filename" + * + * Codes can be a sequence of: + * - 1 start of new file + * - 2 returning to previous + * - 3 system header + * - 4 interpret as C-code + * + * 4 is not used and 1 mutually excludes 2 + * Anyhow, we are not really interested in these at all + * because we only want to know the linenumber and + * filename. + */ +^{ws}*\#{ws}* yy_push_state(pp_line); +[^\n]* { + int lineno; + char *cptr; + char *fname; + yy_pop_state(); + lineno = (int)strtol(yytext, &cptr, 10); + if(!lineno) + yyerror("Malformed '#...' line-directive; invalid linenumber"); + fname = strchr(cptr, '"'); + if(!fname) + yyerror("Malformed '#...' line-directive; missing filename"); + fname++; + cptr = strchr(fname, '"'); + if(!cptr) + yyerror("Malformed '#...' line-directive; missing terminating \""); + *cptr = '\0'; + line_number = lineno - 1; /* We didn't read the newline */ + input_name = xstrdup(fname); + } + /* * Strip everything until a ';' taking * into account braces {} for structures, diff --git a/tools/wrc/parser.y b/tools/wrc/parser.y index 4215982fdae..fae37fdaa7c 100644 --- a/tools/wrc/parser.y +++ b/tools/wrc/parser.y @@ -135,6 +135,8 @@ stringtable_t *tagstt; /* Stringtable tag. stringtable_t *sttres; /* Stringtable resources. This holds the list of * stringtables with different lanuages */ +static int dont_want_id = 0; /* See language parsing for details */ + /* Set to the current options of the currently scanning stringtable */ static int *tagstt_memopt; static characts_t *tagstt_characts; @@ -305,7 +307,7 @@ static int rsrcid_to_token(int lookahead); %type toolbar_items %type dlginit %type optional_style_pair -%type any_num any_nums +%type any_num %type