X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=lib%2Fstring.c;h=c4ca944bb42c0cabcea15a3cce3aca4f6fbf9029;hb=68b83cb76bae38e88cd460ccfb7ee5862d58947f;hp=c1a28c14ced51dd58424a10d2af0e1444207a80a;hpb=d53ecad92f06d2e38a5cbc13af7473867c7fa277;p=oweals%2Fu-boot.git diff --git a/lib/string.c b/lib/string.c index c1a28c14ce..c4ca944bb4 100644 --- a/lib/string.c +++ b/lib/string.c @@ -230,6 +230,14 @@ char * strchr(const char * s, int c) } #endif +const char *strchrnul(const char *s, int c) +{ + for (; *s != (char)c; ++s) + if (*s == '\0') + break; + return s; +} + #ifndef __HAVE_ARCH_STRRCHR /** * strrchr - Find the last occurrence of a character in a string @@ -278,6 +286,30 @@ size_t strnlen(const char * s, size_t count) } #endif +#ifndef __HAVE_ARCH_STRCSPN +/** + * strcspn - Calculate the length of the initial substring of @s which does + * not contain letters in @reject + * @s: The string to be searched + * @reject: The string to avoid + */ +size_t strcspn(const char *s, const char *reject) +{ + const char *p; + const char *r; + size_t count = 0; + + for (p = s; *p != '\0'; ++p) { + for (r = reject; *r != '\0'; ++r) { + if (*p == *r) + return count; + } + ++count; + } + return count; +} +#endif + #ifndef __HAVE_ARCH_STRDUP char * strdup(const char *s) { @@ -511,16 +543,9 @@ void * memmove(void * dest,const void *src,size_t count) { char *tmp, *s; - if (src == dest) - return dest; - if (dest <= src) { - tmp = (char *) dest; - s = (char *) src; - while (count--) - *tmp++ = *s++; - } - else { + memcpy(dest, src, count); + } else { tmp = (char *) dest + count; s = (char *) src + count; while (count--)