diff --git a/tools/wrc/parser.h b/tools/wrc/parser.h index b9e204589d..e9fc8e6234 100644 --- a/tools/wrc/parser.h +++ b/tools/wrc/parser.h @@ -34,5 +34,6 @@ extern char *parser_text; extern int yy_flex_debug; int parser_lex(void); +int parser_lex_destroy(void); #endif diff --git a/tools/wrc/parser.l b/tools/wrc/parser.l index bddc309554..e706100389 100644 --- a/tools/wrc/parser.l +++ b/tools/wrc/parser.l @@ -121,6 +121,8 @@ cident [a-zA-Z_][0-9a-zA-Z_]* /* Always update the current character position within a line */ #define YY_USER_ACTION char_number+=yyleng; wanted_id = want_id; want_id = 0; +#define YY_USER_INIT current_codepage = -1; + static void addcchar(char c); static void addwchar(WCHAR s); static string_t *get_buffered_cstring(void); diff --git a/tools/wrc/parser.y b/tools/wrc/parser.y index 512d27223f..f891f24c6a 100644 --- a/tools/wrc/parser.y +++ b/tools/wrc/parser.y @@ -169,12 +169,12 @@ int want_nl = 0; /* Signal flex that we need the next newline */ int want_id = 0; /* Signal flex that we need the next identifier */ -stringtable_t *tagstt; /* Stringtable tag. +static stringtable_t *tagstt; /* Stringtable tag. * It is set while parsing a stringtable to one of * the stringtables in the sttres list or a new one * if the language was not parsed before. */ -stringtable_t *sttres; /* Stringtable resources. This holds the list of +static 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 */ @@ -358,7 +358,7 @@ static int rsrcid_to_token(int lookahead); resource_file : resources { - resource_t *rsc; + resource_t *rsc, *head; /* First add stringtables to the resource-list */ rsc = build_stt_resources(sttres); /* 'build_stt_resources' returns a head and $1 is a tail */ @@ -384,8 +384,18 @@ resource_file } else $1 = rsc; - /* Final statement before were done */ - resource_top = get_resource_head($1); + + /* Final statements before were done */ + head = get_resource_head($1); + if (resource_top) /* append to existing resources */ + { + resource_t *tail = resource_top; + while (tail->next) tail = tail->next; + tail->next = head; + head->prev = tail; + } + else resource_top = head; + sttres = NULL; } ; diff --git a/tools/wrc/wrc.c b/tools/wrc/wrc.c index 05bd3f8c65..833d6020b4 100644 --- a/tools/wrc/wrc.c +++ b/tools/wrc/wrc.c @@ -232,6 +232,68 @@ static void exit_on_signal( int sig ) exit(1); /* this will call the atexit functions */ } +/* load a single input file */ +static int load_file( const char *input_name, const char *output_name ) +{ + int ret; + + /* Run the preprocessor on the input */ + if(!no_preprocess) + { + /* + * Preprocess the input to a temp-file, or stdout if + * no output was given. + */ + + chat("Starting preprocess\n"); + + if (!preprocess_only) + { + ret = wpp_parse_temp( input_name, output_name, &temp_name ); + } + else if (output_name) + { + FILE *output; + + if (!(output = fopen( output_name, "w" ))) + fatal_perror( "Could not open %s for writing", output_name ); + ret = wpp_parse( input_name, output ); + fclose( output ); + } + else + { + ret = wpp_parse( input_name, stdout ); + } + + if (ret) return ret; + + if(preprocess_only) + { + output_name = NULL; + exit(0); + } + + input_name = temp_name; + } + + /* Go from .rc to .res */ + chat("Starting parse\n"); + + if(!(parser_in = fopen(input_name, "rb"))) + fatal_perror("Could not open %s for input", input_name); + + ret = parser_parse(); + fclose(parser_in); + parser_lex_destroy(); + if (temp_name) + { + unlink( temp_name ); + temp_name = NULL; + } + return ret; +} + + int main(int argc,char *argv[]) { extern char* optarg; @@ -240,7 +302,6 @@ int main(int argc,char *argv[]) int opti = 0; int stdinc = 1; int lose = 0; - int ret; int i; int cmdlen; @@ -402,20 +463,6 @@ int main(int argc,char *argv[]) wpp_add_include_path(INCLUDEDIR"/msvcrt"); wpp_add_include_path(INCLUDEDIR"/windows"); } - - /* Check for input file on command-line */ - if(optind < argc) - { - if (!input_name) input_name = argv[optind++]; - else error("Too many input files.\n"); - } - - /* Check for output file on command-line */ - if(optind < argc) - { - if (!output_name) output_name = argv[optind++]; - else error("Too many output files.\n"); - } /* Kill io buffering when some kind of debuglevel is enabled */ if(debuglevel) @@ -435,65 +482,28 @@ int main(int argc,char *argv[]) if(!currentlanguage) currentlanguage = new_language(0, 0); - /* Generate appropriate outfile names */ - if(!output_name && !preprocess_only) - { - output_name = dup_basename(input_name, ".rc"); - strcat(output_name, ".res"); - } atexit(cleanup_files); - /* Run the preprocessor on the input */ - if(!no_preprocess) - { - /* - * Preprocess the input to a temp-file, or stdout if - * no output was given. - */ + if (input_name) /* specified with -i option */ + { + if(!output_name && !preprocess_only) + { + output_name = dup_basename(input_name, ".rc"); + strcat(output_name, ".res"); + } + if (load_file( input_name, output_name )) exit(1); + } - chat("Starting preprocess\n"); - - if (!preprocess_only) - { - ret = wpp_parse_temp( input_name, output_name, &temp_name ); - } - else if (output_name) - { - FILE *output; - - if (!(output = fopen( output_name, "w" ))) - fatal_perror( "Could not open %s for writing", output_name ); - ret = wpp_parse( input_name, output ); - fclose( output ); - } - else - { - ret = wpp_parse( input_name, stdout ); - } - - if(ret) - exit(1); /* Error during preprocess */ - - if(preprocess_only) - { - output_name = NULL; - exit(0); - } - - input_name = temp_name; - } - - /* Go from .rc to .res */ - chat("Starting parse\n"); - - if(!(parser_in = fopen(input_name, "rb"))) - fatal_perror("Could not open %s for input", input_name); - - ret = parser_parse(); - - if(input_name) fclose(parser_in); - - if(ret) exit(1); /* Error during parse */ + while (optind < argc) + { + input_name = argv[optind++]; + if(!output_name && !preprocess_only) + { + output_name = dup_basename(input_name, ".rc"); + strcat(output_name, ".res"); + } + if (load_file( input_name, output_name )) exit(1); + } if(debuglevel & DEBUGLEVEL_DUMP) dump_resources(resource_top); diff --git a/tools/wrc/wrc.man.in b/tools/wrc/wrc.man.in index 7dfefc025b..5c8d0c0974 100644 --- a/tools/wrc/wrc.man.in +++ b/tools/wrc/wrc.man.in @@ -3,7 +3,7 @@ .SH NAME wrc \- Wine Resource Compiler .SH SYNOPSIS -.BI "wrc " "[options] " "[inputfile]" +.BI "wrc " "[options] " "[inputfiles]" .SH DESCRIPTION .B wrc compiles resources from \fBinputfile\fR @@ -14,7 +14,7 @@ preprocessor before the resources are compiled. See \fBPREPROCESSOR\fR below. .PP .B wrc -takes only one \fBinputfile\fR as argument. The resources are read from +takes a series of \fBinputfile\fR as argument. The resources are read from standard input if no inputfile is given. If the output file is not specified with \fI-o\fR, then \fBwrc\fR will write the output to \fBinputfile.res\fR with \fB.rc\fR stripped, or to \fBwrc.tab.res\fR if