Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit f73787a

Browse files
committed
Simplify core.stdc.string : strerror_r definition
1 parent 948ffa1 commit f73787a

File tree

1 file changed

+23
-49
lines changed

1 file changed

+23
-49
lines changed

src/core/stdc/string.d

Lines changed: 23 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ else version (TVOS)
2323
else version (WatchOS)
2424
version = Darwin;
2525

26+
// Those libs don't expose the mandated C interface
27+
version (CRuntime_Glibc)
28+
version = ReturnStrerrorR;
29+
else version (CRuntime_UClibc)
30+
version = ReturnStrerrorR;
31+
2632
extern (C):
2733
@system:
2834
nothrow:
@@ -44,26 +50,30 @@ void* memmove(return void* s1, scope const void* s2, size_t n) pure;
4450
///
4551
void* memset(return void* s, int c, size_t n) pure;
4652

47-
///
48-
char* strcpy(return char* s1, scope const char* s2) pure;
49-
///
50-
char* strncpy(return char* s1, scope const char* s2, size_t n) pure;
5153
///
5254
char* strcat(return char* s1, scope const char* s2) pure;
5355
///
54-
char* strncat(return char* s1, scope const char* s2, size_t n) pure;
56+
inout(char)* strchr(return inout(char)* s, int c) pure;
5557
///
5658
int strcmp(scope const char* s1, scope const char* s2) pure;
5759
///
5860
int strcoll(scope const char* s1, scope const char* s2);
5961
///
60-
int strncmp(scope const char* s1, scope const char* s2, size_t n) pure;
62+
char* strcpy(return char* s1, scope const char* s2) pure;
6163
///
62-
size_t strxfrm(scope char* s1, scope const char* s2, size_t n);
64+
size_t strcspn(scope const char* s1, scope const char* s2) pure;
6365
///
64-
inout(char)* strchr(return inout(char)* s, int c) pure;
66+
char* strdup(scope const char *s);
6567
///
66-
size_t strcspn(scope const char* s1, scope const char* s2) pure;
68+
char* strerror(int errnum);
69+
///
70+
char* strncpy(return char* s1, scope const char* s2, size_t n) pure;
71+
///
72+
char* strncat(return char* s1, scope const char* s2, size_t n) pure;
73+
///
74+
int strncmp(scope const char* s1, scope const char* s2, size_t n) pure;
75+
///
76+
size_t strxfrm(scope char* s1, scope const char* s2, size_t n);
6777
///
6878
inout(char)* strpbrk(return inout(char)* s1, scope const char* s2) pure;
6979
///
@@ -74,53 +84,17 @@ size_t strspn(scope const char* s1, scope const char* s2) pure;
7484
inout(char)* strstr(return inout(char)* s1, scope const char* s2) pure;
7585
///
7686
char* strtok(return char* s1, scope const char* s2);
77-
///
78-
char* strerror(int errnum);
79-
version (CRuntime_Glibc)
87+
// This `strerror_r` definition is not following the POSIX standard
88+
version (ReturnStrerrorR)
8089
{
8190
///
8291
const(char)* strerror_r(int errnum, return char* buf, size_t buflen);
8392
}
84-
else version (Darwin)
85-
{
86-
int strerror_r(int errnum, scope char* buf, size_t buflen);
87-
}
88-
else version (FreeBSD)
89-
{
90-
int strerror_r(int errnum, scope char* buf, size_t buflen);
91-
}
92-
else version (NetBSD)
93-
{
94-
int strerror_r(int errnum, char* buf, size_t buflen);
95-
}
96-
else version (OpenBSD)
97-
{
98-
int strerror_r(int errnum, scope char* buf, size_t buflen);
99-
}
100-
else version (DragonFlyBSD)
101-
{
102-
int strerror_r(int errnum, scope char* buf, size_t buflen);
103-
}
104-
else version (Solaris)
105-
{
106-
int strerror_r(int errnum, scope char* buf, size_t buflen);
107-
}
108-
else version (CRuntime_Bionic)
93+
// This one is
94+
else
10995
{
11096
///
11197
int strerror_r(int errnum, scope char* buf, size_t buflen);
11298
}
113-
else version (CRuntime_Musl)
114-
{
115-
///
116-
int strerror_r(int errnum, scope char *buf, size_t buflen);
117-
}
118-
else version (CRuntime_UClibc)
119-
{
120-
///
121-
const(char)* strerror_r(int errnum, return char* buf, size_t buflen);
122-
}
12399
///
124100
size_t strlen(scope const char* s) pure;
125-
///
126-
char* strdup(scope const char *s);

0 commit comments

Comments
 (0)