Re: Clear up strxfrm() in UTF-8 with locale on Windows

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Clear up strxfrm() in UTF-8 with locale on Windows
Date: 2007-05-02 21:25:39
Message-ID: 21456.1178141139@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> Given this, perhaps the proper approach should instead be to just check
> the return value, and go from there? Should be a simple enough patch,
> something like the attached.

> Tom, can you comment?

Testing against INT_MAX seems like a type pun, or something. Maybe use
MaxAllocSize instead?

if (xfrmlen >= MaxAllocSize)
return val;

Also, since as you note returning (size_t) -1 is not at all standard,
it would be helpful to readers to note that that's what Windows does
on failure and that's what you're testing for. In fact you could
make a good case that the test should be just

if (xfrmlen == (size_t) -1)
return val;

regards, tom lane

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Gavin Sherry 2007-05-03 03:51:29 Updated bitmap index patch
Previous Message Magnus Hagander 2007-05-02 20:42:27 Re: Clear up strxfrm() in UTF-8 with locale on Windows