Re: EXEC(3)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Jonny,

On 11/9/18 4:33 PM, Jonny Grant wrote:
> 
> 
> On 09/11/2018 14:06, Jakub Wilk wrote:
>> * Jonny Grant <jg@xxxxxxxx>, 2018-11-09, 11:52:
>>> Should these say "NUL-terminated" and "NULL" below?
>> [...]
>>> So the updated line would be:
>>>
>>> argument is an array of pointers to NUL-terminated strings and must be 
>>> terminated by a NULL pointer.
>>
>> No, this would be against conventions documented in man-pages(7):
>>
>> The preferred term for the pointer is "null pointer" or simply "NULL"; 
>> avoid writing "NULL pointer".
>>
>> The preferred term for the byte is "null byte". Avoid writing "NUL", 
>> since it is too easily confused with "NULL". Avoid also the terms "zero 
>> byte" and "null character". The byte that terminates a C string should 
>> be described as "the terminating null byte"; strings may be described as 
>> "null‐terminated", but avoid the use of "NUL‐terminated".
>>
> 
> Thank you for the information Jakub. It looks like the terminology is 
> documented, so at least man-pages are consistent.

Thanks Jakub, for jumping in.
 
> althouh other pages use longer text, eg
> 
> http://man7.org/linux/man-pages/man3/strcat.3.html
> 
> "terminating null byte ('\0')"
> 
> Worth making them all "null byte" ?

I don't think so. "Terminating" is being used explicitly do
indicate that this is the null byte at the end of a string.

> This is the same:
> http://man7.org/linux/man-pages/man3/strncpy.3.html
> 
> It is a shame as ASCII has always called it NUL.
> https://en.wikipedia.org/wiki/ASCII
> 
> The same in IEC 646
> https://en.wikipedia.org/wiki/ISO/IEC_646
> 
> I've not felt confusion about a NULL pointer and a NUL byte myself, but 
> the names are similar, and usage has overlapped, and not consistently 
> stuck to using NUL.

You may not be confused, but it is a point of confusion for some
people. Best to remove the possibility of confusion, in my opinion,
and that is what I did back in 2006 with this commit:

commit 28d88c175143bdbc136bab4e30dd9f8d7299584b
Author: Michael Kerrisk <mtk.manpages@xxxxxxxxx>
Date:   Fri Jan 13 02:09:44 2006 +0000

    Global change to many pages...
    Various pages use inconsistent terms for 'null byte' (which
    is the C99/SUSv3 term for the '\0' character).
    To rectify this the following changes were made in these pages:
    
    Replace 'zero byte' with 'null byte'.
    Replace 'null character' with 'null byte'.
    Replace 'nulls' with 'null bytes'.
    Replace 'NUL-terminated' by 'null-terminated'.
    Replace 'NUL' by 'null byte'.
    Replace 'terminating NUL' by 'terminating null byte'.
    Replace 'final NUL' by 'terminating null byte'.
    Replace 'NUL character' by 'null byte'.

As you can see, there was a mass of varying terminology.
I tried to reduce that range of terminology, and move more
closely to the terms used in the standards.

> Re not writing "NULL pointer", it seems odd as the byte preferred term 
> is "null byte". You'll no doubt be aware that C++ has nullptr keyword, 
> so it's conventionally known as a pointer. The C spec calls it the "null 
> pointer".

Yes, but to me "NULL" is "the null pointer", and thus "NULL pointer"
reads to me as "the null pointer pointer" :-).

> page 47
> "55) The macro NULL is defined in <stddef.h> (and other headers) as a 
> null pointer constant; see 7.17"
> 
> C actually calls it "null character" in the spec
> http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1124.pdf

It also seems to use "null byte" a lot as well.

> "NUL" is not mentioned in the C spec.

Yup!

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux