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.
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" ?
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.
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".
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
"NUL" is not mentioned in the C spec.
Jonny