Date: Tue, 12 Jan 2016 22:34:12 +0000 From: bugzilla-noreply@freebsd.org To: freebsd-doc@FreeBSD.org Subject: [Bug 206176] Non-null-terminated arrays in descriptions of strn* and wcsn* functions Message-ID: <bug-206176-9@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D206176 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@FreeBSD.org Reporter: cherepan@mccme.ru The strn* and wcsn* functions take an argument limiting the size of process= ed parts of arrays. The C standard cautiously and consistently talks about arr= ays 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 poi= nted 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=3D25= 1069&view=3Dmarkup#l51 [2] https://svnweb.freebsd.org/base/head/lib/libc/string/strcat.3?revision=3D26= 2890&view=3Dmarkup#l51 [3] https://svnweb.freebsd.org/base/head/lib/libc/string/strcasecmp.3?revision= =3D266865&view=3Dmarkup#l55 [4] https://svnweb.freebsd.org/base/head/lib/libc/string/strdup.3?revision=3D25= 1069&view=3Dmarkup#l63 [5] https://svnweb.freebsd.org/base/head/lib/libc/string/strstr.3?revision=3D25= 1069&view=3Dmarkup#l77 --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-206176-9>