-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathstring.h
More file actions
173 lines (139 loc) · 6.18 KB
/
string.h
File metadata and controls
173 lines (139 loc) · 6.18 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*********************************************************************/
/* */
/* This Program Written by Paul Edwards. */
/* Released to the Public Domain */
/* */
/*********************************************************************/
/*********************************************************************/
/* */
/* string.h - string header file. */
/* */
/*********************************************************************/
#ifndef __STRING_INCLUDED
#define __STRING_INCLUDED
#ifndef __SIZE_T_DEFINED
#define __SIZE_T_DEFINED
#if (defined(__OS2__) || defined(__32BIT__) || defined(__MVS__) \
|| defined(__CMS__))
typedef unsigned long size_t;
#elif (defined(__MSDOS__) || defined(__DOS__) || defined(__POWERC) \
|| defined(__WIN32__))
typedef unsigned int size_t;
#endif
#endif
#define NULL ((void *)0)
void *memchr(const void *s, int c, size_t n);
int memcmp(const void *s1, const void *s2, size_t n);
void *memcpy(void *s1, const void *s2, size_t n);
void *memmove(void *s1, const void *s2, size_t n);
void *memset(void *s, int c, size_t n);
char *strcat(char *s1, const char *s2);
char *strchr(const char *s, int c);
int strcmp(const char *s1, const char *s2);
int strcoll(const char *s1, const char *s2);
char *strcpy(char *s1, const char *s2);
size_t strcspn(const char *s1, const char *s2);
char *strerror(int errnum);
int stricmp(const char *s1, const char *s2); /* Robert O'Hara, 10/09 */
size_t strlen(const char *s);
char *strlwr(char *s1);
char *strncat(char *s1, const char *s2, size_t n);
int strncmp(const char *s1, const char *s2, size_t n);
char *strncpy(char *s1, const char *s2, size_t n);
char *strpbrk(const char *s1, const char *s2);
char *strrchr(const char *s, int c);
size_t strspn(const char *s1, const char *s2);
char *strstr(const char *s1, const char *s2);
char *strtok(char *s1, const char *s2);
char *strupr(char *s1);
size_t strxfrm(char *s1, const char *s2, size_t n);
#ifdef __WATCOMC__
#ifdef __INLINE_FUNCTIONS__
#pragma intrinsic(memchr, memcmp, memcpy, strcat, strcpy, strlen, strchr)
#endif
#endif
#ifdef __IBMC__
char * _Builtin __strcat(char *s1, const char *s2);
#define strcat(s1,s2) (__strcat((s1),(s2)))
char * _Builtin __strchr(const char *s, int c);
#define strchr(s,c) (__strchr((s),(c)))
int _Builtin __strcmp(const char *s1, const char *s2);
#define strcmp(s1,s2) (__strcmp((s1),(s2)))
int _Builtin __strcpy(char *s1, const char *s2);
#define strcpy(s1,s2) (__strcpy((s1),(s2)))
size_t _Builtin __strlen(const char *s);
#define strlen(s) (__strlen((s)))
char * _Builtin __strncat(char *s1, const char *s2, size_t n);
#define strncat(s1,s2,n) (__strncat((s1),(s2),(n)))
int _Builtin __strncmp(const char *s1, const char *s2, size_t n);
#define strncmp(s1,s2,n) (__strncmp((s1),(s2),(n)))
char * _Builtin __strncpy(char *s1, const char *s2, size_t n);
#define strncpy(s1,s2,n) (__strncpy((s1),(s2),(n)))
char * _Builtin __strrchr(const char *s, int c);
#define strrchr(s,c) (__strrchr((s),(c)))
void * _Builtin __memcpy(void *s1, const void *s2, size_t n);
#define memcpy(a,b,c) (__memcpy((a),(b),(c)))
void * _Builtin __memchr(const void *s, int c, size_t n);
#define memchr(s,c,n) (__memchr((s),(c),(n)))
int _Builtin __memcmp(const void *s1, const void *s2, size_t n);
#define memcmp(s1,s2,n) (__memcmp((s1),(s2),(n)))
void * _Builtin __memset(void *s, int c, size_t n);
#define memset(s,c,n) (__memset((s),(c),(n)))
void * _Builtin __memmove(void *s1, const void *s2, size_t n);
#define memmove(s1,s2,n) (__memmove((s1),(s2),(n)))
#endif
#if defined (__GNUC__) && __GNUC__ >= 3
#define memcpy(a, b, c) (__builtin_memcpy((a),(b),(c)))
#define memcmp(s1, s2, n) (__builtin_memcmp((s1),(s2),(n)))
#endif
/* We don't activate these GCC builtins, because they
normally resort to a call to the normal function,
and when they do, they generate slightly worse
code! Also, they appear to be buggy on MVS. */
#if 0
#define strcat(s1,s2) (__builtin_strcat((s1),(s2)))
#define strchr(s,c) (__builtin_strchr((s),(c)))
#define strcmp(s1,s2) (__builtin_strcmp((s1),(s2)))
#define strcpy(s1,s2) (__builtin_strcpy((s1),(s2)))
#define strlen(s) (__builtin_strlen((s)))
#define strncat(s1,s2,n) (__builtin_strncat((s1),(s2),(n)))
#define strncmp(s1,s2,n) (__builtin_strncmp((s1),(s2),(n)))
#define strncpy(s1,s2,n) (__builtin_strncpy((s1),(s2),(n)))
#define strrchr(s,c) (__builtin_strrchr((s),(c)))
#define memset(s,c,n) (__builtin_memset((s),(c),(n)))
#define strstr(s1,s2) (__builtin_strstr((s1),(s2)))
#define strpbrk(s1,s2) (__builtin_strpbrk((s1),(s2)))
#define strspn(s1,s2) (__builtin_strspn((s1),(s2)))
#define strcspn(s1,s2) (__builtin_strcspn((s1),(s2)))
#endif
#ifdef __BORLANDC__
#ifdef __INLINE_FUNCTIONS__
void *__memcpy__(void *s1, const void *s2, size_t n);
#define memcpy(a,b,c) (__memcpy__((a),(b),(c)))
void *__memchr__(const void *s, int c, size_t n);
#define memchr(s,c,n) (__memchr__((s),(c),(n)))
int __memcmp__(const void *s1, const void *s2, size_t n);
#define memcmp(s1,s2,n) (__memcmp__((s1),(s2),(n)))
void *__memset__(void *s, int c, size_t n);
#define memset(s,c,n) (__memset__((s),(c),(n)))
char *__strcat__(char *s1, const char *s2);
#define strcat(s1,s2) (__strcat__((s1),(s2)))
char *__strchr__(const char *s, int c);
#define strchr(s,c) (__strchr__((s),(c)))
int __strcmp__(const char *s1, const char *s2);
#define strcmp(s1,s2) (__strcmp__((s1),(s2)))
char *__strcpy__(char *s1, const char *s2);
#define strcpy(s1,s2) (__strcpy__((s1),(s2)))
size_t __strlen__(const char *s);
#define strlen(s) (__strlen__((s)))
char *__strncat__(char *s1, const char *s2, size_t n);
#define strncat(s1,s2,n) (__strncat__((s1),(s2),(n)))
int __strncmp__(const char *s1, const char *s2, size_t n);
#define strncmp(s1,s2,n) (__strncmp__((s1),(s2),(n)))
char *__strncpy__(char *s1, const char *s2, size_t n);
#define strncpy(s1,s2,n) (__strncpy__((s1),(s2),(n)))
char *__strrchr__(const char *s, int c);
#define strrchr(s,c) (__strrchr__((s),(c)))
#endif
#endif
#endif