This is a discussion on Re: Clear up strxfrm() in UTF-8 with locale on Windows within the Pgsql Patches forums, part of the PostgreSQL category; --> Magnus Hagander <magnus@hagander.net> writes: > Given this, perhaps the proper approach should instead be to just check > the ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq |
| |||
| On Wed, May 02, 2007 at 05:25:39PM -0400, Tom Lane wrote: > 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? The windows API documentation specifically says: On an error, each function sets errno and returns INT_MAX. So actually an equality test against INT_MAX would be correct. But making that clear in the comment would probably not be a bad idea :-) //Magnus ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend |
| |||
| Magnus Hagander wrote: > On Wed, May 02, 2007 at 05:25:39PM -0400, Tom Lane wrote: >> 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? > > The windows API documentation specifically says: > On an error, each function sets errno and returns INT_MAX. > > So actually an equality test against INT_MAX would be correct. But making > that clear in the comment would probably not be a bad idea :-) I have applied a fix for this, because it obviously needed fixing regardless of if it fixes the original issue all the way. Still looking for confirmation if it does, though. //Magnus ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |
| |||
| Magnus Hagander <magnus@hagander.net> wrote: > > So actually an equality test against INT_MAX would be correct. But making > > that clear in the comment would probably not be a bad idea :-) > > I have applied a fix for this, because it obviously needed fixing > regardless of if it fixes the original issue all the way. Still looking > for confirmation if it does, though. The fix works well. I tested it with UTF-8 encoding and Japanese_Japan.932 (SJIS) locale and I didn't see any errors. I think it it is enough to cover the buggy UTF-8 treatment on Windows. Regards, --- ITAGAKI Takahiro NTT Open Source Software Center ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings |
| ||||
| > > > So actually an equality test against INT_MAX would be correct. But making > > > that clear in the comment would probably not be a bad idea :-) > > > > I have applied a fix for this, because it obviously needed fixing > > regardless of if it fixes the original issue all the way. Still looking > > for confirmation if it does, though. > > The fix works well. I tested it with UTF-8 encoding and Japanese_Japan.932 > (SJIS) locale and I didn't see any errors. I think it it is enough to cover > the buggy UTF-8 treatment on Windows. > Thanks for testing. Bruce, that means the original patch is not needed, so you can take it off the patch queue. Thanks. /Magnus ---------------------------(end of broadcast)--------------------------- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate |