pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Petr Jelinek <petr@2ndquadrant.com>
To: Christian Ullrich <chris@chrullrich.net>
To: Andrew Dunstan <andrew@dunslane.net>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Magnus Hagander <magnus@hagander.net>
Cc: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Subject: Re: VS 2015 support in src/tools/msvc
Date: Sun, 10 Apr 2016 23:03:28 +0200
Message-ID: <570ABFA0.4090403@2ndquadrant.com> (raw)
In-Reply-To: <570A9FCE.5040201@chrullrich.net>
References: <CAB7nPqTTcRGbDxS_RA4CWn1B_KRsvN+FTpct0mTp3v3gRWQ70g@mail.gmail.com>
	<56FA9FDF.20108@2ndquadrant.com>
	<CA+TgmoaRAhFtVuMfrAn9R4aeib0azhj3jb+RC9aQ2z-JTYJsag@mail.gmail.com>
	<CAB7nPqRHbMZ5eW+AcwxgkfoU1odh75osFLJKrKkQn2N1gbiceQ@mail.gmail.com>
	<56FB2BF8.3060303@dunslane.net>
	<CA+TgmoakpqU5uXDTkfaCHesFeW8N_aH5w-e991BfxkcREo7-mg@mail.gmail.com>
	<5705768E.4020908@dunslane.net>
	<5706FB7E.5070703@dunslane.net>
	<CAB7nPqR4QHFRZ1vjMo9Njy49hDAXOAjO+AEGhuCDzmhQJRagAw@mail.gmail.com>
	<570792ED.2080003@chrullrich.net>
	<5707AC9E.7070309@dunslane.net>
	<CAB7nPqROXyB_=-BbAXGnCdHFYUE4_+qgQAGk1swwnVQSfiab9Q@mail.gmail.com>
	<5707C80F.9050709@chrullrich.net>
	<5707D7DC.2030508@dunslane.net>
	<5707E074.4030102@chrullrich.net>
	<CAB7nPqSYAxCX+p0D0Qpqv6D4uLb2fmGcpUeKRxMyom5cAziuzg@mail.gmail.com>
	<CAB7nPqSOPynjV7ZC9wghkvwTpDPj7U=py7AoczzguTmv1kmh+g@mail.gmail.com>
	<0B77CFCB-0F90-4CAB-8509-7EB391C06D59@chrullrich.net>
	<570A6A14.6040303@dunslane.net>
	<570A9FCE.5040201@chrullrich.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

On 10/04/16 20:47, Christian Ullrich wrote:
> * 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
>

But r is return value so it has to be allocated. The intermediate 
variables are function local.

>> 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.

That really depends on what you set in config/commandline. The current 
code supports both (that's why there is the else fallback to old code 
which handles the "German_Germany.1252" format).

> 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;
> }
>

This is basically same as the approach of fixing _locale_t that was also 
considered upthread but nobody was too happy with it. I guess the worry 
is that given that the header file is obviously unfinished in the area 
where this is defined and also the fact that this looks like something 
that's not meant to be used outside of that header makes people worry 
that it might change between point releases of the SDK.

-- 
   Petr Jelinek                  http://www.2ndQuadrant.com/
   PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (134+ messages)  latest in thread

Message-ID: <570ABFA0.4090403@2ndquadrant.com>
Permalink:  ../570ABFA0.4090403@2ndquadrant.com/
Also on:    postgresql.org/message-id/570ABFA0.4090403@2ndquadrant.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: petr@2ndquadrant.com, chris@chrullrich.net, andrew@dunslane.net, michael.paquier@gmail.com, robertmhaas@gmail.com, tgl@sss.pgh.pa.us, magnus@hagander.net
  Subject: Re: VS 2015 support in src/tools/msvc
  In-Reply-To: <570ABFA0.4090403@2ndquadrant.com>
  References: <CAB7nPqTTcRGbDxS_RA4CWn1B_KRsvN+FTpct0mTp3v3gRWQ70g@mail.gmail.com> <CA+TgmoaRAhFtVuMfrAn9R4aeib0azhj3jb+RC9aQ2z-JTYJsag@mail.gmail.com> <CAB7nPqRHbMZ5eW+AcwxgkfoU1odh75osFLJKrKkQn2N1gbiceQ@mail.gmail.com> <56FB2BF8.3060303@dunslane.net> <CA+TgmoakpqU5uXDTkfaCHesFeW8N_aH5w-e991BfxkcREo7-mg@mail.gmail.com> <5705768E.4020908@dunslane.net> <5706FB7E.5070703@dunslane.net> <CAB7nPqR4QHFRZ1vjMo9Njy49hDAXOAjO+AEGhuCDzmhQJRagAw@mail.gmail.com> <570792ED.2080003@chrullrich.net> <5707AC9E.7070309@dunslane.net> <CAB7nPqROXyB_=-BbAXGnCdHFYUE4_+qgQAGk1swwnVQSfiab9Q@mail.gmail.com> <5707C80F.9050709@chrullrich.net> <5707D7DC.2030508@dunslane.net> <5707E074.4030102@chrullrich.net> <CAB7nPqSYAxCX+p0D0Qpqv6D4uLb2fmGcpUeKRxMyom5cAziuzg@mail.gmail.com> <CAB7nPqSOPynjV7ZC9wghkvwTpDPj7U=py7AoczzguTmv1kmh+g@mail.gmail.com> <0B77CFCB-0F90-4CAB-8509-7EB391C06D59@chrullrich.net> <570A6A14.6040303@dunslane.net> <570A9FCE.5040201@chrullrich.net> <570ABFA0.4090403@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox