-sync wrc to wine 1.1.27

-apply a patch from Marcus Meissner to fix reading from stdin (broken in current wine)

svn path=/trunk/; revision=42498
This commit is contained in:
Christoph von Wittich 2009-08-08 09:09:37 +00:00
parent e465790307
commit db136c3959
10 changed files with 2528 additions and 1925 deletions

File diff suppressed because it is too large Load diff

View file

@ -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);
@ -571,7 +573,7 @@ L\" {
}
{ws}+ want_id = wanted_id; /* Eat whitespace */
<INITIAL>. return yytext[0];
<INITIAL>[ -~] return yytext[0];
<*>.|\n {
/* Catch all rule to find any unmatched text */
@ -580,10 +582,11 @@ L\" {
line_number++;
char_number = 1;
}
parser_warning("Unmatched text '%c' (0x%02x) YY_START=%d\n",
isprint(*yytext & 0xff) ? *yytext : '.', *yytext, YY_START);
parser_error("Unmatched text '%c' (0x%02x) YY_START=%d",
isprint((unsigned char)*yytext) ? *yytext : '.', *yytext, YY_START);
}
<<EOF>> current_codepage = -1; yyterminate();
%%
/* These dup functions copy the enclosed '\0' from

File diff suppressed because it is too large Load diff

View file

@ -1,27 +1,37 @@
/* A Bison parser, made by GNU Bison 2.1. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
/* A Bison parser, made by GNU Bison 2.4.1. */
This program is free software; you can redistribute it and/or modify
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
@ -114,97 +124,16 @@
pUPM = 340
};
#endif
/* Tokens. */
#define tNL 258
#define tNUMBER 259
#define tLNUMBER 260
#define tSTRING 261
#define tIDENT 262
#define tFILENAME 263
#define tRAWDATA 264
#define tACCELERATORS 265
#define tBITMAP 266
#define tCURSOR 267
#define tDIALOG 268
#define tDIALOGEX 269
#define tMENU 270
#define tMENUEX 271
#define tMESSAGETABLE 272
#define tRCDATA 273
#define tVERSIONINFO 274
#define tSTRINGTABLE 275
#define tFONT 276
#define tFONTDIR 277
#define tICON 278
#define tHTML 279
#define tAUTO3STATE 280
#define tAUTOCHECKBOX 281
#define tAUTORADIOBUTTON 282
#define tCHECKBOX 283
#define tDEFPUSHBUTTON 284
#define tPUSHBUTTON 285
#define tRADIOBUTTON 286
#define tSTATE3 287
#define tGROUPBOX 288
#define tCOMBOBOX 289
#define tLISTBOX 290
#define tSCROLLBAR 291
#define tCONTROL 292
#define tEDITTEXT 293
#define tRTEXT 294
#define tCTEXT 295
#define tLTEXT 296
#define tBLOCK 297
#define tVALUE 298
#define tSHIFT 299
#define tALT 300
#define tASCII 301
#define tVIRTKEY 302
#define tGRAYED 303
#define tCHECKED 304
#define tINACTIVE 305
#define tNOINVERT 306
#define tPURE 307
#define tIMPURE 308
#define tDISCARDABLE 309
#define tLOADONCALL 310
#define tPRELOAD 311
#define tFIXED 312
#define tMOVEABLE 313
#define tCLASS 314
#define tCAPTION 315
#define tCHARACTERISTICS 316
#define tEXSTYLE 317
#define tSTYLE 318
#define tVERSION 319
#define tLANGUAGE 320
#define tFILEVERSION 321
#define tPRODUCTVERSION 322
#define tFILEFLAGSMASK 323
#define tFILEOS 324
#define tFILETYPE 325
#define tFILEFLAGS 326
#define tFILESUBTYPE 327
#define tMENUBARBREAK 328
#define tMENUBREAK 329
#define tMENUITEM 330
#define tPOPUP 331
#define tSEPARATOR 332
#define tHELP 333
#define tTOOLBAR 334
#define tBUTTON 335
#define tBEGIN 336
#define tEND 337
#define tDLGINIT 338
#define tNOT 339
#define pUPM 340
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 1676 of yacc.c */
#line 238 "parser.y"
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 241 "parser.y"
typedef union YYSTYPE {
string_t *str;
int num;
int *iptr;
@ -246,15 +175,17 @@ typedef union YYSTYPE {
style_pair_t *styles;
style_t *style;
ani_any_t *ani;
/* Line 1676 of yacc.c */
#line 183 "parser.tab.h"
} YYSTYPE;
/* Line 1447 of yacc.c. */
#line 252 "parser.tab.h"
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
extern YYSTYPE parser_lval;

View file

@ -129,9 +129,6 @@
#include <assert.h>
#include <ctype.h>
#include <string.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#include "wrc.h"
#include "utils.h"
@ -172,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 */
@ -361,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 */
@ -387,8 +384,20 @@ resource_file
}
else
$1 = rsc;
/* Final statement before were done */
resource_top = get_resource_head($1);
/* Final statements before were done */
if ((head = get_resource_head($1)) != NULL)
{
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;
}
;

View file

@ -292,7 +292,10 @@ static resource_t *read_res32(FILE *fp)
usrres = new_user(type, NULL, new_int(memopt));
}
else
{
free (type);
usrres = NULL;
}
rsc = new_resource(res_type,
usrres,
memopt,
@ -351,7 +354,7 @@ resource_t *read_resfile(char *inname)
fp = fopen(inname, "rb");
if(!fp)
error("Could not open inputfile %s\n", inname);
fatal_perror("Could not open %s", inname);
/* Determine 16 or 32 bit .res file */
if(fread(&rh, 1, sizeof(rh), fp) != sizeof(rh))

View file

@ -96,6 +96,17 @@ void internal_error(const char *file, int line, const char *s, ...)
exit(3);
}
void fatal_perror( const char *msg, ... )
{
va_list valist;
va_start( valist, msg );
fprintf(stderr, "Error: ");
vfprintf( stderr, msg, valist );
perror( " " );
va_end( valist );
exit(2);
}
void error(const char *s, ...)
{
va_list ap;

View file

@ -36,7 +36,8 @@ char *xstrdup(const char *str);
int parser_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
int parser_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
void internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4), noreturn));
void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
void fatal_perror( const char *msg, ... ) __attribute__((format (printf, 1, 2), noreturn));
void error(const char *s, ...) __attribute__((format (printf, 1, 2), noreturn));
void warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
void chat(const char *s, ...) __attribute__((format (printf, 1, 2)));

View file

@ -55,7 +55,7 @@
#endif
static const char usage[] =
"Usage: wrc [options...] [infile[.rc|.res]] [outfile]\n"
"Usage: wrc [options...] [infile[.rc|.res]]\n"
" -D id[=val] Define preprocessor identifier id=val\n"
" -E Preprocess only\n"
" -F target Ignored for compatibility with windres\n"
@ -132,6 +132,7 @@ int extensions = 1;
/*
* Language setting for resources (-l option)
*/
static language_t *defaultlanguage;
language_t *currentlanguage = NULL;
/*
@ -174,29 +175,42 @@ int getopt (int argc, char *const *argv, const char *optstring);
static void cleanup_files(void);
static void segvhandler(int sig);
enum long_options_values
{
LONG_OPT_NOSTDINC = 1,
LONG_OPT_TMPFILE,
LONG_OPT_NOTMPFILE,
LONG_OPT_PREPROCESSOR,
LONG_OPT_VERSION,
LONG_OPT_DEBUG,
LONG_OPT_ENDIANESS,
LONG_OPT_PEDANTIC,
LONG_OPT_VERIFY_TRANSL
};
static const char short_options[] =
"D:Ef:F:hi:I:J:l:o:O:rU:v";
static const struct option long_options[] = {
{ "debug", 1, 0, 6 },
{ "debug", 1, 0, LONG_OPT_DEBUG },
{ "define", 1, 0, 'D' },
{ "endianess", 1, 0, 7 },
{ "endianess", 1, 0, LONG_OPT_ENDIANESS },
{ "help", 0, 0, 'h' },
{ "include-dir", 1, 0, 'I' },
{ "input", 1, 0, 'i' },
{ "input-format", 1, 0, 'J' },
{ "language", 1, 0, 'l' },
{ "no-use-temp-file", 0, 0, 3 },
{ "nostdinc", 0, 0, 1 },
{ "no-use-temp-file", 0, 0, LONG_OPT_NOTMPFILE },
{ "nostdinc", 0, 0, LONG_OPT_NOSTDINC },
{ "output", 1, 0, 'o' },
{ "output-format", 1, 0, 'O' },
{ "pedantic", 0, 0, 8 },
{ "preprocessor", 1, 0, 4 },
{ "pedantic", 0, 0, LONG_OPT_PEDANTIC },
{ "preprocessor", 1, 0, LONG_OPT_PREPROCESSOR },
{ "target", 1, 0, 'F' },
{ "undefine", 1, 0, 'U' },
{ "use-temp-file", 0, 0, 2 },
{ "use-temp-file", 0, 0, LONG_OPT_TMPFILE },
{ "verbose", 0, 0, 'v' },
{ "verify-translations", 0, 0, 9 },
{ "version", 0, 0, 5 },
{ "verify-translations", 0, 0, LONG_OPT_VERIFY_TRANSL },
{ "version", 0, 0, LONG_OPT_VERSION },
{ 0, 0, 0, 0 }
};
@ -232,6 +246,71 @@ 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;
}
/* Reset the language */
currentlanguage = dup_language( defaultlanguage );
/* 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);
if (temp_name)
{
unlink( temp_name );
temp_name = NULL;
}
free( currentlanguage );
return ret;
}
int main(int argc,char *argv[])
{
extern char* optarg;
@ -240,9 +319,10 @@ int main(int argc,char *argv[])
int opti = 0;
int stdinc = 1;
int lose = 0;
int ret;
int nb_files = 0;
int i;
int cmdlen;
char **files = xmalloc( argc * sizeof(*files) );
signal(SIGSEGV, segvhandler);
signal( SIGTERM, exit_on_signal );
@ -279,27 +359,27 @@ int main(int argc,char *argv[])
{
switch(optc)
{
case 1:
case LONG_OPT_NOSTDINC:
stdinc = 0;
break;
case 2:
case LONG_OPT_TMPFILE:
if (debuglevel) warning("--use-temp-file option not yet supported, ignored.\n");
break;
case 3:
case LONG_OPT_NOTMPFILE:
if (debuglevel) warning("--no-use-temp-file option not yet supported, ignored.\n");
break;
case 4:
case LONG_OPT_PREPROCESSOR:
if (strcmp(optarg, "cat") == 0) no_preprocess = 1;
else fprintf(stderr, "-P option not yet supported, ignored.\n");
break;
case 5:
case LONG_OPT_VERSION:
printf(version_string);
exit(0);
break;
case 6:
case LONG_OPT_DEBUG:
debuglevel = strtol(optarg, NULL, 0);
break;
case 7:
case LONG_OPT_ENDIANESS:
switch(optarg[0])
{
case 'n':
@ -319,11 +399,11 @@ int main(int argc,char *argv[])
lose++;
}
break;
case 8:
case LONG_OPT_PEDANTIC:
pedantic = 1;
wpp_set_pedantic(1);
break;
case 9:
case LONG_OPT_VERIFY_TRANSL:
verify_translations_mode = 1;
break;
case 'D':
@ -339,8 +419,7 @@ int main(int argc,char *argv[])
printf(usage);
exit(0);
case 'i':
if (!input_name) input_name = strdup(optarg);
else error("Too many input files.\n");
files[nb_files++] = optarg;
break;
case 'I':
wpp_add_include_path(optarg);
@ -355,7 +434,7 @@ int main(int argc,char *argv[])
lan = strtol(optarg, NULL, 0);
if (get_language_codepage(PRIMARYLANGID(lan), SUBLANGID(lan)) == -1)
error("Language %04x is not supported\n", lan);
currentlanguage = new_language(PRIMARYLANGID(lan), SUBLANGID(lan));
defaultlanguage = new_language(PRIMARYLANGID(lan), SUBLANGID(lan));
}
break;
case 'f':
@ -402,20 +481,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)
@ -432,68 +497,33 @@ int main(int argc,char *argv[])
(debuglevel & DEBUGLEVEL_PPMSG) != 0 );
/* Check if the user set a language, else set default */
if(!currentlanguage)
currentlanguage = new_language(0, 0);
if(!defaultlanguage)
defaultlanguage = 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.
*/
while (optind < argc) files[nb_files++] = argv[optind++];
chat("Starting preprocess\n");
for (i = 0; i < nb_files; i++)
{
input_name = files[i];
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 (!preprocess_only)
{
ret = wpp_parse_temp( input_name, output_name, &temp_name );
}
else if (output_name)
{
FILE *output;
if (!(output = fopen( output_name, "w" )))
error( "Could not open %s for writing\n", 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")))
error("Could not open %s for input\n", input_name);
ret = parser_parse();
if(input_name) fclose(parser_in);
if(ret) exit(1); /* Error during parse */
/* stdin special case. NULL means "stdin" for wpp. */
if (nb_files == 0) {
if(!output_name && !preprocess_only)
{
output_name = dup_basename("stdin", ".rc");
strcat(output_name, ".res");
}
if (load_file( NULL, output_name )) exit(1);
}
if(debuglevel & DEBUGLEVEL_DUMP)
dump_resources(resource_top);

View file

@ -52,9 +52,7 @@ void write_resfile(char *outname, resource_t *top)
fo = fopen(outname, "wb");
if(!fo)
{
error("Could not open %s\n", outname);
}
fatal_perror("Could not open %s", outname);
if(win32)
{
@ -102,5 +100,6 @@ void write_resfile(char *outname, resource_t *top)
}
}
}
fclose(fo);
if (fclose(fo))
fatal_perror("Error writing %s", outname);
}