[Bug 206176] Non-null-terminated arrays in descriptions of strn* and wcsn* functions
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Tue Jan 12 22:34:13 UTC 2016
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=206176
Bug ID: 206176
Summary: Non-null-terminated arrays in descriptions of strn*
and wcsn* functions
Product: Documentation
Version: Latest
Hardware: Any
OS: Any
Status: New
Severity: Affects Many People
Priority: ---
Component: Documentation
Assignee: freebsd-doc at FreeBSD.org
Reporter: cherepan at mccme.ru
The strn* and wcsn* functions take an argument limiting the size of processed
parts of arrays. The C standard cautiously and consistently talks about arrays
instead of strings in such cases and (hence) doesn't require arguments to be
null-terminated strings in all cases.
OTOH FreeBSD man pages don't make this distinction and don't usually make
remarks to that effect.
Take for example strcmp and strncmp. The description of strcmp in C11,
7.24.4.2p2:
"The strcmp function compares the string pointed to by s1 to the string pointed
to by s2."
It talks about "the string pointed to by s1" as expected.
Then, the description of strncmp -- C11, 7.24.4.4p2:
"The strncmp function compares not more than n characters (characters that
follow a null character are not compared) from the array pointed to by s1 to
the array pointed to by s2."
Here, it talks about "the array pointed to by s1" instead of strings.
In the next paragraph it talks about "the possibly null-terminated array
pointed to by s1" (please note "possibly").
The man page[1] for strncmp is silent on such details.
The same for strncat[2].
The question for non-C11 function like strncasecmp[3], strndup[4], strnstr[5]
is moot but IMHO it's better to be consistent with C11.
Implementations are mostly ok, only documentation is wrong.
[1]
https://svnweb.freebsd.org/base/head/lib/libc/string/strcmp.3?revision=251069&view=markup#l51
[2]
https://svnweb.freebsd.org/base/head/lib/libc/string/strcat.3?revision=262890&view=markup#l51
[3]
https://svnweb.freebsd.org/base/head/lib/libc/string/strcasecmp.3?revision=266865&view=markup#l55
[4]
https://svnweb.freebsd.org/base/head/lib/libc/string/strdup.3?revision=251069&view=markup#l63
[5]
https://svnweb.freebsd.org/base/head/lib/libc/string/strstr.3?revision=251069&view=markup#l77
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-doc
mailing list