4 * Copyright (C) 1991, 1992 Linus Torvalds
8 * stupid library routines.. The optimized versions should generally be found
9 * as inline code in <asm-xx/string.h>
11 * These are buggy as well..
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.
17 * * Sat Feb 09 2002, Jason Thomas <jason@topic.com.au>,
18 * Matthew Hawkins <matt@mh.dropbear.id.au>
19 * - Kissed strtok() goodbye
27 #include <linux/bug.h>
28 #include <linux/compiler.h>
29 #include <linux/string.h>
31 static char *skip_spaces(const char *str)
48 while (end >= s && isspace(*end))
52 return skip_spaces(s);
55 size_t strlcpy(char *dest, const char *src, size_t size)
57 size_t ret = strlen(src);
60 size_t len = (ret >= size) ? size - 1 : ret;
61 memcpy(dest, src, len);
67 ssize_t strscpy(char *dest, const char *src, size_t count)
71 if (count == 0 || WARN_ON_ONCE(count > INT_MAX))
85 /* Hit buffer length without finding a NUL; force NUL-termination. */
92 void memzero_explicit(void *s, size_t count)
98 int match_string(const char * const *array, size_t n, const char *string)
103 for (index = 0; index < n; index++) {
107 if (!strcmp(item, string))