-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring.d
123 lines (118 loc) · 2.96 KB
/
string.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_string.h.html, _string.h)
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Sean Kelly
* Source: $(DRUNTIMESRC core/stdc/_string.d)
* Standards: ISO/IEC 9899:1999 (E)
*/
version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;
// Those libs don't expose the mandated C interface
version (CRuntime_Glibc)
version = ReturnStrerrorR;
else version (CRuntime_UClibc)
version = ReturnStrerrorR;
extern (C):
@system:
nothrow:
@nogc:
///
void* memchr(return const void* s, int c, size_t n) pure
{
//stub
return cast(void*)null;
}
///
int memcmp(scope const void* s1, scope const void* s2, size_t n) pure;
///
void* memcpy(return void* s1, scope const void* s2, size_t n) pure;
version (Windows)
{
///
int memicmp(scope const char* s1, scope const char* s2, size_t n);
}
///
void* memmove(return void* s1, scope const void* s2, size_t n) pure;
/**
* https://github.com/DevSolar/pdclib/blob/cadb3570d551369f98610ae5a31946edeec63973/functions/string/memset.c
*/
void* memset(return void* s, int c, size_t n) pure
{
ubyte* p = cast(ubyte*) s;
while ( n-- )
{
*p++ = cast(ubyte) c;
}
return s;
}
///
char* strcat(return char* s1, scope const char* s2) pure;
///
inout(char)* strchr(return inout(char)* s, int c) pure;
///
int strcmp(scope const char* s1, scope const char* s2) pure
{
//stub
return 0;
}
///
int strcoll(scope const char* s1, scope const char* s2);
///
char* strcpy(return char* s1, scope const char* s2) pure;
///
size_t strcspn(scope const char* s1, scope const char* s2) pure;
///
char* strdup(scope const char *s);
///
char* strerror(int errnum);
// This `strerror_r` definition is not following the POSIX standard
version (ReturnStrerrorR)
{
///
const(char)* strerror_r(int errnum, return char* buf, size_t buflen);
}
// This one is
else
{
int strerror_r(int errnum, scope char* buf, size_t buflen);
}
///
size_t strlen(scope const char* s) pure
{
//stub
return 0;
}
///
char* strncat(return char* s1, scope const char* s2, size_t n) pure;
///
int strncmp(scope const char* s1, scope const char* s2, size_t n) pure;
///
char* strncpy(return char* s1, scope const char* s2, size_t n) pure;
///
inout(char)* strpbrk(return inout(char)* s1, scope const char* s2) pure;
///
inout(char)* strrchr(return inout(char)* s, int c) pure;
///
size_t strspn(scope const char* s1, scope const char* s2) pure
{
//stub
return 0;
}
///
inout(char)* strstr(return inout(char)* s1, scope const char* s2) pure;
///
char* strtok(return char* s1, scope const char* s2);
///
size_t strxfrm(scope char* s1, scope const char* s2, size_t n);