winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
April 2022
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
1024 discussions
Start a n
N
ew thread
Alexandre Julliard : kernelbase: Support UTF-8 as default Ansi codepage in MultiByteToWideChar().
by Alexandre Julliard
11 Apr '22
11 Apr '22
Module: wine Branch: master Commit: 2cc54d4b854e6c4f9610f60116b320c93c21e1e3 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=2cc54d4b854e6c4f9610f601…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Apr 11 17:26:46 2022 +0200 kernelbase: Support UTF-8 as default Ansi codepage in MultiByteToWideChar(). Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernelbase/locale.c | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/dlls/kernelbase/locale.c b/dlls/kernelbase/locale.c index c0cd0307447..c807b1e0124 100644 --- a/dlls/kernelbase/locale.c +++ b/dlls/kernelbase/locale.c @@ -2283,11 +2283,6 @@ static int mbstowcs_utf8( DWORD flags, const char *src, int srclen, WCHAR *dst, DWORD reslen; NTSTATUS status; - if (flags & ~(MB_PRECOMPOSED | MB_COMPOSITE | MB_USEGLYPHCHARS | MB_ERR_INVALID_CHARS)) - { - SetLastError( ERROR_INVALID_FLAGS ); - return 0; - } if (!dstlen) dst = NULL; status = RtlUTF8ToUnicodeN( dst, dstlen * sizeof(WCHAR), &reslen, src, srclen ); if (status == STATUS_SOME_NOT_MAPPED) @@ -2528,24 +2523,12 @@ static int mbstowcs_dbcs( const CPTABLEINFO *info, const unsigned char *src, int } -static int mbstowcs_codepage( UINT codepage, DWORD flags, const char *src, int srclen, +static int mbstowcs_codepage( const CPTABLEINFO *info, DWORD flags, const char *src, int srclen, WCHAR *dst, int dstlen ) { CPTABLEINFO local_info; - const CPTABLEINFO *info = get_codepage_table( codepage ); const unsigned char *str = (const unsigned char *)src; - if (!info) - { - SetLastError( ERROR_INVALID_PARAMETER ); - return 0; - } - if (flags & ~(MB_PRECOMPOSED | MB_COMPOSITE | MB_USEGLYPHCHARS | MB_ERR_INVALID_CHARS)) - { - SetLastError( ERROR_INVALID_FLAGS ); - return 0; - } - if ((flags & MB_USEGLYPHCHARS) && info->MultiByteTable[256] == 256) { local_info = *info; @@ -6161,6 +6144,7 @@ LCID WINAPI DECLSPEC_HOTPATCH LocaleNameToLCID( const WCHAR *name, DWORD flags ) INT WINAPI DECLSPEC_HOTPATCH MultiByteToWideChar( UINT codepage, DWORD flags, const char *src, INT srclen, WCHAR *dst, INT dstlen ) { + const CPTABLEINFO *info; int ret; if (!src || !srclen || (!dst && dstlen) || dstlen < 0) @@ -6178,19 +6162,24 @@ INT WINAPI DECLSPEC_HOTPATCH MultiByteToWideChar( UINT codepage, DWORD flags, co case CP_UTF7: ret = mbstowcs_utf7( flags, src, srclen, dst, dstlen ); break; - case CP_UTF8: - ret = mbstowcs_utf8( flags, src, srclen, dst, dstlen ); - break; case CP_UNIXCP: - if (unix_cp == CP_UTF8) - { - ret = mbstowcs_utf8( flags, src, srclen, dst, dstlen ); - break; - } codepage = unix_cp; /* fall through */ default: - ret = mbstowcs_codepage( codepage, flags, src, srclen, dst, dstlen ); + if (!(info = get_codepage_table( codepage ))) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return 0; + } + if (flags & ~(MB_PRECOMPOSED | MB_COMPOSITE | MB_USEGLYPHCHARS | MB_ERR_INVALID_CHARS)) + { + SetLastError( ERROR_INVALID_FLAGS ); + return 0; + } + if (info->CodePage == CP_UTF8) + ret = mbstowcs_utf8( flags, src, srclen, dst, dstlen ); + else + ret = mbstowcs_codepage( info, flags, src, srclen, dst, dstlen ); break; } TRACE( "cp %d %s -> %s, ret = %d\n", codepage, debugstr_an(src, srclen), debugstr_wn(dst, ret), ret );
1
0
0
0
Alexandre Julliard : kernelbase: Support UTF-7/8 codepages in get_codepage_table().
by Alexandre Julliard
11 Apr '22
11 Apr '22
Module: wine Branch: master Commit: 8993e15cfa5b77ac2487239354ffe63bbc5e562d URL:
https://source.winehq.org/git/wine.git/?a=commit;h=8993e15cfa5b77ac24872393…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Apr 11 17:21:47 2022 +0200 kernelbase: Support UTF-7/8 codepages in get_codepage_table(). Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/tests/locale.c | 34 ++++++++++++++++-- dlls/kernelbase/locale.c | 86 +++++++++++++------------------------------- 2 files changed, 57 insertions(+), 63 deletions(-) diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c index 9b95fcae640..8dc5814162a 100644 --- a/dlls/kernel32/tests/locale.c +++ b/dlls/kernel32/tests/locale.c @@ -4251,6 +4251,7 @@ static void test_GetCPInfo(void) { BOOL ret; CPINFO cpinfo; + CPINFOEXW cpiw; SetLastError(0xdeadbeef); ret = GetCPInfo(CP_SYMBOL, &cpinfo); @@ -4275,6 +4276,18 @@ static void test_GetCPInfo(void) for (i = 0; i < sizeof(cpinfo.LeadByte); i++) ok(!cpinfo.LeadByte[i], "expected NUL byte in index %u\n", i); ok(cpinfo.MaxCharSize == 5, "expected 5, got 0x%x\n", cpinfo.MaxCharSize); + + memset( &cpiw, 0xcc, sizeof(cpiw) ); + ret = GetCPInfoExW( CP_UTF7, 0, &cpiw ); + ok( ret, "GetCPInfoExW failed err %lu\n", GetLastError() ); + ok( cpiw.DefaultChar[0] == 0x3f, "wrong DefaultChar[0] %02x\n", cpiw.DefaultChar[0] ); + ok( cpiw.DefaultChar[1] == 0, "wrong DefaultChar[1] %02x\n", cpiw.DefaultChar[1] ); + for (i = 0; i < 12; i++) ok( cpiw.LeadByte[i] == 0, "wrong LeadByte[%u] %02x\n", i, cpiw.LeadByte[i] ); + ok( cpiw.MaxCharSize == 5, "wrong MaxCharSize %02x\n", cpiw.MaxCharSize ); + ok( cpiw.CodePage == CP_UTF7, "wrong CodePage %02x\n", cpiw.CodePage ); + ok( cpiw.UnicodeDefaultChar == 0xfffd, "wrong UnicodeDefaultChar %02x\n", cpiw.UnicodeDefaultChar ); + ok( !wcscmp( cpiw.CodePageName, L"65000 (UTF-7)" ), + "wrong CodePageName %s\n", debugstr_w(cpiw.CodePageName) ); } memset(cpinfo.LeadByte, '-', ARRAY_SIZE(cpinfo.LeadByte)); @@ -4293,10 +4306,27 @@ static void test_GetCPInfo(void) ok(cpinfo.DefaultChar[1] == 0, "expected 0, got 0x%x\n", cpinfo.DefaultChar[1]); for (i = 0; i < sizeof(cpinfo.LeadByte); i++) ok(!cpinfo.LeadByte[i], "expected NUL byte in index %u\n", i); - ok(cpinfo.MaxCharSize == 4 || broken(cpinfo.MaxCharSize == 3) /* win9x */, - "expected 4, got %u\n", cpinfo.MaxCharSize); + ok(cpinfo.MaxCharSize == 4, "expected 4, got %u\n", cpinfo.MaxCharSize); + + memset( &cpiw, 0xcc, sizeof(cpiw) ); + ret = GetCPInfoExW( CP_UTF8, 0, &cpiw ); + ok( ret, "GetCPInfoExW failed err %lu\n", GetLastError() ); + ok( cpiw.DefaultChar[0] == 0x3f, "wrong DefaultChar[0] %02x\n", cpiw.DefaultChar[0] ); + ok( cpiw.DefaultChar[1] == 0, "wrong DefaultChar[1] %02x\n", cpiw.DefaultChar[1] ); + for (i = 0; i < 12; i++) ok( cpiw.LeadByte[i] == 0, "wrong LeadByte[%u] %02x\n", i, cpiw.LeadByte[i] ); + ok( cpiw.MaxCharSize == 4, "wrong MaxCharSize %02x\n", cpiw.MaxCharSize ); + ok( cpiw.CodePage == CP_UTF8, "wrong CodePage %02x\n", cpiw.CodePage ); + ok( cpiw.UnicodeDefaultChar == 0xfffd, "wrong UnicodeDefaultChar %02x\n", cpiw.UnicodeDefaultChar ); + ok( !wcscmp( cpiw.CodePageName, L"65001 (UTF-8)" ), + "wrong CodePageName %s\n", debugstr_w(cpiw.CodePageName) ); } + + SetLastError( 0xdeadbeef ); + ret = GetCPInfoExW( 0xbeef, 0, &cpiw ); + ok( !ret, "GetCPInfoExW succeeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() ); + if (pNtGetNlsSectionPtr) { CPTABLEINFO table; diff --git a/dlls/kernelbase/locale.c b/dlls/kernelbase/locale.c index 67052af7e4f..c0cd0307447 100644 --- a/dlls/kernelbase/locale.c +++ b/dlls/kernelbase/locale.c @@ -164,8 +164,8 @@ static const struct { UINT cp; const WCHAR *name; } codepage_names[] = { 28604, L"ISO 8859-14 Latin 8 (Celtic)" }, { 28605, L"ISO 8859-15 Latin 9 (Euro)" }, { 28606, L"ISO 8859-16 Latin 10 (Balkan)" }, - { 65000, L"Unicode (UTF-7)" }, - { 65001, L"Unicode (UTF-8)" } + { 65000, L"65000 (UTF-7)" }, + { 65001, L"65001 (UTF-8)" } }; /* Unicode expanded ligatures */ @@ -1964,24 +1964,28 @@ static WCHAR compose_chars( WCHAR ch1, WCHAR ch2 ) static UINT get_locale_codepage( const NLS_LOCALE_DATA *locale, ULONG flags ) { UINT ret = locale->idefaultansicodepage; - if ((flags & LOCALE_USE_CP_ACP) || ret == CP_UTF8) ret = system_locale->idefaultansicodepage; + if ((flags & LOCALE_USE_CP_ACP) || ret == CP_UTF8) ret = nls_info.AnsiTableInfo.CodePage; return ret; } static UINT get_lcid_codepage( LCID lcid, ULONG flags ) { - UINT ret = GetACP(); + UINT ret = nls_info.AnsiTableInfo.CodePage; - if (!(flags & LOCALE_USE_CP_ACP) && lcid != GetSystemDefaultLCID()) - GetLocaleInfoW( lcid, LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, - (WCHAR *)&ret, sizeof(ret)/sizeof(WCHAR) ); + if (!(flags & LOCALE_USE_CP_ACP) && lcid != system_lcid) + { + const NLS_LOCALE_DATA *locale = NlsValidateLocale( &lcid, 0 ); + if (locale) ret = locale->idefaultansicodepage; + } return ret; } static const CPTABLEINFO *get_codepage_table( UINT codepage ) { + static const CPTABLEINFO utf7_cpinfo = { CP_UTF7, 5, '?', 0xfffd, '?', '?' }; + static const CPTABLEINFO utf8_cpinfo = { CP_UTF8, 4, '?', 0xfffd, '?', '?' }; unsigned int i; USHORT *ptr; SIZE_T size; @@ -1996,15 +2000,13 @@ static const CPTABLEINFO *get_codepage_table( UINT codepage ) codepage = mac_cp; break; case CP_THREAD_ACP: - if (NtCurrentTeb()->CurrentLocale == GetUserDefaultLCID()) return &nls_info.AnsiTableInfo; codepage = get_lcid_codepage( NtCurrentTeb()->CurrentLocale, 0 ); - if (!codepage) return &nls_info.AnsiTableInfo; - break; - default: - if (codepage == nls_info.AnsiTableInfo.CodePage) return &nls_info.AnsiTableInfo; - if (codepage == nls_info.OemTableInfo.CodePage) return &nls_info.OemTableInfo; break; } + if (codepage == nls_info.AnsiTableInfo.CodePage) return &nls_info.AnsiTableInfo; + if (codepage == nls_info.OemTableInfo.CodePage) return &nls_info.OemTableInfo; + if (codepage == CP_UTF8) return &utf8_cpinfo; + if (codepage == CP_UTF7) return &utf7_cpinfo; RtlEnterCriticalSection( &locale_section ); @@ -4838,27 +4840,14 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetCPInfo( UINT codepage, CPINFO *cpinfo ) { const CPTABLEINFO *table; - if (!cpinfo) + if (!cpinfo || !(table = get_codepage_table( codepage ))) { SetLastError( ERROR_INVALID_PARAMETER ); return FALSE; } - switch (codepage) - { - case CP_UTF7: - case CP_UTF8: - cpinfo->DefaultChar[0] = 0x3f; - cpinfo->DefaultChar[1] = 0; - memset( cpinfo->LeadByte, 0, sizeof(cpinfo->LeadByte) ); - cpinfo->MaxCharSize = (codepage == CP_UTF7) ? 5 : 4; - break; - default: - if (!(table = get_codepage_table( codepage ))) return FALSE; - cpinfo->MaxCharSize = table->MaximumCharacterSize; - memcpy( cpinfo->DefaultChar, &table->DefaultChar, sizeof(cpinfo->DefaultChar) ); - memcpy( cpinfo->LeadByte, table->LeadByte, sizeof(cpinfo->LeadByte) ); - break; - } + cpinfo->MaxCharSize = table->MaximumCharacterSize; + memcpy( cpinfo->DefaultChar, &table->DefaultChar, sizeof(cpinfo->DefaultChar) ); + memcpy( cpinfo->LeadByte, table->LeadByte, sizeof(cpinfo->LeadByte) ); return TRUE; } @@ -4871,38 +4860,16 @@ BOOL WINAPI GetCPInfoExW( UINT codepage, DWORD flags, CPINFOEXW *cpinfo ) const CPTABLEINFO *table; int min, max, pos; - if (!cpinfo) + if (!cpinfo || !(table = get_codepage_table( codepage ))) { SetLastError( ERROR_INVALID_PARAMETER ); return FALSE; } - switch (codepage) - { - case CP_UTF7: - cpinfo->DefaultChar[0] = 0x3f; - cpinfo->DefaultChar[1] = 0; - cpinfo->LeadByte[0] = cpinfo->LeadByte[1] = 0; - cpinfo->MaxCharSize = 5; - cpinfo->CodePage = CP_UTF7; - cpinfo->UnicodeDefaultChar = 0x3f; - break; - case CP_UTF8: - cpinfo->DefaultChar[0] = 0x3f; - cpinfo->DefaultChar[1] = 0; - cpinfo->LeadByte[0] = cpinfo->LeadByte[1] = 0; - cpinfo->MaxCharSize = 4; - cpinfo->CodePage = CP_UTF8; - cpinfo->UnicodeDefaultChar = 0x3f; - break; - default: - if (!(table = get_codepage_table( codepage ))) return FALSE; - cpinfo->MaxCharSize = table->MaximumCharacterSize; - memcpy( cpinfo->DefaultChar, &table->DefaultChar, sizeof(cpinfo->DefaultChar) ); - memcpy( cpinfo->LeadByte, table->LeadByte, sizeof(cpinfo->LeadByte) ); - cpinfo->CodePage = table->CodePage; - cpinfo->UnicodeDefaultChar = table->UniDefaultChar; - break; - } + cpinfo->MaxCharSize = table->MaximumCharacterSize; + memcpy( cpinfo->DefaultChar, &table->DefaultChar, sizeof(cpinfo->DefaultChar) ); + memcpy( cpinfo->LeadByte, table->LeadByte, sizeof(cpinfo->LeadByte) ); + cpinfo->CodePage = table->CodePage; + cpinfo->UnicodeDefaultChar = table->UniDefaultChar; min = 0; max = ARRAY_SIZE(codepage_names) - 1; @@ -5775,9 +5742,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH IsValidCodePage( UINT codepage ) case CP_MACCP: case CP_THREAD_ACP: return FALSE; - case CP_UTF7: - case CP_UTF8: - return TRUE; default: return get_codepage_table( codepage ) != NULL; }
1
0
0
0
Alexandre Julliard : kernelbase: Avoid redundant locale lookups in GetLocaleInfoA().
by Alexandre Julliard
11 Apr '22
11 Apr '22
Module: wine Branch: master Commit: fd2ecee06fe9ab3af09854bb72fe9be3ec40a673 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=fd2ecee06fe9ab3af09854bb…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Apr 11 17:19:52 2022 +0200 kernelbase: Avoid redundant locale lookups in GetLocaleInfoA(). Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernelbase/locale.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/dlls/kernelbase/locale.c b/dlls/kernelbase/locale.c index 1e477a449e1..67052af7e4f 100644 --- a/dlls/kernelbase/locale.c +++ b/dlls/kernelbase/locale.c @@ -5098,6 +5098,7 @@ INT WINAPI DECLSPEC_HOTPATCH GetGeoInfoW( GEOID id, GEOTYPE type, WCHAR *data, i */ INT WINAPI DECLSPEC_HOTPATCH GetLocaleInfoA( LCID lcid, LCTYPE lctype, char *buffer, INT len ) { + const NLS_LOCALE_DATA *locale; WCHAR *bufferW; INT lenW, ret; @@ -5113,19 +5114,26 @@ INT WINAPI DECLSPEC_HOTPATCH GetLocaleInfoA( LCID lcid, LCTYPE lctype, char *buf SetLastError( ERROR_INVALID_FLAGS ); return 0; } - + if (!(locale = NlsValidateLocale( &lcid, 0 ))) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return 0; + } if (LOWORD(lctype) == LOCALE_FONTSIGNATURE || (lctype & LOCALE_RETURN_NUMBER)) - return GetLocaleInfoW( lcid, lctype, (WCHAR *)buffer, len / sizeof(WCHAR) ) * sizeof(WCHAR); + { + ret = get_locale_info( locale, lcid, lctype, (WCHAR *)buffer, len / sizeof(WCHAR) ); + return ret * sizeof(WCHAR); + } - if (!(lenW = GetLocaleInfoW( lcid, lctype, NULL, 0 ))) return 0; + if (!(lenW = get_locale_info( locale, lcid, lctype, NULL, 0 ))) return 0; if (!(bufferW = RtlAllocateHeap( GetProcessHeap(), 0, lenW * sizeof(WCHAR) ))) { SetLastError( ERROR_NOT_ENOUGH_MEMORY ); return 0; } - ret = GetLocaleInfoW( lcid, lctype, bufferW, lenW ); - if (ret) ret = WideCharToMultiByte( get_lcid_codepage( lcid, lctype ), 0, + ret = get_locale_info( locale, lcid, lctype, bufferW, lenW ); + if (ret) ret = WideCharToMultiByte( get_locale_codepage( locale, lctype ), 0, bufferW, ret, buffer, len, NULL, NULL ); RtlFreeHeap( GetProcessHeap(), 0, bufferW ); return ret;
1
0
0
0
Alexandre Julliard : kernelbase: Use RtlMultiByteToUnicodeN in IsChar* functions.
by Alexandre Julliard
11 Apr '22
11 Apr '22
Module: wine Branch: master Commit: 23834ee3b8d0a3d73eed593404748abd7d29d0d9 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=23834ee3b8d0a3d73eed5934…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Apr 11 17:01:36 2022 +0200 kernelbase: Use RtlMultiByteToUnicodeN in IsChar* functions. In case the Ansi codepage was set to UTF-8. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernelbase/locale.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/dlls/kernelbase/locale.c b/dlls/kernelbase/locale.c index 54d4a838731..1e477a449e1 100644 --- a/dlls/kernelbase/locale.c +++ b/dlls/kernelbase/locale.c @@ -5580,8 +5580,10 @@ INT WINAPI DECLSPEC_HOTPATCH IdnToUnicode( DWORD flags, const WCHAR *src, INT sr */ BOOL WINAPI DECLSPEC_HOTPATCH IsCharAlphaA( CHAR c ) { - WCHAR wc = nls_info.AnsiTableInfo.MultiByteTable[(unsigned char)c]; - return !!(get_char_type( CT_CTYPE1, wc ) & C1_ALPHA); + WCHAR wc; + DWORD reslen; + RtlMultiByteToUnicodeN( &wc, sizeof(WCHAR), &reslen, &c, 1 ); + return reslen && (get_char_type( CT_CTYPE1, wc ) & C1_ALPHA); } @@ -5599,8 +5601,10 @@ BOOL WINAPI DECLSPEC_HOTPATCH IsCharAlphaW( WCHAR wc ) */ BOOL WINAPI DECLSPEC_HOTPATCH IsCharAlphaNumericA( CHAR c ) { - WCHAR wc = nls_info.AnsiTableInfo.MultiByteTable[(unsigned char)c]; - return !!(get_char_type( CT_CTYPE1, wc ) & (C1_ALPHA | C1_DIGIT)); + WCHAR wc; + DWORD reslen; + RtlMultiByteToUnicodeN( &wc, sizeof(WCHAR), &reslen, &c, 1 ); + return reslen && (get_char_type( CT_CTYPE1, wc ) & (C1_ALPHA | C1_DIGIT)); } @@ -5645,8 +5649,10 @@ BOOL WINAPI DECLSPEC_HOTPATCH IsCharDigitW( WCHAR wc ) */ BOOL WINAPI DECLSPEC_HOTPATCH IsCharLowerA( CHAR c ) { - WCHAR wc = nls_info.AnsiTableInfo.MultiByteTable[(unsigned char)c]; - return !!(get_char_type( CT_CTYPE1, wc ) & C1_LOWER); + WCHAR wc; + DWORD reslen; + RtlMultiByteToUnicodeN( &wc, sizeof(WCHAR), &reslen, &c, 1 ); + return reslen && (get_char_type( CT_CTYPE1, wc ) & C1_LOWER); } @@ -5673,8 +5679,10 @@ BOOL WINAPI DECLSPEC_HOTPATCH IsCharPunctW( WCHAR wc ) */ BOOL WINAPI DECLSPEC_HOTPATCH IsCharSpaceA( CHAR c ) { - WCHAR wc = nls_info.AnsiTableInfo.MultiByteTable[(unsigned char)c]; - return !!(get_char_type( CT_CTYPE1, wc ) & C1_SPACE); + WCHAR wc; + DWORD reslen; + RtlMultiByteToUnicodeN( &wc, sizeof(WCHAR), &reslen, &c, 1 ); + return reslen && (get_char_type( CT_CTYPE1, wc ) & C1_SPACE); } @@ -5692,8 +5700,10 @@ BOOL WINAPI DECLSPEC_HOTPATCH IsCharSpaceW( WCHAR wc ) */ BOOL WINAPI DECLSPEC_HOTPATCH IsCharUpperA( CHAR c ) { - WCHAR wc = nls_info.AnsiTableInfo.MultiByteTable[(unsigned char)c]; - return !!(get_char_type( CT_CTYPE1, wc ) & C1_UPPER); + WCHAR wc; + DWORD reslen; + RtlMultiByteToUnicodeN( &wc, sizeof(WCHAR), &reslen, &c, 1 ); + return reslen && (get_char_type( CT_CTYPE1, wc ) & C1_UPPER); }
1
0
0
0
Alexandre Julliard : ntdll: Support UTF-8 codepage in string conversion functions.
by Alexandre Julliard
11 Apr '22
11 Apr '22
Module: wine Branch: master Commit: 2aa4673f32d08238b61e5b445d8bf873dccf2556 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=2aa4673f32d08238b61e5b44…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Apr 11 11:36:24 2022 +0200 ntdll: Support UTF-8 codepage in string conversion functions. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/locale.c | 189 ++++++++++++++++++++++++++++++++++++++++------------ dlls/ntdll/string.c | 8 +-- 2 files changed, 148 insertions(+), 49 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=2aa4673f32d08238b61e…
1
0
0
0
Alexandre Julliard : ntdll: Use the standard CPTABLEINFO structure for the Unix codepage.
by Alexandre Julliard
11 Apr '22
11 Apr '22
Module: wine Branch: master Commit: deab47be6eabc93b89b76e332db8dab1502daebd URL:
https://source.winehq.org/git/wine.git/?a=commit;h=deab47be6eabc93b89b76e33…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Apr 11 11:15:03 2022 +0200 ntdll: Use the standard CPTABLEINFO structure for the Unix codepage. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/unix/env.c | 163 ++++++++++---------------------------------------- 1 file changed, 30 insertions(+), 133 deletions(-) diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index 9b499239803..47bc0118802 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -83,13 +83,7 @@ static char user_locale[LOCALE_NAME_MAX_LENGTH]; const WCHAR system_dir[] = {'\\','?','?','\\','C',':','\\','w','i','n','d','o','w','s','\\', 's','y','s','t','e','m','3','2','\\',0}; -static struct -{ - USHORT *data; - USHORT *dbcs; - USHORT *mbtable; - void *wctable; -} unix_cp; +static CPTABLEINFO unix_cp = { CP_UTF8, 4, '?', 0xfffd, '?', '?' }; static char *get_nls_file_path( ULONG type, ULONG id ) { @@ -276,17 +270,6 @@ static const struct { const char *name; UINT cp; } charset_names[] = { "UTF8", CP_UTF8 } }; -static void init_unix_cptable( USHORT *ptr ) -{ - unix_cp.data = ptr; - ptr += ptr[0]; - unix_cp.wctable = ptr + ptr[0] + 1; - unix_cp.mbtable = ++ptr; - ptr += 256; - if (*ptr++) ptr += 256; /* glyph table */ - if (*ptr) unix_cp.dbcs = ptr + 1; /* dbcs ranges */ -} - static void init_unix_codepage(void) { char charset_name[16]; @@ -315,7 +298,7 @@ static void init_unix_codepage(void) if (charset_names[pos].cp != CP_UTF8) { void *data = read_nls_file( NLS_SECTION_CODEPAGE, charset_names[pos].cp ); - if (data) init_unix_cptable( data ); + if (data) init_codepage_table( data, &unix_cp ); } return; } @@ -378,42 +361,14 @@ static BOOL is_dynamic_env_var( const char *var ) */ DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen ) { - DWORD reslen; + unsigned int reslen; - if (unix_cp.data) - { - DWORD i; + if (unix_cp.CodePage != CP_UTF8) return cp_mbstowcs( &unix_cp, dst, dstlen, src, srclen ); - if (unix_cp.dbcs) - { - for (i = dstlen; srclen && i; i--, srclen--, src++, dst++) - { - USHORT off = unix_cp.dbcs[(unsigned char)*src]; - if (off && srclen > 1) - { - src++; - srclen--; - *dst = unix_cp.dbcs[off + (unsigned char)*src]; - } - else *dst = unix_cp.mbtable[(unsigned char)*src]; - } - reslen = dstlen - i; - } - else - { - reslen = min( srclen, dstlen ); - for (i = 0; i < reslen; i++) dst[i] = unix_cp.mbtable[(unsigned char)src[i]]; - } - } - else /* utf-8 */ - { - reslen = 0; - RtlUTF8ToUnicodeN( dst, dstlen * sizeof(WCHAR), &reslen, src, srclen ); - reslen /= sizeof(WCHAR); + utf8_mbstowcs( dst, dstlen, &reslen, src, srclen ); #ifdef __APPLE__ /* work around broken Mac OS X filesystem that enforces NFD */ - if (reslen && nfc_table) reslen = compose_string( nfc_table, dst, reslen ); + if (reslen && nfc_table) reslen = compose_string( nfc_table, dst, reslen ); #endif - } return reslen; } @@ -423,98 +378,40 @@ DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen ) */ int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BOOL strict ) { - DWORD i, reslen; + unsigned int i, reslen; - if (unix_cp.data) + if (unix_cp.CodePage != CP_UTF8) { - if (unix_cp.dbcs) + if (strict) { - const unsigned short *uni2cp = unix_cp.wctable; - for (i = dstlen; srclen && i; i--, srclen--, src++) + if (unix_cp.DBCSCodePage) { - unsigned short ch = uni2cp[*src]; - if (ch >> 8) - { - if (strict && unix_cp.dbcs[unix_cp.dbcs[ch >> 8] + (ch & 0xff)] != *src) return -1; - if (i == 1) break; /* do not output a partial char */ - i--; - *dst++ = ch >> 8; - } - else + const WCHAR *uni2cp = unix_cp.WideCharTable; + for (i = 0; i < srclen; i++) { - if (unix_cp.mbtable[ch] != *src) return -1; - *dst++ = (char)ch; + WCHAR ch = uni2cp[src[i]]; + if (ch >> 8) + { + if (unix_cp.DBCSOffsets[unix_cp.DBCSOffsets[ch >> 8] + (ch & 0xff)] != src[i]) + return -1; + } + else if (unix_cp.MultiByteTable[(unsigned char)ch] != src[i]) return -1; } } - reslen = dstlen - i; - } - else - { - const unsigned char *uni2cp = unix_cp.wctable; - reslen = min( srclen, dstlen ); - for (i = 0; i < reslen; i++) + else { - unsigned char ch = uni2cp[src[i]]; - if (strict && unix_cp.mbtable[ch] != src[i]) return -1; - dst[i] = ch; + const char *uni2cp = unix_cp.WideCharTable; + for (i = 0; i < srclen; i++) + if (unix_cp.MultiByteTable[(unsigned char)uni2cp[src[i]]] != src[i]) + return -1; } } + reslen = cp_wcstombs( &unix_cp, dst, dstlen, src, srclen ); } - else /* utf-8 */ + else { - char *end; - unsigned int val; - - for (end = dst + dstlen; srclen; srclen--, src++) - { - WCHAR ch = *src; - - if (ch < 0x80) /* 0x00-0x7f: 1 byte */ - { - if (dst > end - 1) break; - *dst++ = ch; - continue; - } - if (ch < 0x800) /* 0x80-0x7ff: 2 bytes */ - { - if (dst > end - 2) break; - dst[1] = 0x80 | (ch & 0x3f); - ch >>= 6; - dst[0] = 0xc0 | ch; - dst += 2; - continue; - } - if (!get_utf16( src, srclen, &val )) - { - if (strict) return -1; - val = 0xfffd; - } - if (val < 0x10000) /* 0x800-0xffff: 3 bytes */ - { - if (dst > end - 3) break; - dst[2] = 0x80 | (val & 0x3f); - val >>= 6; - dst[1] = 0x80 | (val & 0x3f); - val >>= 6; - dst[0] = 0xe0 | val; - dst += 3; - } - else /* 0x10000-0x10ffff: 4 bytes */ - { - if (dst > end - 4) break; - dst[3] = 0x80 | (val & 0x3f); - val >>= 6; - dst[2] = 0x80 | (val & 0x3f); - val >>= 6; - dst[1] = 0x80 | (val & 0x3f); - val >>= 6; - dst[0] = 0xf0 | val; - dst += 4; - src++; - srclen--; - } - } - reslen = dstlen - (end - dst); + NTSTATUS status = utf8_wcstombs( dst, dstlen, &reslen, src, srclen ); + if (strict && status == STATUS_SOME_NOT_MAPPED) return -1; } return reslen; } @@ -1140,9 +1037,9 @@ static void add_dynamic_environment( WCHAR **env, SIZE_T *pos, SIZE_T *size ) add_system_dll_path_var( env, pos, size ); append_envA( env, pos, size, "WINEUSERNAME", user_name ); append_envA( env, pos, size, "WINEDLLOVERRIDES", overrides ); - if (unix_cp.data) + if (unix_cp.CodePage != CP_UTF8) { - sprintf( str, "%u", unix_cp.data[1] ); + sprintf( str, "%u", unix_cp.CodePage ); append_envA( env, pos, size, "WINEUNIXCP", str ); } else append_envW( env, pos, size, "WINEUNIXCP", NULL );
1
0
0
0
Alexandre Julliard : ntdll: Move more codepage conversion functions to the common header.
by Alexandre Julliard
11 Apr '22
11 Apr '22
Module: wine Branch: master Commit: 61edb816499f023709cf3faf90e45bdf63ff1778 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=61edb816499f023709cf3faf…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Apr 11 10:57:41 2022 +0200 ntdll: Move more codepage conversion functions to the common header. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/locale.c | 264 ++++-------------------------------------- dlls/ntdll/locale_private.h | 275 ++++++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/unix/env.c | 55 +-------- 3 files changed, 302 insertions(+), 292 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=61edb816499f023709cf…
1
0
0
0
Alexandre Julliard : ntdll: Move some duplicated locale definitions to a common header.
by Alexandre Julliard
11 Apr '22
11 Apr '22
Module: wine Branch: master Commit: d966c45e068aa5d0bd0b361220639533a541b865 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d966c45e068aa5d0bd0b3612…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Apr 11 10:35:44 2022 +0200 ntdll: Move some duplicated locale definitions to a common header. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/locale.c | 437 +----------------------------------------- dlls/ntdll/locale_private.h | 453 ++++++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/unix/env.c | 229 +--------------------- 3 files changed, 455 insertions(+), 664 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=d966c45e068aa5d0bd0b…
1
0
0
0
Esme Povirk : windowscodecs: pceltFetched is optional in IWICEnumMetadataItem.
by Alexandre Julliard
11 Apr '22
11 Apr '22
Module: wine Branch: master Commit: 824d521dc73ff4caadd4e0ea6db8b64d8ce2e03c URL:
https://source.winehq.org/git/wine.git/?a=commit;h=824d521dc73ff4caadd4e0ea…
Author: Esme Povirk <esme(a)codeweavers.com> Date: Sat Apr 9 16:03:59 2022 -0500 windowscodecs: pceltFetched is optional in IWICEnumMetadataItem. Spotted by Eric Pouech. Signed-off-by: Esme Povirk <esme(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/windowscodecs/metadatahandler.c | 4 ++++ dlls/windowscodecs/tests/metadata.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/dlls/windowscodecs/metadatahandler.c b/dlls/windowscodecs/metadatahandler.c index b0b682b6d9b..5bcca0f58c6 100644 --- a/dlls/windowscodecs/metadatahandler.c +++ b/dlls/windowscodecs/metadatahandler.c @@ -491,9 +491,13 @@ static HRESULT WINAPI MetadataHandlerEnum_Next(IWICEnumMetadataItem *iface, ULONG new_index; HRESULT hr=S_FALSE; ULONG i; + ULONG fetched; TRACE("(%p,%li)\n", iface, celt); + if (!pceltFetched) + pceltFetched = &fetched; + EnterCriticalSection(&This->parent->lock); if (This->index >= This->parent->item_count) diff --git a/dlls/windowscodecs/tests/metadata.c b/dlls/windowscodecs/tests/metadata.c index 2ec9eb645e8..57d8e2b1bea 100644 --- a/dlls/windowscodecs/tests/metadata.c +++ b/dlls/windowscodecs/tests/metadata.c @@ -303,6 +303,21 @@ static void test_metadata_unknown(void) ok(hr == S_FALSE, "Next failed, hr=%lx\n", hr); ok(items_returned == 0, "unexpected item count %li\n", items_returned); + hr = IWICEnumMetadataItem_Reset(enumerator); + ok(hr == S_OK, "Reset failed, hr=%lx\n", hr); + + hr = IWICEnumMetadataItem_Next(enumerator, 1, &schema, &id, NULL, NULL); + ok(hr == S_OK, "Next failed, hr=%lx\n", hr); + + if (hr == S_OK) + { + ok(schema.vt == VT_EMPTY, "unexpected vt: %i\n", schema.vt); + ok(id.vt == VT_EMPTY, "unexpected vt: %i\n", id.vt); + + PropVariantClear(&schema); + PropVariantClear(&id); + } + IWICEnumMetadataItem_Release(enumerator); }
1
0
0
0
Esme Povirk : gdiplus: Accept newer version in OpenType header.
by Alexandre Julliard
11 Apr '22
11 Apr '22
Module: wine Branch: master Commit: 7d118a25c047580968a80d66c3061a47211b2380 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=7d118a25c047580968a80d66…
Author: Esme Povirk <esme(a)codeweavers.com> Date: Sat Apr 9 14:18:38 2022 -0500 gdiplus: Accept newer version in OpenType header. Signed-off-by: Esme Povirk <esme(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/gdiplus/font.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c index 6529f94bc1f..57849733a9c 100644 --- a/dlls/gdiplus/font.c +++ b/dlls/gdiplus/font.c @@ -106,7 +106,7 @@ typedef struct #define GET_BE_DWORD(x) (x) #else #define GET_BE_WORD(x) MAKEWORD(HIBYTE(x), LOBYTE(x)) -#define GET_BE_DWORD(x) MAKELONG(GET_BE_WORD(HIWORD(x)), GET_BE_WORD(LOWORD(x))); +#define GET_BE_DWORD(x) MAKELONG(GET_BE_WORD(HIWORD(x)), GET_BE_WORD(LOWORD(x))) #endif #define MS_MAKE_TAG(ch0, ch1, ch2, ch3) \ @@ -1150,14 +1150,16 @@ GpStatus WINGDIPAPI GdipPrivateAddFontFile(GpFontCollection *collection, GDIPCON #define NAME_ID_FULL_FONT_NAME 4 typedef struct { - USHORT major_version; - USHORT minor_version; + ULONG version; USHORT tables_no; USHORT search_range; USHORT entry_selector; USHORT range_shift; } tt_header; +#define TT_HEADER_VERSION_1 0x00010000 +#define TT_HEADER_VERSION_CFF 0x4f54544f + typedef struct { char tag[4]; /* table name */ ULONG check_sum; /* Check sum */ @@ -1402,7 +1404,8 @@ static WCHAR *load_ttf_name_id( const BYTE *mem, DWORD_PTR size, DWORD id ) header = (const tt_header*)mem; count = GET_BE_WORD(header->tables_no); - if (GET_BE_WORD(header->major_version) != 1 || GET_BE_WORD(header->minor_version) != 0) + if (GET_BE_DWORD(header->version) != TT_HEADER_VERSION_1 && + GET_BE_DWORD(header->version) != TT_HEADER_VERSION_CFF) return NULL; pos = sizeof(*header);
1
0
0
0
← Newer
1
...
72
73
74
75
76
77
78
...
103
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
Results per page:
10
25
50
100
200