Thread: Does mbutils.c really need to use L'\0' ?

Does mbutils.c really need to use L'\0' ?

From
Tom Lane
Date:
I grow weary of mopping up after pgindent, as in
http://archives.postgresql.org/pgsql-committers/2010-07/msg00069.php

The problem evidently is that pgindent hasn't heard of wide character
constants.  No doubt the best fix would be to teach it about them;
but given that we seem to have next to no use for such constants,
I'm dubious that it's worth the trouble.  I suggest that it might be
best to replace these usages of L'\0' by plain scalar 0.  Does anyone
think that wouldn't work or is too grotty?
        regards, tom lane


Re: Does mbutils.c really need to use L'\0' ?

From
Andrew Dunstan
Date:

Tom Lane wrote:
> I grow weary of mopping up after pgindent, as in
> http://archives.postgresql.org/pgsql-committers/2010-07/msg00069.php
>
> The problem evidently is that pgindent hasn't heard of wide character
> constants.  No doubt the best fix would be to teach it about them;
> but given that we seem to have next to no use for such constants,
> I'm dubious that it's worth the trouble.  I suggest that it might be
> best to replace these usages of L'\0' by plain scalar 0.  Does anyone
> think that wouldn't work or is too grotty?
>
>             
>   

or maybe 0x0000, which I gather from 
<http://en.wikipedia.org/wiki/Wide_character> is the usual locution.

cheers

andrew.


Re: Does mbutils.c really need to use L'\0' ?

From
Tom Lane
Date:
Andrew Dunstan <andrew@dunslane.net> writes:
> Tom Lane wrote:
>> I'm dubious that it's worth the trouble.  I suggest that it might be
>> best to replace these usages of L'\0' by plain scalar 0.  Does anyone
>> think that wouldn't work or is too grotty?

> or maybe 0x0000, which I gather from 
> <http://en.wikipedia.org/wiki/Wide_character> is the usual locution.

Hm.  I don't really read that page as suggesting that 0x0000 is what to
use if your compiler hasn't got wide chars.  I'd tend to go with just 0,
which is a reasonably common substitute for non-wide '\0' ...
        regards, tom lane


Re: Does mbutils.c really need to use L'\0' ?

From
Takahiro Itagaki
Date:
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> >> I'm dubious that it's worth the trouble.  I suggest that it might be
> >> best to replace these usages of L'\0' by plain scalar 0.
> I'd tend to go with just 0,
> which is a reasonably common substitute for non-wide '\0' ...

I think all of the following codes work in the same way
at least on Windows, where the codes are actually used.
   utf16[dstlen] = L'\0';   utf16[dstlen] = '\0';   utf16[dstlen] = 0;   utf16[dstlen] = (WCHAR) 0;

Regards,
---
Takahiro Itagaki
NTT Open Source Software Center




Re: Does mbutils.c really need to use L'\0' ?

From
Tom Lane
Date:
Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp> writes:
> I think all of the following codes work in the same way
> at least on Windows, where the codes are actually used.

>     utf16[dstlen] = L'\0';
>     utf16[dstlen] = '\0';
>     utf16[dstlen] = 0;
>     utf16[dstlen] = (WCHAR) 0;

The last one seems like the best choice, since it makes the intent visible.
Committed that way --- thanks for the suggestion!
        regards, tom lane