]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
string_copying.7: Consistently list strtcpy() after stpecpy()
authorAlejandro Colomar <alx@kernel.org>
Mon, 4 Dec 2023 12:58:53 +0000 (13:58 +0100)
committerAlejandro Colomar <alx@kernel.org>
Mon, 4 Dec 2023 12:58:53 +0000 (13:58 +0100)
And put it next to strlcpy(3bsd), which is very similar to strtcpy().

Signed-off-by: Alejandro Colomar <alx@kernel.org>
man7/string_copying.7

index b8ea98eccd1afe23f882e03df5dc9159d0c17063..ad2d889af25d6fb47695b46788ab892902e8aaed 100644 (file)
@@ -7,8 +7,8 @@
 .SH NAME
 stpcpy,
 strcpy, strcat,
-strtcpy,
 stpecpy,
+strtcpy,
 strlcpy, strlcat,
 stpncpy,
 strncpy,
@@ -314,10 +314,10 @@ List of functions:
 .BR strcpy (3),
 .BR strcat (3)
 .IP \[bu]
-.BR strtcpy ()
-.IP \[bu]
 .BR stpecpy ()
 .IP \[bu]
+.BR strtcpy ()
+.IP \[bu]
 .BR strlcpy (3bsd),
 .BR strlcat (3bsd)
 .PD
@@ -370,18 +370,6 @@ The return value is useless.
 .IP
 .BR stpcpy (3)
 is a faster alternative to these functions.
-.\" ----- DESCRIPTION :: Functions :: strtcpy() -----------------------/
-.TP
-.BR strtcpy ()
-Copy the input string into a destination string.
-If the destination buffer isn't large enough to hold the copy,
-the resulting string is truncated
-(but it is guaranteed to be null-terminated).
-It returns the length of the string,
-or \-1 if it truncated.
-.IP
-This function is not provided by any library;
-see EXAMPLES for a reference implementation.
 .\" ----- DESCRIPTION :: Functions :: stpecpy() -----------------------/
 .TP
 .BR stpecpy ()
@@ -396,6 +384,18 @@ Truncation needs to be detected only once after the last chained call.
 .IP
 This function is not provided by any library;
 see EXAMPLES for a reference implementation.
+.\" ----- DESCRIPTION :: Functions :: strtcpy() -----------------------/
+.TP
+.BR strtcpy ()
+Copy the input string into a destination string.
+If the destination buffer isn't large enough to hold the copy,
+the resulting string is truncated
+(but it is guaranteed to be null-terminated).
+It returns the length of the string,
+or \-1 if it truncated.
+.IP
+This function is not provided by any library;
+see EXAMPLES for a reference implementation.
 .\" ----- DESCRIPTION :: Functions :: strlcpy(3bsd), strlcat(3bsd) ----/
 .TP
 .BR strlcpy (3bsd)
@@ -582,15 +582,6 @@ strcat(buf, "!");
 len = strlen(buf);
 puts(buf);
 .EE
-.\" ----- EXAMPLES :: strtcpy() ---------------------------------------/
-.TP
-.BR strtcpy ()
-.EX
-len = strtcpy(buf, "Hello world!", sizeof(buf));
-if (len == \-1)
-    goto toolong;
-puts(buf);
-.EE
 .\" ----- EXAMPLES :: stpecpy() ---------------------------------------/
 .TP
 .BR stpecpy ()
@@ -607,6 +598,15 @@ if (p == end) {
 len = p \- buf;
 puts(buf);
 .EE
+.\" ----- EXAMPLES :: strtcpy() ---------------------------------------/
+.TP
+.BR strtcpy ()
+.EX
+len = strtcpy(buf, "Hello world!", sizeof(buf));
+if (len == \-1)
+    goto toolong;
+puts(buf);
+.EE
 .\" ----- EXAMPLES :: strlcpy(3bsd), strlcat(3bsd) --------------------/
 .TP
 .BR strlcpy (3bsd)
@@ -706,25 +706,6 @@ Here are reference implementations for functions not provided by libc.
 .EX
 /* This code is in the public domain. */
 \&
-.\" ----- EXAMPLES :: Implementations :: strtcpy() --------------------/
-ssize_t
-.IR strtcpy "(char *restrict dst, const char *restrict src, size_t dsize)"
-{
-    bool    trunc;
-    size_t  dlen, slen;
-\&
-    if (dsize == 0)
-        return \-1;
-\&
-    slen = strnlen(src, dsize);
-    trunc = (slen == dsize);
-    dlen = slen \- trunc;
-\&
-    stpcpy(mempcpy(dst, src, dlen), "");
-
-    return trunc ? \-1 : slen;
-}
-\&
 .\" ----- EXAMPLES :: Implementations :: stpecpy() --------------------/
 char *
 .IR stpecpy "(char *dst, char end[0], const char *restrict src)"
@@ -744,6 +725,25 @@ char *
 \&
     return stpcpy(mempcpy(dst, src, dlen), "") + trunc;
 }
+\&
+.\" ----- EXAMPLES :: Implementations :: strtcpy() --------------------/
+ssize_t
+.IR strtcpy "(char *restrict dst, const char *restrict src, size_t dsize)"
+{
+    bool    trunc;
+    size_t  dlen, slen;
+\&
+    if (dsize == 0)
+        return \-1;
+\&
+    slen = strnlen(src, dsize);
+    trunc = (slen == dsize);
+    dlen = slen \- trunc;
+\&
+    stpcpy(mempcpy(dst, src, dlen), "");
+
+    return trunc ? \-1 : slen;
+}
 .\" ----- SEE ALSO :: -------------------------------------------------/
 .SH SEE ALSO
 .BR bzero (3),