Module: wine Branch: master Commit: 1d8f4fe4a0a90fada6c52fc7e766ae4fd8c64252 URL: https://source.winehq.org/git/wine.git/?a=commit;h=1d8f4fe4a0a90fada6c52fc7e...
Author: Alexandre Julliard julliard@winehq.org Date: Fri Feb 7 08:48:08 2020 +0100
wrc: Add an option to set the input codepage to UTF-8.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
tools/makedep.c | 8 ++++---- tools/wrc/parser.l | 2 +- tools/wrc/wrc.c | 8 +++++++- tools/wrc/wrc.h | 1 + tools/wrc/wrc.man.in | 3 +++ 5 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/tools/makedep.c b/tools/makedep.c index e5628712cc..12095436dd 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -2710,7 +2710,7 @@ static void output_source_rc( struct makefile *make, struct incl_file *source, c if (source->file->flags & FLAG_GENERATED) strarray_add( &make->clean_files, source->name ); strarray_add( &make->res_files, strmake( "%s.res", obj )); output( "%s.res: %s\n", obj_dir_path( make, obj ), source->filename ); - output( "\t%s -o $@", tools_path( make, "wrc" ) ); + output( "\t%s -u -o $@", tools_path( make, "wrc" ) ); if (make->is_win16) output_filename( "-m16" ); else output_filenames( target_flags ); output_filename( "--nostdinc" ); @@ -2735,7 +2735,7 @@ static void output_source_rc( struct makefile *make, struct incl_file *source, c { strarray_add( &make->clean_files, strmake( "%s.pot", obj )); output( "%s.pot: %s\n", obj_dir_path( make, obj ), source->filename ); - output( "\t%s -O pot -o $@", tools_path( make, "wrc" ) ); + output( "\t%s -u -O pot -o $@", tools_path( make, "wrc" ) ); if (make->is_win16) output_filename( "-m16" ); else output_filenames( target_flags ); output_filename( "--nostdinc" ); @@ -3019,7 +3019,7 @@ static void output_source_spec( struct makefile *make, struct incl_file *source, strarray_add( &make->clean_files, dll_name ); strarray_add( &make->res_files, strmake( "%s.res", obj )); output( "%s.res: %s\n", obj_dir_path( make, obj ), obj_dir_path( make, dll_name )); - output( "\techo "%s.dll TESTDLL \"%s\"" | %s -o $@\n", obj, + output( "\techo "%s.dll TESTDLL \"%s\"" | %s -u -o $@\n", obj, obj_dir_path( make, dll_name ), tools_path( make, "wrc" ));
output( "%s:", obj_dir_path( make, dll_name )); @@ -3492,7 +3492,7 @@ static void output_test_module( struct makefile *make ) output( "all: %s/%s\n", top_obj_dir_path( make, "programs/winetest" ), testres ); output( "%s/%s: %s%s\n", top_obj_dir_path( make, "programs/winetest" ), testres, obj_dir_path( make, stripped ), ext ); - output( "\techo "%s TESTRES \"%s%s\"" | %s -o $@\n", + output( "\techo "%s TESTRES \"%s%s\"" | %s -u -o $@\n", testmodule, obj_dir_path( make, stripped ), ext, tools_path( make, "wrc" ));
output_filenames_obj_dir( make, make->ok_files ); diff --git a/tools/wrc/parser.l b/tools/wrc/parser.l index f456c626d1..d1e768f72c 100644 --- a/tools/wrc/parser.l +++ b/tools/wrc/parser.l @@ -121,7 +121,7 @@ ws [ \f\t\r] /* 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; +#define YY_USER_INIT current_codepage = utf8_input ? CP_UTF8 : -1;
static void addcchar(char c); static void addwchar(WCHAR s); diff --git a/tools/wrc/wrc.c b/tools/wrc/wrc.c index d171bfa2ef..b4cb013f8e 100644 --- a/tools/wrc/wrc.c +++ b/tools/wrc/wrc.c @@ -144,6 +144,8 @@ int preprocess_only = 0; */ int no_preprocess = 0;
+int utf8_input = 0; + int check_utf8 = 1; /* whether to check for valid utf8 */
static int pointer_size = sizeof(void *); @@ -184,7 +186,7 @@ enum long_options_values };
static const char short_options[] = - "b:D:Ef:F:hi:I:J:l:m:o:O:rU:v"; + "b:D:Ef:F:hi:I:J:l:m:o:O:ruU:v"; static const struct option long_options[] = { { "debug", 1, NULL, LONG_OPT_DEBUG }, { "define", 1, NULL, 'D' }, @@ -203,6 +205,7 @@ static const struct option long_options[] = { { "preprocessor", 1, NULL, LONG_OPT_PREPROCESSOR }, { "sysroot", 1, NULL, LONG_OPT_SYSROOT }, { "target", 1, NULL, 'F' }, + { "utf8", 0, NULL, 'u' }, { "undefine", 1, NULL, 'U' }, { "use-temp-file", 0, NULL, LONG_OPT_TMPFILE }, { "verbose", 0, NULL, 'v' }, @@ -503,6 +506,9 @@ int main(int argc,char *argv[]) case 'r': /* ignored for compatibility with rc */ break; + case 'u': + utf8_input = 1; + break; case 'U': wpp_del_define(optarg); break; diff --git a/tools/wrc/wrc.h b/tools/wrc/wrc.h index 77e3e6942e..9664dd0392 100644 --- a/tools/wrc/wrc.h +++ b/tools/wrc/wrc.h @@ -39,6 +39,7 @@ extern int pedantic; extern int byteorder; extern int preprocess_only; extern int no_preprocess; +extern int utf8_input; extern int check_utf8;
extern char *input_name; diff --git a/tools/wrc/wrc.man.in b/tools/wrc/wrc.man.in index 80fcd04c5b..24dca04902 100644 --- a/tools/wrc/wrc.man.in +++ b/tools/wrc/wrc.man.in @@ -124,6 +124,9 @@ To disable preprocessing, use \fB--preprocessor=cat\fR. .I \fB--sysroot=\fIdir\fR Prefix the standard include paths with \fIdir\fR. .TP +.I \fB--utf8\fR, \fB-u\fR +Set the default codepage of the input file to UTF-8. +.TP .I \fB-U\fR, \fB--undefine\fR=\fIid\fR Undefine preprocessor identifier \fIid\fR. Please note that only macros defined up to this point are undefined by this command. However, these