wrc: Add support for loading multiple input files at once.
This commit is contained in:
parent
6cf96bf940
commit
e25bc79da1
@ -34,5 +34,6 @@ extern char *parser_text;
|
|||||||
extern int yy_flex_debug;
|
extern int yy_flex_debug;
|
||||||
|
|
||||||
int parser_lex(void);
|
int parser_lex(void);
|
||||||
|
int parser_lex_destroy(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -121,6 +121,8 @@ cident [a-zA-Z_][0-9a-zA-Z_]*
|
|||||||
/* Always update the current character position within a line */
|
/* 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_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 addcchar(char c);
|
||||||
static void addwchar(WCHAR s);
|
static void addwchar(WCHAR s);
|
||||||
static string_t *get_buffered_cstring(void);
|
static string_t *get_buffered_cstring(void);
|
||||||
|
@ -169,12 +169,12 @@
|
|||||||
|
|
||||||
int want_nl = 0; /* Signal flex that we need the next newline */
|
int want_nl = 0; /* Signal flex that we need the next newline */
|
||||||
int want_id = 0; /* Signal flex that we need the next identifier */
|
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
|
* It is set while parsing a stringtable to one of
|
||||||
* the stringtables in the sttres list or a new one
|
* the stringtables in the sttres list or a new one
|
||||||
* if the language was not parsed before.
|
* 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
|
* stringtables with different lanuages
|
||||||
*/
|
*/
|
||||||
static int dont_want_id = 0; /* See language parsing for details */
|
static int dont_want_id = 0; /* See language parsing for details */
|
||||||
@ -358,7 +358,7 @@ static int rsrcid_to_token(int lookahead);
|
|||||||
|
|
||||||
resource_file
|
resource_file
|
||||||
: resources {
|
: resources {
|
||||||
resource_t *rsc;
|
resource_t *rsc, *head;
|
||||||
/* First add stringtables to the resource-list */
|
/* First add stringtables to the resource-list */
|
||||||
rsc = build_stt_resources(sttres);
|
rsc = build_stt_resources(sttres);
|
||||||
/* 'build_stt_resources' returns a head and $1 is a tail */
|
/* 'build_stt_resources' returns a head and $1 is a tail */
|
||||||
@ -384,8 +384,18 @@ resource_file
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
$1 = rsc;
|
$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;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
152
tools/wrc/wrc.c
152
tools/wrc/wrc.c
@ -232,6 +232,68 @@ static void exit_on_signal( int sig )
|
|||||||
exit(1); /* this will call the atexit functions */
|
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[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
extern char* optarg;
|
extern char* optarg;
|
||||||
@ -240,7 +302,6 @@ int main(int argc,char *argv[])
|
|||||||
int opti = 0;
|
int opti = 0;
|
||||||
int stdinc = 1;
|
int stdinc = 1;
|
||||||
int lose = 0;
|
int lose = 0;
|
||||||
int ret;
|
|
||||||
int i;
|
int i;
|
||||||
int cmdlen;
|
int cmdlen;
|
||||||
|
|
||||||
@ -402,20 +463,6 @@ int main(int argc,char *argv[])
|
|||||||
wpp_add_include_path(INCLUDEDIR"/msvcrt");
|
wpp_add_include_path(INCLUDEDIR"/msvcrt");
|
||||||
wpp_add_include_path(INCLUDEDIR"/windows");
|
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 */
|
/* Kill io buffering when some kind of debuglevel is enabled */
|
||||||
if(debuglevel)
|
if(debuglevel)
|
||||||
@ -435,65 +482,28 @@ int main(int argc,char *argv[])
|
|||||||
if(!currentlanguage)
|
if(!currentlanguage)
|
||||||
currentlanguage = new_language(0, 0);
|
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);
|
atexit(cleanup_files);
|
||||||
|
|
||||||
/* Run the preprocessor on the input */
|
if (input_name) /* specified with -i option */
|
||||||
if(!no_preprocess)
|
{
|
||||||
{
|
if(!output_name && !preprocess_only)
|
||||||
/*
|
{
|
||||||
* Preprocess the input to a temp-file, or stdout if
|
output_name = dup_basename(input_name, ".rc");
|
||||||
* no output was given.
|
strcat(output_name, ".res");
|
||||||
*/
|
}
|
||||||
|
if (load_file( input_name, output_name )) exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
chat("Starting preprocess\n");
|
while (optind < argc)
|
||||||
|
{
|
||||||
if (!preprocess_only)
|
input_name = argv[optind++];
|
||||||
{
|
if(!output_name && !preprocess_only)
|
||||||
ret = wpp_parse_temp( input_name, output_name, &temp_name );
|
{
|
||||||
}
|
output_name = dup_basename(input_name, ".rc");
|
||||||
else if (output_name)
|
strcat(output_name, ".res");
|
||||||
{
|
}
|
||||||
FILE *output;
|
if (load_file( input_name, output_name )) exit(1);
|
||||||
|
}
|
||||||
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 */
|
|
||||||
|
|
||||||
if(debuglevel & DEBUGLEVEL_DUMP)
|
if(debuglevel & DEBUGLEVEL_DUMP)
|
||||||
dump_resources(resource_top);
|
dump_resources(resource_top);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
.SH NAME
|
.SH NAME
|
||||||
wrc \- Wine Resource Compiler
|
wrc \- Wine Resource Compiler
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.BI "wrc " "[options] " "[inputfile]"
|
.BI "wrc " "[options] " "[inputfiles]"
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.B wrc
|
.B wrc
|
||||||
compiles resources from \fBinputfile\fR
|
compiles resources from \fBinputfile\fR
|
||||||
@ -14,7 +14,7 @@ preprocessor before the resources are compiled. See \fBPREPROCESSOR\fR
|
|||||||
below.
|
below.
|
||||||
.PP
|
.PP
|
||||||
.B wrc
|
.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
|
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
|
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
|
\fBinputfile.res\fR with \fB.rc\fR stripped, or to \fBwrc.tab.res\fR if
|
||||||
|
Loading…
x
Reference in New Issue
Block a user