public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: mtk.manpages@gmail.com
Cc: Alejandro Colomar <alx.manpages@gmail.com>,
	linux-man@vger.kernel.org, libc-alpha@sourceware.org
Subject: [PATCH 15/24] string.3: SYNOPSIS: Use 'restrict' in prototypes
Date: Wed, 10 Mar 2021 19:31:41 +0100	[thread overview]
Message-ID: <20210310183149.194717-16-alx.manpages@gmail.com> (raw)
In-Reply-To: <20210310183149.194717-1-alx.manpages@gmail.com>

Both POSIX and glibc use 'restrict' in stpcpy(), strcat(), strcpy(), strncat(), strncpy(), strtok(), strxfrm().
Let's use it here too.

.../glibc$ grep_glibc_prototype stpcpy
string/string.h:475:
extern char *stpcpy (char *__restrict __dest, const char *__restrict __src)
     __THROW __nonnull ((1, 2));
.../glibc$ grep_glibc_prototype strcat
string/string.h:133:
extern char *strcat (char *__restrict __dest, const char *__restrict __src)
     __THROW __nonnull ((1, 2));
.../glibc$ grep_glibc_prototype strcpy
string/string.h:125:
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
     __THROW __nonnull ((1, 2));
.../glibc$ grep_glibc_prototype strncat
string/string.h:136:
extern char *strncat (char *__restrict __dest, const char *__restrict __src,
		      size_t __n) __THROW __nonnull ((1, 2));
.../glibc$ grep_glibc_prototype strncpy
string/string.h:128:
extern char *strncpy (char *__restrict __dest,
		      const char *__restrict __src, size_t __n)
     __THROW __nonnull ((1, 2));
.../glibc$ grep_glibc_prototype strtok
string/string.h:340:
extern char *strtok (char *__restrict __s, const char *__restrict __delim)
     __THROW __nonnull ((2));
.../glibc$ grep_glibc_prototype strxfrm
string/string.h:150:
extern size_t strxfrm (char *__restrict __dest,
		       const char *__restrict __src, size_t __n)
    __THROW __nonnull ((2)) __attr_access ((__write_only__, 1, 3));
.../glibc$

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
 man3/string.3 | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/man3/string.3 b/man3/string.3
index ab4cc3ce7..06da21c28 100644
--- a/man3/string.3
+++ b/man3/string.3
@@ -66,7 +66,7 @@ in the string
 .TP
 .B #include <string.h>
 .TP
-.BI "char *stpcpy(char *" dest ", const char *" src );
+.BI "char *stpcpy(char *restrict " dest ", const char *restrict " src );
 Copy a string from
 .I src
 to
@@ -74,7 +74,7 @@ to
 returning a pointer to the end of the resulting string at
 .IR dest .
 .TP
-.BI "char *strcat(char *" dest ", const char *" src );
+.BI "char *strcat(char *restrict " dest ", const char *restrict " src );
 Append the string
 .I src
 to the string
@@ -101,7 +101,7 @@ with
 .I s2
 using the current locale.
 .TP
-.BI "char *strcpy(char *" dest ", const char *" src );
+.BI "char *strcpy(char *restrict " dest ", const char *restrict " src );
 Copy the string
 .I src
 to
@@ -129,7 +129,8 @@ Randomly swap the characters in
 Return the length of the string
 .IR s .
 .TP
-.BI "char *strncat(char *" dest ", const char *" src ", size_t " n );
+.BI "char *strncat(char *restrict " dest ", const char *restrict " src \
+", size_t " n );
 Append at most
 .I n
 bytes from the string
@@ -147,7 +148,8 @@ bytes of the strings
 and
 .IR s2 .
 .TP
-.BI "char *strncpy(char *" dest ", const char *" src ", size_t " n );
+.BI "char *strncpy(char *restrict " dest ", const char *restrict " src \
+", size_t " n );
 Copy at most
 .I n
 bytes from string
@@ -188,19 +190,20 @@ in the string
 .IR haystack ,
 returning a pointer to the found substring.
 .TP
-.BI "char *strtok(char *" s ", const char *" delim );
+.BI "char *strtok(char *restrict " s ", const char *restrict " delim );
 Extract tokens from the string
 .I s
 that are delimited by one of the bytes in
 .IR delim .
 .TP
-.BI "size_t strxfrm(char *" dest ", const char *" src ", size_t " n );
+.BI "size_t strxfrm(char *restrict " dst ", const char *restrict " src \
+", size_t " n );
 Transforms
 .I src
 to the current locale and copies the first
 .I n
 bytes to
-.IR dest .
+.IR dst .
 .SH DESCRIPTION
 The string functions perform operations on null-terminated
 strings.
-- 
2.30.1.721.g45526154a5


  parent reply	other threads:[~2021-03-10 18:32 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 18:31 [PATCH 00/24] man3: SYNOPSIS: Use 'restrict' in prototypes (batch 5) Alejandro Colomar
2021-03-10 18:31 ` [PATCH 01/24] sem_getvalue.3: SYNOPSIS: Use 'restrict' in prototypes Alejandro Colomar
2021-03-10 18:31 ` [PATCH 02/24] sem_wait.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 03/24] setaliasent.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 04/24] setbuf.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 05/24] " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 06/24] setnetgrent.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 07/24] sigwait.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 08/24] statvfs.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 09/24] stpcpy.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 10/24] stpncpy.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 11/24] strcat.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 12/24] strcpy.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 13/24] strfmon.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 14/24] strftime.3: " Alejandro Colomar
2021-03-10 18:31 ` Alejandro Colomar [this message]
2021-03-10 18:31 ` [PATCH 16/24] string.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 17/24] strptime.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 18/24] strsep.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 19/24] strtod.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 20/24] strtoimax.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 21/24] strtok.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 22/24] strtol.3, strtoul.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 23/24] strxfrm.3: " Alejandro Colomar
2021-03-10 18:31 ` [PATCH 24/24] swab.3: " Alejandro Colomar
2021-03-14 20:51 ` [PATCH 00/24] man3: SYNOPSIS: Use 'restrict' in prototypes (batch 5) Michael Kerrisk (man-pages)
2021-03-14 20:53   ` Michael Kerrisk (man-pages)
2021-03-19 21:08     ` Alejandro Colomar (man-pages)
2021-03-19 20:59   ` Alejandro Colomar (man-pages)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210310183149.194717-16-alx.manpages@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).