Browse Source

stripped down version of string.c containing only the used functions

tags/v0.9.3
Holger Lubitz 17 years ago
parent
commit
c9c97b3444
1 changed files with 0 additions and 251 deletions
  1. 0
    251
      src/core/string.c

+ 0
- 251
src/core/string.c View File

@@ -28,41 +28,6 @@
28 28
 
29 29
 /* *** FROM string.c *** */
30 30
 
31
-#ifndef __HAVE_ARCH_STRNICMP
32
-/**
33
- * strnicmp - Case insensitive, length-limited string comparison
34
- * @s1: One string
35
- * @s2: The other string
36
- * @len: the maximum number of characters to compare
37
- */
38
-int strnicmp(const char *s1, const char *s2, size_t len)
39
-{
40
-	/* Yes, Virginia, it had better be unsigned */
41
-	unsigned char c1, c2;
42
-
43
-	c1 = 0;	c2 = 0;
44
-	if (len) {
45
-		do {
46
-			c1 = *s1; c2 = *s2;
47
-			s1++; s2++;
48
-			if (!c1)
49
-				break;
50
-			if (!c2)
51
-				break;
52
-			if (c1 == c2)
53
-				continue;
54
-			c1 = tolower(c1);
55
-			c2 = tolower(c2);
56
-			if (c1 != c2)
57
-				break;
58
-		} while (--len);
59
-	}
60
-	return (int)c1 - (int)c2;
61
-}
62
-#endif
63
-
64
-char * ___strtok;
65
-
66 31
 #ifndef __HAVE_ARCH_STRCPY
67 32
 /**
68 33
  * strcpy - Copy a %NUL terminated string
@@ -120,35 +85,6 @@ char * strcat(char * dest, const char * src)
120 85
 }
121 86
 #endif
122 87
 
123
-#ifndef __HAVE_ARCH_STRNCAT
124
-/**
125
- * strncat - Append a length-limited, %NUL-terminated string to another
126
- * @dest: The string to be appended to
127
- * @src: The string to append to it
128
- * @count: The maximum numbers of bytes to copy
129
- *
130
- * Note that in contrast to strncpy, strncat ensures the result is
131
- * terminated.
132
- */
133
-char * strncat(char *dest, const char *src, size_t count)
134
-{
135
-	char *tmp = dest;
136
-
137
-	if (count) {
138
-		while (*dest)
139
-			dest++;
140
-		while ((*dest++ = *src++)) {
141
-			if (--count == 0) {
142
-				*dest = '\0';
143
-				break;
144
-			}
145
-		}
146
-	}
147
-
148
-	return tmp;
149
-}
150
-#endif
151
-
152 88
 #ifndef __HAVE_ARCH_STRCMP
153 89
 /**
154 90
  * strcmp - Compare two strings
@@ -260,135 +196,6 @@ size_t strnlen(const char * s, size_t count)
260 196
 }
261 197
 #endif
262 198
 
263
-#ifndef __HAVE_ARCH_STRSPN
264
-/**
265
- * strspn - Calculate the length of the initial substring of @s which only
266
- * 	contain letters in @accept
267
- * @s: The string to be searched
268
- * @accept: The string to search for
269
- */
270
-size_t strspn(const char *s, const char *accept)
271
-{
272
-	const char *p;
273
-	const char *a;
274
-	size_t count = 0;
275
-
276
-	for (p = s; *p != '\0'; ++p) {
277
-		for (a = accept; *a != '\0'; ++a) {
278
-			if (*p == *a)
279
-				break;
280
-		}
281
-		if (*a == '\0')
282
-			return count;
283
-		++count;
284
-	}
285
-
286
-	return count;
287
-}
288
-#endif
289
-
290
-#ifndef __HAVE_ARCH_STRCSPN
291
-/**
292
- * strcspn - Calculate the length of the initial substring of @s which only
293
- * 	contain letters not in @reject
294
- * @s: The string to be searched
295
- * @accept: The string to search for
296
- */
297
-size_t strcspn(const char *s, const char *reject)
298
-{
299
-	const char *p;
300
-	const char *r;
301
-	size_t count = 0;
302
-
303
-	for (p = s; *p != '\0'; ++p) {
304
-		for (r = reject; *r != '\0'; ++r) {
305
-			if (*p == *r)
306
-				return count;
307
-		}
308
-		++count;
309
-	}
310
-
311
-	return count;
312
-}
313
-#endif
314
-
315
-#ifndef __HAVE_ARCH_STRPBRK
316
-/**
317
- * strpbrk - Find the first occurrence of a set of characters
318
- * @cs: The string to be searched
319
- * @ct: The characters to search for
320
- */
321
-char * strpbrk(const char * cs,const char * ct)
322
-{
323
-	const char *sc1,*sc2;
324
-
325
-	for( sc1 = cs; *sc1 != '\0'; ++sc1) {
326
-		for( sc2 = ct; *sc2 != '\0'; ++sc2) {
327
-			if (*sc1 == *sc2)
328
-				return (char *) sc1;
329
-		}
330
-	}
331
-	return NULL;
332
-}
333
-#endif
334
-
335
-#ifndef __HAVE_ARCH_STRTOK
336
-/**
337
- * strtok - Split a string into tokens
338
- * @s: The string to be searched
339
- * @ct: The characters to search for
340
- *
341
- * WARNING: strtok is deprecated, use strsep instead.
342
- */
343
-char * strtok(char * s,const char * ct)
344
-{
345
-	char *sbegin, *send;
346
-
347
-	sbegin  = s ? s : ___strtok;
348
-	if (!sbegin) {
349
-		return NULL;
350
-	}
351
-	sbegin += strspn(sbegin,ct);
352
-	if (*sbegin == '\0') {
353
-		___strtok = NULL;
354
-		return( NULL );
355
-	}
356
-	send = strpbrk( sbegin, ct);
357
-	if (send && *send != '\0')
358
-		*send++ = '\0';
359
-	___strtok = send;
360
-	return (sbegin);
361
-}
362
-#endif
363
-
364
-#ifndef __HAVE_ARCH_STRSEP
365
-/**
366
- * strsep - Split a string into tokens
367
- * @s: The string to be searched
368
- * @ct: The characters to search for
369
- *
370
- * strsep() updates @s to point after the token, ready for the next call.
371
- *
372
- * It returns empty tokens, too, behaving exactly like the libc function
373
- * of that name. In fact, it was stolen from glibc2 and de-fancy-fied.
374
- * Same semantics, slimmer shape. ;)
375
- */
376
-char * strsep(char **s, const char *ct)
377
-{
378
-	char *sbegin = *s, *end;
379
-
380
-	if (sbegin == NULL)
381
-		return NULL;
382
-
383
-	end = strpbrk(sbegin, ct);
384
-	if (end)
385
-		*end++ = '\0';
386
-	*s = end;
387
-
388
-	return sbegin;
389
-}
390
-#endif
391
-
392 199
 #ifndef __HAVE_ARCH_MEMSET
393 200
 /**
394 201
  * memset - Fill a region of memory with the given value
@@ -409,25 +216,6 @@ void * memset(void * s,int c,size_t count)
409 216
 }
410 217
 #endif
411 218
 
412
-#ifndef __HAVE_ARCH_BCOPY
413
-/**
414
- * bcopy - Copy one area of memory to another
415
- * @src: Where to copy from
416
- * @dest: Where to copy to
417
- * @count: The size of the area.
418
- *
419
- * Note that this is the same as memcpy(), with the arguments reversed.
420
- * memcpy() is the standard, bcopy() is a legacy BSD function.
421
- *
422
- * You should not use this function to access IO space, use memcpy_toio()
423
- * or memcpy_fromio() instead.
424
- */
425
-char * bcopy(const char * src, char * dest, int count)
426
-{
427
-	return memmove(dest,src,count);
428
-}
429
-#endif
430
-
431 219
 #ifndef __HAVE_ARCH_MEMCPY
432 220
 /**
433 221
  * memcpy - Copy one area of memory to another
@@ -498,30 +286,6 @@ int memcmp(const void * cs,const void * ct,size_t count)
498 286
 }
499 287
 #endif
500 288
 
501
-#ifndef __HAVE_ARCH_MEMSCAN
502
-/**
503
- * memscan - Find a character in an area of memory.
504
- * @addr: The memory area
505
- * @c: The byte to search for
506
- * @size: The size of the area.
507
- *
508
- * returns the address of the first occurrence of @c, or 1 byte past
509
- * the area if @c is not found
510
- */
511
-void * memscan(void * addr, int c, size_t size)
512
-{
513
-	unsigned char * p = (unsigned char *) addr;
514
-
515
-	while (size) {
516
-		if (*p == c)
517
-			return (void *) p;
518
-		p++;
519
-		size--;
520
-	}
521
-  	return (void *) p;
522
-}
523
-#endif
524
-
525 289
 #ifndef __HAVE_ARCH_STRSTR
526 290
 /**
527 291
  * strstr - Find the first substring in a %NUL terminated string
@@ -569,21 +333,6 @@ void * memchr(const void *s, int c, size_t n)
569 333
 
570 334
 #endif
571 335
 
572
-char * strndup(const char *s, size_t n)
573
-{
574
-	size_t len = strlen(s);
575
-	char *new;
576
-
577
-	if (len>n)
578
-		len = n;
579
-	new = malloc(len+1);
580
-	if (new) {
581
-		new[len] = '\0';
582
-		memcpy(new,s,len);
583
-	}
584
-	return new;
585
-}
586
-
587 336
 char * strdup(const char *s) {
588 337
 	return strndup(s, ~((size_t)0));
589 338
 }

Loading…
Cancel
Save