diff options
| author | Alejandro Colomar <alx.manpages@gmail.com> | 2021-03-10 19:31:41 +0100 |
|---|---|---|
| committer | Michael Kerrisk <mtk.manpages@gmail.com> | 2021-03-14 21:40:45 +0100 |
| commit | 9180299e5106018a0d279f30308c3496a432d2bc (patch) | |
| tree | eb59a01cc3f082dc8cd0009f58e02afbeb8bb4ea /man3/string.3 | |
| parent | f8e178d48bc7d9fd1e8d9ca445940e6f6d79a4bd (diff) | |
| download | man-pages-9180299e5106018a0d279f30308c3496a432d2bc.tar.gz | |
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>
Diffstat (limited to 'man3/string.3')
| -rw-r--r-- | man3/string.3 | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/man3/string.3 b/man3/string.3 index ab4cc3ce7e..06da21c28d 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. |
