Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
be7558fc
Commit
be7558fc
authored
Aug 20, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrc: Print a warning when encountering utf8 strings in non-utf8 codepage.
parent
385594aa
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
0 deletions
+34
-0
genres.c
tools/wrc/genres.c
+3
-0
parser.l
tools/wrc/parser.l
+3
-0
utils.c
tools/wrc/utils.c
+23
-0
utils.h
tools/wrc/utils.h
+1
-0
wrc.c
tools/wrc/wrc.c
+3
-0
wrc.h
tools/wrc/wrc.h
+1
-0
No files found.
tools/wrc/genres.c
View file @
be7558fc
...
...
@@ -314,6 +314,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
++
)
...
...
tools/wrc/parser.l
View file @
be7558fc
...
...
@@ -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;
}
...
...
tools/wrc/utils.c
View file @
be7558fc
...
...
@@ -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
)
{
...
...
tools/wrc/utils.h
View file @
be7558fc
...
...
@@ -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
);
...
...
tools/wrc/wrc.c
View file @
be7558fc
...
...
@@ -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
"
);
...
...
tools/wrc/wrc.h
View file @
be7558fc
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment