* strnlen.3: never beyond s+maxlen
@ 2020-11-19 19:42 Heinrich Schuchardt
2020-11-28 9:02 ` Michael Kerrisk (man-pages)
0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2020-11-19 19:42 UTC (permalink / raw)
To: linux-man, Michael Kerrisk (man-pages)
Hello Michael,
the strnlen.3 manpage has the following sentence:
"In doing this, strnlen() looks only at the first maxlen characters in
the string pointed to by s and never beyond s+maxlen."
This sentence is self-contradictory:
The last visited character implied by "first maxlen characters" is
s[maxlen-1].
Given that "beyond a" does not include "a", the last visited character
implied by "never beyond s+maxlen" is s[maxlen].
A consistent sentence would be
"In doing this, strnlen() looks only at the first maxlen characters in
the string pointed to by s and never beyond s+maxlen-1."
I would prefer
"In doing this, strnlen() looks only at the first maxlen characters in
the string pointed to by s and never beyond s[maxlen-1]"
Best regards
Heinrich
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: strnlen.3: never beyond s+maxlen
2020-11-19 19:42 strnlen.3: never beyond s+maxlen Heinrich Schuchardt
@ 2020-11-28 9:02 ` Michael Kerrisk (man-pages)
0 siblings, 0 replies; 2+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-11-28 9:02 UTC (permalink / raw)
To: Heinrich Schuchardt, linux-man; +Cc: mtk.manpages
On 11/19/20 8:42 PM, Heinrich Schuchardt wrote:
> Hello Michael,
>
> the strnlen.3 manpage has the following sentence:
>
> "In doing this, strnlen() looks only at the first maxlen characters in
> the string pointed to by s and never beyond s+maxlen."
>
> This sentence is self-contradictory:
>
> The last visited character implied by "first maxlen characters" is
> s[maxlen-1].
>
> Given that "beyond a" does not include "a", the last visited character
> implied by "never beyond s+maxlen" is s[maxlen].
>
> A consistent sentence would be
>
> "In doing this, strnlen() looks only at the first maxlen characters in
> the string pointed to by s and never beyond s+maxlen-1."
>
> I would prefer
>
> "In doing this, strnlen() looks only at the first maxlen characters in
> the string pointed to by s and never beyond s[maxlen-1]"
Thanks, Heinrich. I changed as you suggested.
Cheers,
Michael
diff --git a/man3/strnlen.3 b/man3/strnlen.3
index 6c4b080fc..d4385af49 100644
--- a/man3/strnlen.3
+++ b/man3/strnlen.3
@@ -54,7 +54,7 @@ looks only at the first
characters in the string pointed to by
.I s
and never beyond
-.IR s+maxlen .
+.IR s[maxlen\-1] .
.SH RETURN VALUE
The
.BR strnlen ()
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-28 22:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19 19:42 strnlen.3: never beyond s+maxlen Heinrich Schuchardt
2020-11-28 9:02 ` Michael Kerrisk (man-pages)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).