wrc: Add an option to set the input codepage to UTF-8.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-02-07 08:48:08 +01:00
parent 2045950096
commit 1d8f4fe4a0
5 changed files with 16 additions and 6 deletions

View File

@ -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 );

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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