diff options
author | Alejandro Colomar <alx@kernel.org> | 2023-12-05 00:42:07 +0100 |
---|---|---|
committer | Alejandro Colomar <alx@kernel.org> | 2023-12-05 00:42:29 +0100 |
commit | c41448a74ef5400602da8199a353b4edae7ace69 (patch) | |
tree | 9307abc08107f8f7829153789b605ae3b929cb50 | |
parent | 0f22dfb6b3e30744df7edd94dba18b9f923cf77c (diff) |
string_copying.7: Generalize null-padded character sequences with strnlen(3)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rw-r--r-- | man7/string_copying.7 | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/man7/string_copying.7 b/man7/string_copying.7 index 5b123b929..067a1156c 100644 --- a/man7/string_copying.7 +++ b/man7/string_copying.7 @@ -246,18 +246,13 @@ To copy bytes from strings into these buffers, use or .BR stpncpy (3). .P -To copy from an unterminated string within a fixed-size buffer into a string, -ignoring any trailing null bytes in the source fixed-size buffer, -you should use -.I \%stpcpy(mempcpy(dst,\ src,\ strnlen(src,\ NITEMS(src))),\ \[dq]\[dq]) -or -.BR strncat (3). -.P -To copy from an unterminated string within a fixed-size buffer -into a character sequence, -ignoring any trailing null bytes in the source fixed-size buffer, -you should use -.IR "\%mempcpy(dst,\ src,\ strnlen(src,\ NITEMS(src)))" . +To read a null-padded character sequence, +use +.IR "strnlen(src,\ NITEMS(src))" , +and then you can treat it as a known-length character sequence; +or use +.BR strncat (3) +directly. .\" ----- DESCRIPTION :: Known-length character sequences -----------------/ .SS Known-length character sequences The simplest character sequence copying function is |