Author: cwittich Date: Sat Aug 22 17:35:17 2009 New Revision: 42851
URL: http://svn.reactos.org/svn/reactos?rev=42851&view=rev Log: sync wrc to wine 1.1.28
Modified: trunk/reactos/tools/wrc/genres.c trunk/reactos/tools/wrc/lex.yy.c trunk/reactos/tools/wrc/parser.l trunk/reactos/tools/wrc/utils.c trunk/reactos/tools/wrc/utils.h trunk/reactos/tools/wrc/wrc.c trunk/reactos/tools/wrc/wrc.h
Modified: trunk/reactos/tools/wrc/genres.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/wrc/genres.c?rev=4285... ============================================================================== --- trunk/reactos/tools/wrc/genres.c [iso-8859-1] (original) +++ trunk/reactos/tools/wrc/genres.c [iso-8859-1] Sat Aug 22 17:35:17 2009 @@ -317,6 +317,9 @@ if (!check_unicode_conversion( str, newstr, codepage )) error( "String %s does not convert identically to Unicode and back in codepage %d. " "Try using a Unicode string instead\n", str->str.cstr, codepage ); + if (check_valid_utf8( str, codepage )) + warning( "string "%s" seems to be UTF-8 but codepage %u is in use.\n", + str->str.cstr, codepage ); } if (!isterm) put_word(res, newstr->size); for(cnt = 0; cnt < newstr->size; cnt++)
Modified: trunk/reactos/tools/wrc/lex.yy.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/wrc/lex.yy.c?rev=4285... ============================================================================== --- trunk/reactos/tools/wrc/lex.yy.c [iso-8859-1] (original) +++ trunk/reactos/tools/wrc/lex.yy.c [iso-8859-1] Sat Aug 22 17:35:17 2009 @@ -2672,6 +2672,9 @@ if (!check_unicode_conversion( str, str_w, current_codepage )) parser_error("String %s does not convert identically to Unicode and back in codepage %d. " "Try using a Unicode string instead", str->str.cstr, current_codepage ); + if (check_valid_utf8( str, current_codepage )) + parser_warning( "string "%s" seems to be UTF-8 but codepage %u is in use.", + str->str.cstr, current_codepage ); free_string( str ); return str_w; }
Modified: trunk/reactos/tools/wrc/parser.l URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/wrc/parser.l?rev=4285... ============================================================================== --- trunk/reactos/tools/wrc/parser.l [iso-8859-1] (original) +++ trunk/reactos/tools/wrc/parser.l [iso-8859-1] Sat Aug 22 17:35:17 2009 @@ -637,6 +637,9 @@ if (!check_unicode_conversion( str, str_w, current_codepage )) parser_error("String %s does not convert identically to Unicode and back in codepage %d. " "Try using a Unicode string instead", str->str.cstr, current_codepage ); + if (check_valid_utf8( str, current_codepage )) + parser_warning( "string "%s" seems to be UTF-8 but codepage %u is in use.", + str->str.cstr, current_codepage ); free_string( str ); return str_w; }
Modified: trunk/reactos/tools/wrc/utils.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/wrc/utils.c?rev=42851... ============================================================================== --- trunk/reactos/tools/wrc/utils.c [iso-8859-1] (original) +++ trunk/reactos/tools/wrc/utils.c [iso-8859-1] Sat Aug 22 17:35:17 2009 @@ -311,6 +311,29 @@ free( str ); }
+/* check if the string is valid utf8 despite a different codepage being in use */ +int check_valid_utf8( const string_t *str, int codepage ) +{ + unsigned int i; + + if (!check_utf8) return 0; + if (!codepage) return 0; + if (!wine_cp_get_table( codepage )) return 0; + + for (i = 0; i < str->size; i++) + { + if ((unsigned char)str->str.cstr[i] >= 0xf5) goto done; + if ((unsigned char)str->str.cstr[i] >= 0xc2) break; + if ((unsigned char)str->str.cstr[i] >= 0x80) goto done; + } + if (i == str->size) return 0; /* no 8-bit chars at all */ + + if (wine_utf8_mbstowcs( MB_ERR_INVALID_CHARS, str->str.cstr, str->size, NULL, 0 ) >= 0) return 1; + +done: + check_utf8 = 0; /* at least one 8-bit non-utf8 string found, stop checking */ + return 0; +}
int check_unicode_conversion( const string_t *str_a, const string_t *str_w, int codepage ) {
Modified: trunk/reactos/tools/wrc/utils.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/wrc/utils.h?rev=42851... ============================================================================== --- trunk/reactos/tools/wrc/utils.h [iso-8859-1] (original) +++ trunk/reactos/tools/wrc/utils.h [iso-8859-1] Sat Aug 22 17:35:17 2009 @@ -45,6 +45,7 @@ int compare_name_id(const name_id_t *n1, const name_id_t *n2); string_t *convert_string(const string_t *str, enum str_e type, int codepage); void free_string( string_t *str ); +int check_valid_utf8( const string_t *str, int codepage ); int check_unicode_conversion( const string_t *str_a, const string_t *str_w, int codepage ); int get_language_codepage( unsigned short lang, unsigned short sublang );
Modified: trunk/reactos/tools/wrc/wrc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/wrc/wrc.c?rev=42851&a... ============================================================================== --- trunk/reactos/tools/wrc/wrc.c [iso-8859-1] (original) +++ trunk/reactos/tools/wrc/wrc.c [iso-8859-1] Sat Aug 22 17:35:17 2009 @@ -155,6 +155,8 @@ */ int no_preprocess = 0;
+int check_utf8 = 1; /* whether to check for valid utf8 */ + static int verify_translations_mode;
char *output_name = NULL; /* The name given by the -o option */ @@ -292,6 +294,7 @@
/* Reset the language */ currentlanguage = dup_language( defaultlanguage ); + check_utf8 = 1;
/* Go from .rc to .res */ chat("Starting parse\n"); @@ -514,14 +517,11 @@ } if (load_file( input_name, output_name )) exit(1); } - /* stdin special case. NULL means "stdin" for wpp. */ - if (nb_files == 0) { + if (nb_files == 0) + { if(!output_name && !preprocess_only) - { - output_name = dup_basename("stdin", ".rc"); - strcat(output_name, ".res"); - } + output_name = strdup("wrc.tab.res"); if (load_file( NULL, output_name )) exit(1); }
Modified: trunk/reactos/tools/wrc/wrc.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/wrc/wrc.h?rev=42851&a... ============================================================================== --- trunk/reactos/tools/wrc/wrc.h [iso-8859-1] (original) +++ trunk/reactos/tools/wrc/wrc.h [iso-8859-1] Sat Aug 22 17:35:17 2009 @@ -43,6 +43,7 @@ extern int byteorder; extern int preprocess_only; extern int no_preprocess; +extern int check_utf8;
extern char *output_name; extern char *input_name;