diff options
| author | Linus Torvalds <torvalds@athlon.transmeta.com> | 2002-02-04 18:03:52 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@athlon.transmeta.com> | 2002-02-04 18:03:52 -0800 |
| commit | b56566c61ebe66fc5c9aa33385ba5b13bf6a8957 (patch) | |
| tree | 098a056a41285753cbd8b993e292b82c55a2fc9a /lib/string.c | |
| parent | 44e8778cf19e61151a4819b771186c7e4c49bff1 (diff) | |
v2.4.2.2 -> v2.4.2.3
- Alan Cox: continued merging
- Urban Widmark: smbfs fix (d_add on already hashed dentry - no-no).
- Andrew Morton: 3c59x update
- Jeff Garzik: network driver cleanups and fixes
- Gérard Roudier: sym-ncr drivers update
- Jens Axboe: more loop cleanups and fixes
- David Miller: sparc update, some networking fixes
Diffstat (limited to 'lib/string.c')
| -rw-r--r-- | lib/string.c | 158 |
1 files changed, 154 insertions, 4 deletions
diff --git a/lib/string.c b/lib/string.c index 3ce8829e4eea..6ebb2c56333f 100644 --- a/lib/string.c +++ b/lib/string.c @@ -20,6 +20,12 @@ #include <linux/ctype.h> #ifndef __HAVE_ARCH_STRNICMP +/** + * strnicmp - Case insensitive, length-limited string comparison + * @s1: One string + * @s2: The other string + * @len: the maximum number of characters to compare + */ int strnicmp(const char *s1, const char *s2, size_t len) { /* Yes, Virginia, it had better be unsigned */ @@ -49,6 +55,11 @@ int strnicmp(const char *s1, const char *s2, size_t len) char * ___strtok; #ifndef __HAVE_ARCH_STRCPY +/** + * strcpy - Copy a %NUL terminated string + * @dest: Where to copy the string to + * @src: Where to copy the string from + */ char * strcpy(char * dest,const char *src) { char *tmp = dest; @@ -60,6 +71,16 @@ char * strcpy(char * dest,const char *src) #endif #ifndef __HAVE_ARCH_STRNCPY +/** + * strncpy - Copy a length-limited, %NUL-terminated string + * @dest: Where to copy the string to + * @src: Where to copy the string from + * @count: The maximum number of bytes to copy + * + * Note that unlike userspace strncpy, this does not %NUL-pad the buffer. + * However, the result is not %NUL-terminated if the source exceeds + * @count bytes. + */ char * strncpy(char * dest,const char *src,size_t count) { char *tmp = dest; @@ -72,6 +93,11 @@ char * strncpy(char * dest,const char *src,size_t count) #endif #ifndef __HAVE_ARCH_STRCAT +/** + * strcat - Append one %NUL-terminated string to another + * @dest: The string to be appended to + * @src: The string to append to it + */ char * strcat(char * dest, const char * src) { char *tmp = dest; @@ -86,6 +112,15 @@ char * strcat(char * dest, const char * src) #endif #ifndef __HAVE_ARCH_STRNCAT +/** + * strncat - Append a length-limited, %NUL-terminated string to another + * @dest: The string to be appended to + * @src: The string to append to it + * @count: The maximum numbers of bytes to copy + * + * Note that in contrast to strncpy, strncat ensures the result is + * terminated. + */ char * strncat(char *dest, const char *src, size_t count) { char *tmp = dest; @@ -106,6 +141,11 @@ char * strncat(char *dest, const char *src, size_t count) #endif #ifndef __HAVE_ARCH_STRCMP +/** + * strcmp - Compare two strings + * @cs: One string + * @ct: Another string + */ int strcmp(const char * cs,const char * ct) { register signed char __res; @@ -120,6 +160,12 @@ int strcmp(const char * cs,const char * ct) #endif #ifndef __HAVE_ARCH_STRNCMP +/** + * strncmp - Compare two length-limited strings + * @cs: One string + * @ct: Another string + * @count: The maximum number of bytes to compare + */ int strncmp(const char * cs,const char * ct,size_t count) { register signed char __res = 0; @@ -135,6 +181,11 @@ int strncmp(const char * cs,const char * ct,size_t count) #endif #ifndef __HAVE_ARCH_STRCHR +/** + * strchr - Find the first occurrence of a character in a string + * @s: The string to be searched + * @c: The character to search for + */ char * strchr(const char * s, int c) { for(; *s != (char) c; ++s) @@ -145,6 +196,11 @@ char * strchr(const char * s, int c) #endif #ifndef __HAVE_ARCH_STRRCHR +/** + * strrchr - Find the last occurrence of a character in a string + * @s: The string to be searched + * @c: The character to search for + */ char * strrchr(const char * s, int c) { const char *p = s + strlen(s); @@ -157,6 +213,10 @@ char * strrchr(const char * s, int c) #endif #ifndef __HAVE_ARCH_STRLEN +/** + * strlen - Find the length of a string + * @s: The string to be sized + */ size_t strlen(const char * s) { const char *sc; @@ -168,6 +228,11 @@ size_t strlen(const char * s) #endif #ifndef __HAVE_ARCH_STRNLEN +/** + * strnlen - Find the length of a length-limited string + * @s: The string to be sized + * @count: The maximum number of bytes to search + */ size_t strnlen(const char * s, size_t count) { const char *sc; @@ -179,6 +244,12 @@ size_t strnlen(const char * s, size_t count) #endif #ifndef __HAVE_ARCH_STRSPN +/** + * strspn - Calculate the length of the initial substring of @s which only + * contain letters in @accept + * @s: The string to be searched + * @accept: The string to search for + */ size_t strspn(const char *s, const char *accept) { const char *p; @@ -200,6 +271,11 @@ size_t strspn(const char *s, const char *accept) #endif #ifndef __HAVE_ARCH_STRPBRK +/** + * strpbrk - Find the first occurrence of a set of characters + * @cs: The string to be searched + * @ct: The characters to search for + */ char * strpbrk(const char * cs,const char * ct) { const char *sc1,*sc2; @@ -215,6 +291,13 @@ char * strpbrk(const char * cs,const char * ct) #endif #ifndef __HAVE_ARCH_STRTOK +/** + * strtok - Split a string into tokens + * @s: The string to be searched + * @ct: The characters to search for + * + * WARNING: strtok is deprecated, use strsep instead. + */ char * strtok(char * s,const char * ct) { char *sbegin, *send; @@ -237,7 +320,13 @@ char * strtok(char * s,const char * ct) #endif #ifndef __HAVE_ARCH_STRSEP - +/** + * strsep - Split a string into tokens + * @s: The string to be searched + * @ct: The characters to search for + * + * strsep() updates @s to point after the token, ready for the next call. + */ char * strsep(char **s, const char * ct) { char *sbegin=*s; @@ -256,6 +345,12 @@ char * strsep(char **s, const char * ct) #endif #ifndef __HAVE_ARCH_MEMSET +/** + * memset - Fill a region of memory with the given value + * @s: Pointer to the start of the area. + * @c: The byte to fill the area with + * @count: The size of the area. + */ void * memset(void * s,int c,size_t count) { char *xs = (char *) s; @@ -268,6 +363,18 @@ void * memset(void * s,int c,size_t count) #endif #ifndef __HAVE_ARCH_BCOPY +/** + * bcopy - Copy one area of memory to another + * @src: Where to copy from + * @dest: Where to copy to + * @count: The size of the area. + * + * When using copies for I/O remember that bcopy and memcpy are entitled + * to do out of order writes and may well exactly that. + * + * Note that this is the same as memcpy, with the arguments reversed. memcpy + * is the standard, bcopy is a legacy BSD function. + */ char * bcopy(const char * src, char * dest, int count) { char *tmp = dest; @@ -280,6 +387,15 @@ char * bcopy(const char * src, char * dest, int count) #endif #ifndef __HAVE_ARCH_MEMCPY +/** + * memcpy - Copy one area of memory to another + * @dest: Where to copy to + * @src: Where to copy from + * @count: The size of the area. + * + * When using copies for I/O remember that bcopy and memcpy are entitled + * to do out of order writes and may well exactly that. + */ void * memcpy(void * dest,const void *src,size_t count) { char *tmp = (char *) dest, *s = (char *) src; @@ -292,6 +408,14 @@ void * memcpy(void * dest,const void *src,size_t count) #endif #ifndef __HAVE_ARCH_MEMMOVE +/** + * memmove - Copy one area of memory to another + * @dest: Where to copy to + * @src: Where to copy from + * @count: The size of the area. + * + * memmove copes with overlapping areas. + */ void * memmove(void * dest,const void *src,size_t count) { char *tmp, *s; @@ -314,6 +438,12 @@ void * memmove(void * dest,const void *src,size_t count) #endif #ifndef __HAVE_ARCH_MEMCMP +/** + * memmove - Compare two areas of memory + * @cs: One area of memory + * @ct: Another area of memory + * @count: The size of the area. + */ int memcmp(const void * cs,const void * ct,size_t count) { const unsigned char *su1, *su2; @@ -326,10 +456,16 @@ int memcmp(const void * cs,const void * ct,size_t count) } #endif -/* - * find the first occurrence of byte 'c', or 1 past the area if none - */ #ifndef __HAVE_ARCH_MEMSCAN +/** + * memscan - Find a character in an area of memory. + * @addr: The memory area + * @c: The byte to search for + * @size: The size of the area. + * + * returns the address of the first occurrence of @c, or 1 byte past + * the area if @c is not found + */ void * memscan(void * addr, int c, size_t size) { unsigned char * p = (unsigned char *) addr; @@ -345,6 +481,11 @@ void * memscan(void * addr, int c, size_t size) #endif #ifndef __HAVE_ARCH_STRSTR +/** + * strstr - Find the first substring in a %NUL terminated string + * @s1: The string to be searched + * @s2: The string to search for + */ char * strstr(const char * s1,const char * s2) { int l1, l2; @@ -364,6 +505,15 @@ char * strstr(const char * s1,const char * s2) #endif #ifndef __HAVE_ARCH_MEMCHR +/** + * memchr - Find a character in an area of memory. + * @s: The memory area + * @c: The byte to search for + * @n: The size of the area. + * + * returns the address of the first occurrence of @c, or %NULL + * if @c is not found + */ void *memchr(const void *s, int c, size_t n) { const unsigned char *p = s; |
