2017-11-14 23:21 GMT-07:00 Nikolay Sivov nsivov@codeweavers.com:
On 11/15/2017 09:05 AM, Alex Henrie wrote:
2017-11-14 0:40 GMT-07:00 Nikolay Sivov bunglehead@gmail.com:
Is it possible we're picking wrong resource with FindResource() here? Maybe we should be using explicit language instead of a neutral one, so
propsheet.c:69: Test failed: Unexpected template buffer size 508, resource size 270
could mean we were supposed to pick up a different resource of size 254.
I tried FindResourceExA on Hebrew Windows 10 with all of the following, and got a resource of size 250 every time:
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT) MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT) MAKELANGID(LANG_NEUTRAL, SUBLANG_CUSTOM_DEFAULT) MAKELANGID(LANG_NEUTRAL, SUBLANG_CUSTOM_UNSPECIFIED) MAKELANGID(LANG_NEUTRAL, SUBLANG_UI_CUSTOM_DEFAULT) MAKELANGID(LANG_HEBREW, SUBLANG_HEBREW_ISRAEL)
Interestingly, 508 is exactly 2 times the US English resource size. Maybe the RTL locales base their buffer size on the US English resource? I checked and other languages such as German have different resource and buffer sizes from English.
I also checked Kurdish, Persian, Punjabi, Urdu, and Uyghur Windows 10, and resource sizes were the same for both the localized resource and the US English resource. So, I couldn't tell whether they compute buffer size based on the English resource or based on their own resource.
That's confusing, how can they all be the same if we have a failing test? What's picked up as neutral resource, that's a question I guess. Also it sounds strange that localized strings don't affect template size, but maybe strings are stored separately. If regardless of locale it's always using US English size, that's what we should use too, still it's interesting where size 270 comes from.
I used Hebrew Windows for testing because it's simpler than Arabic: Windows only recognizes one Hebrew dialect.
English: Resource size 254, buffer size 508 Arabic: Resource size 270, buffer size 508 Hebrew: Resource size 250, buffer size 508 German: Resource size 266, buffer size 532
P.S. GetLocaleInfo() takes LCID not LANGID, and you can use special constants like LOCALE_USER_DEFAULT too.
OK, LOCALE_USER_DEFAULT should be fine. Out of curiosity, what is the correct way to specify a LCID? Do I have to say something like MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), 0)?
More importantly, how do you think these tests should be written? Should I use the US English resource size to determine the correct buffer size on RTL locales, or should I just continue accepting sizes within 32 bytes of expected? Also, should the different code path be for all RTL locales, or just for Arabic and Hebrew specifically?
Ideally we should test against actual exact size, using single path, and not testing locale properties.
Considering the numbers I gave above, how can we have only a single path?
-Alex