diff --git a/lib/libc/string/strtok.c b/lib/libc/string/strtok.c index 68b0865fe8c9..11e63c1a3959 100644 --- a/lib/libc/string/strtok.c +++ b/lib/libc/string/strtok.c @@ -1,4 +1,4 @@ -/* +/*- * Copyright (c) 1998 Softweyr LLC. All rights reserved. * * strtok_r, from Berkeley strtok @@ -10,7 +10,6 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * * 1. Redistributions of source code must retain the above copyright * notices, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright @@ -40,6 +39,12 @@ #include __FBSDID("$FreeBSD$"); +#if 0 +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strtok.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ +#endif + #include #ifdef DEBUG_STRTOK #include @@ -49,8 +54,8 @@ __FBSDID("$FreeBSD$"); char * strtok_r(char *s, const char *delim, char **last) { + char *spanp, *tok; int c, sc; - char *spanp, *tok, *w; if (s == NULL && (s = *last) == NULL) return (NULL); @@ -60,9 +65,10 @@ strtok_r(char *s, const char *delim, char **last) */ cont: c = *s++; - for (spanp = (char *)delim; (sc = *spanp++) != 0;) + for (spanp = (char *)delim; (sc = *spanp++) != 0;) { if (c == sc) goto cont; + } if (c == 0) { /* no non-delimiter characters */ *last = NULL; @@ -81,10 +87,8 @@ strtok_r(char *s, const char *delim, char **last) if ((sc = *spanp++) == c) { if (c == 0) s = NULL; - else { - w = s - 1; - *w = '\0'; - } + else + s[-1] = '\0'; *last = s; return (tok); } @@ -93,7 +97,6 @@ strtok_r(char *s, const char *delim, char **last) /* NOTREACHED */ } - char * strtok(char *s, const char *delim) { @@ -102,7 +105,6 @@ strtok(char *s, const char *delim) return (strtok_r(s, delim, &last)); } - #ifdef DEBUG_STRTOK /* * Test the tokenizer.