Alexandre Julliard : libwine: Get the reverse mapping of the Unicode default char to check for invalid chars .
Alexandre Julliard
julliard at winehq.org
Mon Feb 23 10:00:42 CST 2009
Module: wine
Branch: master
Commit: b38b207625c36a332a564935af70040e20a2b63e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b38b207625c36a332a564935af70040e20a2b63e
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Feb 23 15:16:35 2009 +0100
libwine: Get the reverse mapping of the Unicode default char to check for invalid chars.
We can't assume that wctomb(Unicode default char) is identical to the Ansi
default char.
---
libs/wine/mbtowc.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/libs/wine/mbtowc.c b/libs/wine/mbtowc.c
index 6249e41..8b06a89 100644
--- a/libs/wine/mbtowc.c
+++ b/libs/wine/mbtowc.c
@@ -44,10 +44,12 @@ static inline int check_invalid_chars_sbcs( const struct sbcs_table *table, int
const unsigned char *src, unsigned int srclen )
{
const WCHAR * const cp2uni = (flags & MB_USEGLYPHCHARS) ? table->cp2uni_glyphs : table->cp2uni;
+ const WCHAR def_unicode_char = table->info.def_unicode_char;
+ const unsigned char def_char = table->uni2cp_low[table->uni2cp_high[def_unicode_char >> 8]
+ + (def_unicode_char & 0xff)];
while (srclen)
{
- if (cp2uni[*src] == table->info.def_unicode_char && *src != table->info.def_char)
- break;
+ if (cp2uni[*src] == def_unicode_char && *src != def_char) break;
src++;
srclen--;
}
@@ -151,20 +153,21 @@ static inline int check_invalid_chars_dbcs( const struct dbcs_table *table,
{
const WCHAR * const cp2uni = table->cp2uni;
const unsigned char * const cp2uni_lb = table->cp2uni_leadbytes;
-
+ const WCHAR def_unicode_char = table->info.def_unicode_char;
+ const unsigned short def_char = table->uni2cp_low[table->uni2cp_high[def_unicode_char >> 8]
+ + (def_unicode_char & 0xff)];
while (srclen)
{
unsigned char off = cp2uni_lb[*src];
if (off) /* multi-byte char */
{
if (srclen == 1) break; /* partial char, error */
- if (cp2uni[(off << 8) + src[1]] == table->info.def_unicode_char &&
- ((src[0] << 8) | src[1]) != table->info.def_char) break;
+ if (cp2uni[(off << 8) + src[1]] == def_unicode_char &&
+ ((src[0] << 8) | src[1]) != def_char) break;
src++;
srclen--;
}
- else if (cp2uni[*src] == table->info.def_unicode_char &&
- *src != table->info.def_char) break;
+ else if (cp2uni[*src] == def_unicode_char && *src != def_char) break;
src++;
srclen--;
}
More information about the wine-cvs
mailing list