Re: Clear up strxfrm() in UTF-8 with locale on Windows - Mailing list pgsql-patches

From Tom Lane
Subject Re: Clear up strxfrm() in UTF-8 with locale on Windows
Date
Msg-id 21456.1178141139@sss.pgh.pa.us
Whole thread Raw
In response to Re: Clear up strxfrm() in UTF-8 with locale on Windows  (Magnus Hagander <magnus@hagander.net>)
Responses Re: Clear up strxfrm() in UTF-8 with locale on Windows
List pgsql-patches
Magnus Hagander <magnus@hagander.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

pgsql-patches by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Clear up strxfrm() in UTF-8 with locale on Windows
Next
From: Gavin Sherry
Date:
Subject: Updated bitmap index patch