|
@@ -38,122 +38,6 @@ FILE_LICENCE ( GPL2_ONLY );
|
38
|
38
|
|
39
|
39
|
/* *** FROM string.c *** */
|
40
|
40
|
|
41
|
|
-#ifndef __HAVE_ARCH_STRNICMP
|
42
|
|
-/**
|
43
|
|
- * strnicmp - Case insensitive, length-limited string comparison
|
44
|
|
- * @s1: One string
|
45
|
|
- * @s2: The other string
|
46
|
|
- * @len: the maximum number of characters to compare
|
47
|
|
- */
|
48
|
|
-int strnicmp(const char *s1, const char *s2, size_t len)
|
49
|
|
-{
|
50
|
|
- /* Yes, Virginia, it had better be unsigned */
|
51
|
|
- unsigned char c1, c2;
|
52
|
|
-
|
53
|
|
- c1 = 0; c2 = 0;
|
54
|
|
- if (len) {
|
55
|
|
- do {
|
56
|
|
- c1 = *s1; c2 = *s2;
|
57
|
|
- s1++; s2++;
|
58
|
|
- if (!c1)
|
59
|
|
- break;
|
60
|
|
- if (!c2)
|
61
|
|
- break;
|
62
|
|
- if (c1 == c2)
|
63
|
|
- continue;
|
64
|
|
- c1 = tolower(c1);
|
65
|
|
- c2 = tolower(c2);
|
66
|
|
- if (c1 != c2)
|
67
|
|
- break;
|
68
|
|
- } while (--len);
|
69
|
|
- }
|
70
|
|
- return (int)c1 - (int)c2;
|
71
|
|
-}
|
72
|
|
-#endif
|
73
|
|
-
|
74
|
|
-char * ___strtok;
|
75
|
|
-
|
76
|
|
-#ifndef __HAVE_ARCH_STRNCAT
|
77
|
|
-/**
|
78
|
|
- * strncat - Append a length-limited, %NUL-terminated string to another
|
79
|
|
- * @dest: The string to be appended to
|
80
|
|
- * @src: The string to append to it
|
81
|
|
- * @count: The maximum numbers of bytes to copy
|
82
|
|
- *
|
83
|
|
- * Note that in contrast to strncpy, strncat ensures the result is
|
84
|
|
- * terminated.
|
85
|
|
- */
|
86
|
|
-char * strncat(char *dest, const char *src, size_t count)
|
87
|
|
-{
|
88
|
|
- char *tmp = dest;
|
89
|
|
-
|
90
|
|
- if (count) {
|
91
|
|
- while (*dest)
|
92
|
|
- dest++;
|
93
|
|
- while ((*dest++ = *src++)) {
|
94
|
|
- if (--count == 0) {
|
95
|
|
- *dest = '\0';
|
96
|
|
- break;
|
97
|
|
- }
|
98
|
|
- }
|
99
|
|
- }
|
100
|
|
-
|
101
|
|
- return tmp;
|
102
|
|
-}
|
103
|
|
-#endif
|
104
|
|
-
|
105
|
|
-#ifndef __HAVE_ARCH_STRSPN
|
106
|
|
-/**
|
107
|
|
- * strspn - Calculate the length of the initial substring of @s which only
|
108
|
|
- * contain letters in @accept
|
109
|
|
- * @s: The string to be searched
|
110
|
|
- * @accept: The string to search for
|
111
|
|
- */
|
112
|
|
-size_t strspn(const char *s, const char *accept)
|
113
|
|
-{
|
114
|
|
- const char *p;
|
115
|
|
- const char *a;
|
116
|
|
- size_t count = 0;
|
117
|
|
-
|
118
|
|
- for (p = s; *p != '\0'; ++p) {
|
119
|
|
- for (a = accept; *a != '\0'; ++a) {
|
120
|
|
- if (*p == *a)
|
121
|
|
- break;
|
122
|
|
- }
|
123
|
|
- if (*a == '\0')
|
124
|
|
- return count;
|
125
|
|
- ++count;
|
126
|
|
- }
|
127
|
|
-
|
128
|
|
- return count;
|
129
|
|
-}
|
130
|
|
-#endif
|
131
|
|
-
|
132
|
|
-#ifndef __HAVE_ARCH_STRCSPN
|
133
|
|
-/**
|
134
|
|
- * strcspn - Calculate the length of the initial substring of @s which only
|
135
|
|
- * contain letters not in @reject
|
136
|
|
- * @s: The string to be searched
|
137
|
|
- * @accept: The string to search for
|
138
|
|
- */
|
139
|
|
-size_t strcspn(const char *s, const char *reject)
|
140
|
|
-{
|
141
|
|
- const char *p;
|
142
|
|
- const char *r;
|
143
|
|
- size_t count = 0;
|
144
|
|
-
|
145
|
|
- for (p = s; *p != '\0'; ++p) {
|
146
|
|
- for (r = reject; *r != '\0'; ++r) {
|
147
|
|
- if (*p == *r)
|
148
|
|
- return count;
|
149
|
|
- }
|
150
|
|
- ++count;
|
151
|
|
- }
|
152
|
|
-
|
153
|
|
- return count;
|
154
|
|
-}
|
155
|
|
-#endif
|
156
|
|
-
|
157
|
41
|
#ifndef __HAVE_ARCH_STRPBRK
|
158
|
42
|
/**
|
159
|
43
|
* strpbrk - Find the first occurrence of a set of characters
|
|
@@ -174,35 +58,6 @@ char * strpbrk(const char * cs,const char * ct)
|
174
|
58
|
}
|
175
|
59
|
#endif
|
176
|
60
|
|
177
|
|
-#ifndef __HAVE_ARCH_STRTOK
|
178
|
|
-/**
|
179
|
|
- * strtok - Split a string into tokens
|
180
|
|
- * @s: The string to be searched
|
181
|
|
- * @ct: The characters to search for
|
182
|
|
- *
|
183
|
|
- * WARNING: strtok is deprecated, use strsep instead.
|
184
|
|
- */
|
185
|
|
-char * strtok(char * s,const char * ct)
|
186
|
|
-{
|
187
|
|
- char *sbegin, *send;
|
188
|
|
-
|
189
|
|
- sbegin = s ? s : ___strtok;
|
190
|
|
- if (!sbegin) {
|
191
|
|
- return NULL;
|
192
|
|
- }
|
193
|
|
- sbegin += strspn(sbegin,ct);
|
194
|
|
- if (*sbegin == '\0') {
|
195
|
|
- ___strtok = NULL;
|
196
|
|
- return( NULL );
|
197
|
|
- }
|
198
|
|
- send = strpbrk( sbegin, ct);
|
199
|
|
- if (send && *send != '\0')
|
200
|
|
- *send++ = '\0';
|
201
|
|
- ___strtok = send;
|
202
|
|
- return (sbegin);
|
203
|
|
-}
|
204
|
|
-#endif
|
205
|
|
-
|
206
|
61
|
#ifndef __HAVE_ARCH_STRSEP
|
207
|
62
|
/**
|
208
|
63
|
* strsep - Split a string into tokens
|
|
@@ -230,46 +85,3 @@ char * strsep(char **s, const char *ct)
|
230
|
85
|
return sbegin;
|
231
|
86
|
}
|
232
|
87
|
#endif
|
233
|
|
-
|
234
|
|
-#ifndef __HAVE_ARCH_BCOPY
|
235
|
|
-/**
|
236
|
|
- * bcopy - Copy one area of memory to another
|
237
|
|
- * @src: Where to copy from
|
238
|
|
- * @dest: Where to copy to
|
239
|
|
- * @count: The size of the area.
|
240
|
|
- *
|
241
|
|
- * Note that this is the same as memcpy(), with the arguments reversed.
|
242
|
|
- * memcpy() is the standard, bcopy() is a legacy BSD function.
|
243
|
|
- *
|
244
|
|
- * You should not use this function to access IO space, use memcpy_toio()
|
245
|
|
- * or memcpy_fromio() instead.
|
246
|
|
- */
|
247
|
|
-char * bcopy(const char * src, char * dest, int count)
|
248
|
|
-{
|
249
|
|
- return memmove(dest,src,count);
|
250
|
|
-}
|
251
|
|
-#endif
|
252
|
|
-
|
253
|
|
-#ifndef __HAVE_ARCH_MEMSCAN
|
254
|
|
-/**
|
255
|
|
- * memscan - Find a character in an area of memory.
|
256
|
|
- * @addr: The memory area
|
257
|
|
- * @c: The byte to search for
|
258
|
|
- * @size: The size of the area.
|
259
|
|
- *
|
260
|
|
- * returns the address of the first occurrence of @c, or 1 byte past
|
261
|
|
- * the area if @c is not found
|
262
|
|
- */
|
263
|
|
-void * memscan(const void * addr, int c, size_t size)
|
264
|
|
-{
|
265
|
|
- unsigned char * p = (unsigned char *) addr;
|
266
|
|
-
|
267
|
|
- while (size) {
|
268
|
|
- if (*p == c)
|
269
|
|
- return (void *) p;
|
270
|
|
- p++;
|
271
|
|
- size--;
|
272
|
|
- }
|
273
|
|
- return (void *) p;
|
274
|
|
-}
|
275
|
|
-#endif
|