Em sex., 17 de abr. de 2020 às 15:44, Juan José Santamaría Flecha <
juanjo.santama...@gmail.com> escreveu:

>
> On Fri, Apr 17, 2020 at 10:33 AM Amit Kapila <amit.kapil...@gmail.com>
> wrote:
>
>>
>> I see some differences in the output when _create_locale() is used vs.
>> when GetLocaleInfoEx() is used.  Forex.
>>
>
> Thanks for the thorough review.
>
>
>> The function IsoLocaleName() header comment says "Convert a Windows
>> setlocale() argument to a Unix-style one", so I was expecting above
>> cases which gives valid values with _create_locale() should also work
>> with GetLocaleInfoEx().  If it is fine for GetLocaleInfoEx() to return
>> an error for the above cases, then we need an explanation of the same
>> and probably add a few comments as well.  So, I am not sure if we can
>> conclude that GetLocaleInfoEx() is an alternative to _create_locale()
>> at this stage.
>>
>
> We can get a match for those locales in non-ISO format by enumerating
> available locales with EnumSystemLocalesEx(), and trying to find a match.
>
> Please find a new patch for so.
>
I have some observations about this patch, related to style, if you will
allow me.
1. argv variable on function enum_locales_fn can be reduced.
2. Var declaration len escapes the Postgres style.
3. Why call wcslen(test_locale), again, when var len have the size?

+static BOOL CALLBACK
+enum_locales_fn(LPWSTR pStr, DWORD dwFlags, LPARAM lparam)
+{
+ WCHAR test_locale[LOCALE_NAME_MAX_LENGTH];
+
+ memset(test_locale, 0, sizeof(test_locale));
+ if (GetLocaleInfoEx(pStr, LOCALE_SENGLISHLANGUAGENAME,
+ test_locale, LOCALE_NAME_MAX_LENGTH) > 0)
+ {
+ size_t len;
+
+ wcscat(test_locale, L"_");
+ len = wcslen(test_locale);
+ if (GetLocaleInfoEx(pStr, LOCALE_SENGLISHCOUNTRYNAME,
+ test_locale + len, LOCALE_NAME_MAX_LENGTH - len) > 0)
+ {
+ WCHAR **argv = (WCHAR **) lparam;
+
+ if (wcsncmp(argv[0], test_locale, len) == 0)
+ {
+ wcscpy(argv[1], pStr);
+ return FALSE;
+ }
+ }
+ }
+ return TRUE;
+}

regards,
Ranier Vilela

Reply via email to