openpcd/firmware/lib/string.c @ master
1 | 2a2d6309 | (no author) | /*
|
---|---|---|---|
2 | * linux/lib/string.c
|
||
3 | *
|
||
4 | * Copyright (C) 1991, 1992 Linus Torvalds
|
||
5 | */
|
||
6 | |||
7 | /*
|
||
8 | * stupid library routines.. The optimized versions should generally be found
|
||
9 | * as inline code in <asm-xx/string.h>
|
||
10 | *
|
||
11 | * These are buggy as well..
|
||
12 | *
|
||
13 | * * Fri Jun 25 1999, Ingo Oeser <ioe@informatik.tu-chemnitz.de>
|
||
14 | * - Added strsep() which will replace strtok() soon (because strsep() is
|
||
15 | * reentrant and should be faster). Use only strsep() in new code, please.
|
||
16 | *
|
||
17 | * * Sat Feb 09 2002, Jason Thomas <jason@topic.com.au>,
|
||
18 | * Matthew Hawkins <matt@mh.dropbear.id.au>
|
||
19 | * - Kissed strtok() goodbye
|
||
20 | */
|
||
21 | |||
22 | #include <sys/types.h>
|
||
23 | #include <string.h>
|
||
24 | #include <asm/ctype.h>
|
||
25 | |||
26 | |||
27 | #ifndef __HAVE_ARCH_STRNLEN
|
||
28 | /**
|
||
29 | * strnlen - Find the length of a length-limited string
|
||
30 | * @s: The string to be sized
|
||
31 | * @count: The maximum number of bytes to search
|
||
32 | */
|
||
33 | size_t strnlen(const char *s, size_t count) |
||
34 | {
|
||
35 | const char *sc; |
||
36 | |||
37 | for (sc = s; count-- && *sc != '\0'; ++sc) |
||
38 | /* nothing */; |
||
39 | return sc - s; |
||
40 | }
|
||
41 | #endif
|