Re: VS 2015 support in src/tools/msvc - Mailing list pgsql-hackers

From Christian Ullrich
Subject Re: VS 2015 support in src/tools/msvc
Date
Msg-id 570A9FCE.5040201@chrullrich.net
Whole thread Raw
In response to Re: VS 2015 support in src/tools/msvc  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: VS 2015 support in src/tools/msvc  (Petr Jelinek <petr@2ndquadrant.com>)
List pgsql-hackers
* Andrew Dunstan:

> On 04/09/2016 08:43 AM, Christian Ullrich wrote:

>>> Michael Paquier wrote:

>>> I don't think that's good to use malloc in those code paths, and I

Oh?

+#if (_MSC_VER >= 1900)
+    uint32    cp;
+
+    if (GetLocaleInfoEx(ctype,
+            LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
+            (LPWSTR) &cp, sizeof(cp) / sizeof(WCHAR)) > 0)
+    {
+        r = malloc(16);            /* excess */
+        if (r != NULL)
+            sprintf(r, "CP%u", cp);
+    }
+    else
+    {
+#endif

> I don't think we need to be too precious about saving a byte or two
> here. Can one or other of you please prepare a replacement patch based
> in this discussion?

Sorry, I don't think I'm up to that (at least not for another week or 
so). I have to read up on the issue first; right now I'm not sure what 
exactly the problem is.

What I can say is that the existing patch needs more work, because 
GetLocaleInfoEx() expects a locale name ("de-DE") as its first argument, 
but the patched win32_langinfo() is giving it a locale identifier 
("German_Germany.1252"). At least it does for me.

I have not gone through the code sufficiently closely to find out where 
the argument to win32_langinfo() originates, but I will when I can.

As for missing code page information in the _locale_t type, ISTM it 
isn't hidden any better in UCRT than it was before:

int main()
{    /* Set locale with nonstandard code page */    _locale_t loc = _create_locale(LC_ALL, "German_Germany.850");
    __crt_locale_data_public* pub = 
(__crt_locale_data_public*)(loc->locinfo);    printf("CP: %d\n", pub->_locale_lc_codepage);    // "CP: 850"    return
0;
}

-- 
Christian




pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: multivariate statistics v14
Next
From: Amit Kapila
Date:
Subject: Re: Move PinBuffer and UnpinBuffer to atomics