Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1apMWB-0006Fr-MF for pgsql-hackers@arkaria.postgresql.org; Sun, 10 Apr 2016 21:03:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1apMWA-0002nQ-TY for pgsql-hackers@arkaria.postgresql.org; Sun, 10 Apr 2016 21:03:38 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1apMW8-0002ly-PI for pgsql-hackers@postgresql.org; Sun, 10 Apr 2016 21:03:37 +0000 Received: from mail-ig0-x22a.google.com ([2607:f8b0:4001:c05::22a]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1apMW5-0007sl-8K for pgsql-hackers@postgresql.org; Sun, 10 Apr 2016 21:03:35 +0000 Received: by mail-ig0-x22a.google.com with SMTP id gy3so68587224igb.1 for ; Sun, 10 Apr 2016 14:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=rxOtd0oJebbDrn1tH1b0nltt9gb41SgfBO1OQxt0aV0=; b=UnYRCxCttAmtT6uvyAd+W4iHa/o94iC6txtGxI+gf+mUFxS7IwfkhpUOD39xMmM+l8 bo4msKThetYQYt40AvxElSfM0YR6WEO7aNNCBaOwxDw5Fb0NVtj0ff7YuLGvFNcjgDE7 +WaQMQGC3M1gpKORovt9AihQbD7sPO6ZGmTIN7iwBHJLmmKFHn7mvl6K3WOQ2L9amLvs 1+2aEvl69KCSb0MGQ+0AMoPCgSuOORgSK0nwxaMmUqR5O0sddJSQoSCNdb1/F8onxyLk I3TO+d72i74YB2LE2IL50Oi9pntyzWgZ9inygN8vC86E8I6Y9q+iOwb3Ynj9ZWT6ritv r1Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=rxOtd0oJebbDrn1tH1b0nltt9gb41SgfBO1OQxt0aV0=; b=JCQ0WC+92XqkWoMcP9TdY1cWVyiHyClYwSI/wjKRslzrCx0J0KzfjMScj21dGZARm0 EIdg02UqoHc1vgnwjiCvaETiEz5RqHr64CxM8K3nldH7Q23Tt2SotGFdVBle5Qv0ypr/ z7nTCpvWAg0uv0c90UpxG+nmd4n2e4QgLnha5tcvqE/kqx/9Nl2XNS6r6D4uTbfREYuC 8k1nFtyvLZ5gC0PwDXpTU0nDsUelrylE5E6U8AelISIWoDBh1jVwEGtJqEVBNFmn8J5d JnPlRVzrm/qr41xvsB1vBLsFxiBSv9iL9oFONJUY0IpUrqshLc9NkuykABpI6oW9IjYp 9Kjw== X-Gm-Message-State: AD7BkJIrwTD8Lq/ehbziqmAZ76fuV1AqMR0mQOsDlvBq5FV3dgwU4BDw29F966jXd7gofplSM0w1IdJ/j0/FjPbedok5qq4gjL1HJpWGwO0oiUkRdch70FrorizCba7aZg7P1zT3A4i1QJgoFrjAiIrS8RAOUvAaid3ggN8egHMo4jKe7qbWjOARX9+nqgsnkg== X-Received: by 10.50.92.37 with SMTP id cj5mr15260062igb.91.1460322211927; Sun, 10 Apr 2016 14:03:31 -0700 (PDT) Received: from [10.0.1.219] ([173.243.46.202]) by smtp.gmail.com with ESMTPSA id b202sm14851464ioe.27.2016.04.10.14.03.29 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 10 Apr 2016 14:03:30 -0700 (PDT) Subject: Re: VS 2015 support in src/tools/msvc To: Christian Ullrich , Andrew Dunstan , Michael Paquier References: <56FA9FDF.20108@2ndquadrant.com> <56FB2BF8.3060303@dunslane.net> <5705768E.4020908@dunslane.net> <5706FB7E.5070703@dunslane.net> <570792ED.2080003@chrullrich.net> <5707AC9E.7070309@dunslane.net> <5707C80F.9050709@chrullrich.net> <5707D7DC.2030508@dunslane.net> <5707E074.4030102@chrullrich.net> <0B77CFCB-0F90-4CAB-8509-7EB391C06D59@chrullrich.net> <570A6A14.6040303@dunslane.net> <570A9FCE.5040201@chrullrich.net> Cc: Robert Haas , Tom Lane , Magnus Hagander , PostgreSQL mailing lists From: Petr Jelinek Message-ID: <570ABFA0.4090403@2ndquadrant.com> Date: Sun, 10 Apr 2016 23:03:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <570A9FCE.5040201@chrullrich.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org 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