Skip to content

Commit 2db6906

Browse files
nrosnros
nros
authored and
nros
committed
memccpy, strdup and strndup are in C23
7.26.2.2 memccpy 7.26.2.6 strdup 7.26.2.7 strndup
1 parent f4f72a5 commit 2db6906

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

include/string.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: string.h,v 1.57 2024/11/02 02:43:48 riastradh Exp $ */
1+
/* $NetBSD: string.h,v 1.58 2024/12/09 12:09:02 nros Exp $ */
22

33
/*-
44
* Copyright (c) 1990, 1993
@@ -53,9 +53,10 @@ typedef struct _locale *locale_t;
5353
#endif /* _POSIX_C_SOURCE || _NETBSD_SOURCE */
5454

5555
__BEGIN_DECLS
56-
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
56+
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) || \
57+
(__STDC_VERSION__ - 0 >= 202311L) || defined(_ISOC23_SOURCE)
5758
void *memccpy(void *, const void *, int, size_t);
58-
#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
59+
#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE || _ISOC23_SOURCE */
5960
void *memchr(const void *, int, size_t);
6061
int memcmp(const void *, const void *, size_t);
6162
void *memcpy(void * __restrict, const void * __restrict, size_t);
@@ -82,9 +83,12 @@ int strcoll_l(const char *, const char *, locale_t);
8283
char *strcpy(char * __restrict, const char * __restrict);
8384
size_t strcspn(const char *, const char *);
8485
#if (_POSIX_C_SOURCE - 0 >= 200809L) || defined(_XOPEN_SOURCE) || \
85-
defined(_NETBSD_SOURCE)
86+
defined(_NETBSD_SOURCE) || (__STDC_VERSION__ - 0 >= 202311L) || \
87+
defined(_ISOC23_SOURCE)
8688
char *strdup(const char *);
87-
#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */
89+
#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE ||
90+
* _ISOC23_SOURCE
91+
*/
8892
__aconst char *strerror(int);
8993
#if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE)
9094
__aconst char *strerror_l(int, locale_t);
@@ -101,8 +105,11 @@ size_t strlen(const char *);
101105
char *strncat(char * __restrict, const char * __restrict, size_t);
102106
int strncmp(const char *, const char *, size_t);
103107
char *strncpy(char * __restrict, const char * __restrict, size_t);
104-
#if (_POSIX_C_SOURCE - 0 >= 200809L) || defined(_NETBSD_SOURCE)
108+
#if (_POSIX_C_SOURCE - 0 >= 200809L) || defined(_NETBSD_SOURCE) || \
109+
(__STDC_VERSION__ - 0 >= 202311L) || defined(_ISOC23_SOURCE)
105110
char *strndup(const char *, size_t);
111+
#endif /* _POSIX_C_SOURCE || _NETBSD_SOURCE || _ISOC23_SOURCE */
112+
#if (_POSIX_C_SOURCE - 0 >= 200809L) || defined(_NETBSD_SOURCE)
106113
size_t strnlen(const char *, size_t);
107114
#endif /* _POSIX_C_SOURCE || _NETBSD_SOURCE */
108115
char *strpbrk(const char *, const char *);

lib/libc/string/strdup.3

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
.\" SUCH DAMAGE.
2727
.\"
2828
.\" from: @(#)strdup.3 8.1 (Berkeley) 6/9/93
29-
.\" $NetBSD: strdup.3,v 1.18 2009/01/29 10:15:39 wiz Exp $
29+
.\" $NetBSD: strdup.3,v 1.19 2024/12/09 12:09:02 nros Exp $
3030
.\"
31-
.Dd January 28, 2009
31+
.Dd December 9, 2024
3232
.Dt STRDUP 3
3333
.Os
3434
.Sh NAME
@@ -98,6 +98,12 @@ The
9898
.Fn strdup
9999
function conforms to
100100
.St -p1003.1-2001 .
101+
The
102+
.Fn strdup
103+
and
104+
.Fn strndup
105+
functions conform to
106+
.St -isoC-2023 .
101107
.Sh HISTORY
102108
The
103109
.Fn strdup

0 commit comments

Comments
 (0)