sync wrc to wine 1.1.28

svn path=/trunk/; revision=42851
This commit is contained in:
Christoph von Wittich 2009-08-22 15:35:17 +00:00
parent a41cdb8eae
commit 1a7345771f
7 changed files with 40 additions and 6 deletions

View file

@ -317,6 +317,9 @@ static void put_string(res_t *res, const string_t *str, enum str_e type, int ist
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++)

View file

@ -2672,6 +2672,9 @@ static string_t *get_buffered_cstring(void)
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;
}

View file

@ -637,6 +637,9 @@ static string_t *get_buffered_cstring(void)
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;
}

View file

@ -311,6 +311,29 @@ void free_string(string_t *str)
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 )
{

View file

@ -45,6 +45,7 @@ char *dup_basename(const char *name, const char *ext);
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 );

View file

@ -155,6 +155,8 @@ int preprocess_only = 0;
*/
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 @@ static int load_file( const char *input_name, const char *output_name )
/* Reset the language */
currentlanguage = dup_language( defaultlanguage );
check_utf8 = 1;
/* Go from .rc to .res */
chat("Starting parse\n");
@ -514,14 +517,11 @@ int main(int argc,char *argv[])
}
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);
}

View file

@ -43,6 +43,7 @@ extern int pedantic;
extern int byteorder;
extern int preprocess_only;
extern int no_preprocess;
extern int check_utf8;
extern char *output_name;
extern char *input_name;