Module: wine Branch: master Commit: 16d57370090a63560e01e64699517ae27ce94c7f URL: http://source.winehq.org/git/wine.git/?a=commit;h=16d57370090a63560e01e64699...
Author: Akihiro Sagawa sagawa.aki@gmail.com Date: Mon Apr 4 19:01:01 2011 +0900
libwine: MB_ERR_INVALID_CHARS makes an error when the undefined byte character is used.
---
dlls/kernel32/tests/codepage.c | 1 - libs/wine/mbtowc.c | 13 +++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/dlls/kernel32/tests/codepage.c b/dlls/kernel32/tests/codepage.c index 96dd45d..13f9b75 100644 --- a/dlls/kernel32/tests/codepage.c +++ b/dlls/kernel32/tests/codepage.c @@ -385,7 +385,6 @@ static void test_undefined_byte_char(void) ret = MultiByteToWideChar(testset[i].codepage, MB_ERR_INVALID_CHARS, testset[i].str, -1, NULL, 0); if (testset[i].is_error) { - todo_wine ok(ret == 0 && GetLastError() == ERROR_NO_UNICODE_TRANSLATION, "ret is %d, GetLastError is %u (cp %d)\n", ret, GetLastError(), testset[i].codepage); diff --git a/libs/wine/mbtowc.c b/libs/wine/mbtowc.c index 8b06a89..1995b31 100644 --- a/libs/wine/mbtowc.c +++ b/libs/wine/mbtowc.c @@ -39,6 +39,13 @@ static int get_decomposition( WCHAR src, WCHAR *dst, unsigned int dstlen ) return res; }
+/* check the code whether it is in Unicode Private Use Area (PUA). */ +/* MB_ERR_INVALID_CHARS raises an error converting from 1-byte character to PUA. */ +static inline int is_private_use_area_char(WCHAR code) +{ + return (code >= 0xe000 && code <= 0xf8ff); +} + /* check src string for invalid chars; return non-zero if invalid char found */ static inline int check_invalid_chars_sbcs( const struct sbcs_table *table, int flags, const unsigned char *src, unsigned int srclen ) @@ -49,7 +56,8 @@ static inline int check_invalid_chars_sbcs( const struct sbcs_table *table, int + (def_unicode_char & 0xff)]; while (srclen) { - if (cp2uni[*src] == def_unicode_char && *src != def_char) break; + if ((cp2uni[*src] == def_unicode_char && *src != def_char) || + is_private_use_area_char(cp2uni[*src])) break; src++; srclen--; } @@ -167,7 +175,8 @@ static inline int check_invalid_chars_dbcs( const struct dbcs_table *table, src++; srclen--; } - else if (cp2uni[*src] == def_unicode_char && *src != def_char) break; + else if ((cp2uni[*src] == def_unicode_char && *src != def_char) || + is_private_use_area_char(cp2uni[*src])) break; src++; srclen--; }