Re: VS 2015 support in src/tools/msvc

From: Christian Ullrich <chris(at)chrullrich(dot)net>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Petr Jelinek <petr(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: VS 2015 support in src/tools/msvc
Date: 2016-04-10 18:47:42
Message-ID: 570A9FCE.5040201@chrullrich.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2016-04-10 18:58:48 Re: Move PinBuffer and UnpinBuffer to atomics
Previous Message Tomas Vondra 2016-04-10 18:29:16 Re: multivariate statistics v14