2 * Copyright (C) 1991, 1992 Linus Torvalds
3 * Copyright (C) 2004 Tobias Lorenz
5 * string handling functions
6 * based on linux/lib/string.c
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 FILE_LICENCE ( GPL2_ONLY );
16 * stupid library routines.. The optimized versions should generally be found
17 * as inline code in <asm-xx/string.h>
19 * These are buggy as well..
21 * * Fri Jun 25 1999, Ingo Oeser <ioe@informatik.tu-chemnitz.de>
22 * - Added strsep() which will replace strtok() soon (because strsep() is
23 * reentrant and should be faster). Use only strsep() in new code, please.
27 * these are the standard string functions that are currently not used by
28 * any code in etherboot. put into a separate file to avoid linking them in
29 * with the rest of string.o
30 * if anything ever does want to use a function of these, consider moving
31 * the function in question back into string.c
39 /* *** FROM string.c *** */
41 #ifndef __HAVE_ARCH_STRPBRK
43 * strpbrk - Find the first occurrence of a set of characters
44 * @cs: The string to be searched
45 * @ct: The characters to search for
47 char * strpbrk(const char * cs,const char * ct)
51 for( sc1 = cs; *sc1 != '\0'; ++sc1) {
52 for( sc2 = ct; *sc2 != '\0'; ++sc2) {
61 #ifndef __HAVE_ARCH_STRSEP
63 * strsep - Split a string into tokens
64 * @s: The string to be searched
65 * @ct: The characters to search for
67 * strsep() updates @s to point after the token, ready for the next call.
69 * It returns empty tokens, too, behaving exactly like the libc function
70 * of that name. In fact, it was stolen from glibc2 and de-fancy-fied.
71 * Same semantics, slimmer shape. ;)
73 char * strsep(char **s, const char *ct)
75 char *sbegin = *s, *end;
80 end = strpbrk(sbegin, ct);