string.3: SYNOPSIS: Use 'restrict' in prototypes

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>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Alejandro Colomar 2021-03-10 19:31:41 +01:00 committed by Michael Kerrisk
parent f8e178d48b
commit 9180299e51
1 changed files with 11 additions and 8 deletions

View File

@ -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.