Lists: | pgsql-patches |
---|
From: | Neil Conway <neilc(at)samurai(dot)com> |
---|---|
To: | PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | correct NUL vs. NULL usage |
Date: | 2003-09-24 06:21:08 |
Message-ID: | 1064384467.5822.63.camel@tokyo |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
In C, "NULL" denotes a special pointer value indicating the pointer
points to no value. "NUL" is the ASCII character that terminates a C
string. These two terms are not synonymous, so this patch corrects the
usage of NULL in comments in the postgres source.
I may have missed an instance or two, but this gets most of the
mistakes, I believe.
-Neil
Attachment | Content-Type | Size |
---|---|---|
nul_cleanup-4.patch | text/x-patch | 68.6 KB |
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Neil Conway <neilc(at)samurai(dot)com> |
Cc: | PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: correct NUL vs. NULL usage |
Date: | 2003-09-24 13:54:43 |
Message-ID: | 3440.1064411683@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
Neil Conway <neilc(at)samurai(dot)com> writes:
> In C, "NULL" denotes a special pointer value indicating the pointer
> points to no value. "NUL" is the ASCII character that terminates a C
> string. These two terms are not synonymous, so this patch corrects the
> usage of NULL in comments in the postgres source.
However, lower case "null" is commonly used for both meanings.
I cite the C99 standard:
... A byte with all bits set to 0,
called the null character, shall exist in the basic
execution character set; it is used to terminate a character
string.
The standard thereafter consistently uses "the null character" to
refer to '\0'. Kernighan & Ritchie first edition tends to use boldface
"\0" in running text, but the initial use of that symbol is *defined as*
"the <i>null character</>, whose value is zero" (their italics).
In my experience "NUL" is actually less common than other names for
the null character.
In short, I think most of this patch is just pedantry. Could you
trim it down to just the places where there's actually risk of
confusion? (I do agree that upper case NULL is not appropriate as
a name for the character.)
regards, tom lane
From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Neil Conway <neilc(at)samurai(dot)com>, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: correct NUL vs. NULL usage |
Date: | 2003-09-28 00:36:58 |
Message-ID: | 200309280036.h8S0awO27806@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
Tom, I understand your research on the historical usage of null, but in
PostgreSQL we have not two but three possible uses for n-u-l-l:
o null pointer
o null byte
o null SQL value
With that list, anything that makes null clearer is great. I think we
should just standardize on 'NUL' for a null byte, or 'nul'. I think the
code would benefit from that clarification. I usually do:
#define NUL '\0'
in my C code.
---------------------------------------------------------------------------
Tom Lane wrote:
> Neil Conway <neilc(at)samurai(dot)com> writes:
> > In C, "NULL" denotes a special pointer value indicating the pointer
> > points to no value. "NUL" is the ASCII character that terminates a C
> > string. These two terms are not synonymous, so this patch corrects the
> > usage of NULL in comments in the postgres source.
>
> However, lower case "null" is commonly used for both meanings.
> I cite the C99 standard:
>
> ... A byte with all bits set to 0,
> called the null character, shall exist in the basic
> execution character set; it is used to terminate a character
> string.
>
> The standard thereafter consistently uses "the null character" to
> refer to '\0'. Kernighan & Ritchie first edition tends to use boldface
> "\0" in running text, but the initial use of that symbol is *defined as*
> "the <i>null character</>, whose value is zero" (their italics).
>
> In my experience "NUL" is actually less common than other names for
> the null character.
>
> In short, I think most of this patch is just pedantry. Could you
> trim it down to just the places where there's actually risk of
> confusion? (I do agree that upper case NULL is not appropriate as
> a name for the character.)
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Neil Conway <neilc(at)samurai(dot)com>, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: correct NUL vs. NULL usage |
Date: | 2003-09-28 09:41:33 |
Message-ID: | Pine.LNX.4.44.0309281139560.11938-100000@peter.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
Bruce Momjian writes:
> Tom, I understand your research on the historical usage of null, but in
> PostgreSQL we have not two but three possible uses for n-u-l-l:
>
> o null pointer
> o null byte
> o null SQL value
>
> With that list, anything that makes null clearer is great. I think we
> should just standardize on 'NUL' for a null byte, or 'nul'.
I don't think someone coming in from the street and seeing a message or
code is going to understand that. If you really want to be clear, call it
"zero byte".
--
Peter Eisentraut peter_e(at)gmx(dot)net