summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormike <mike@FreeBSD.org>2002-01-15 17:52:21 +0000
committermike <mike@FreeBSD.org>2002-01-15 17:52:21 +0000
commit1ba2eb7fe92c58ce4857aa03773db05dc79feaba (patch)
tree3f56409f6f971ce2ffd21507249b84e8938c26fe /lib
parent6a13ede71c19cdbfb688f722632b83a66fbed597 (diff)
downloadFreeBSD-src-1ba2eb7fe92c58ce4857aa03773db05dc79feaba.zip
FreeBSD-src-1ba2eb7fe92c58ce4857aa03773db05dc79feaba.tar.gz
Add a few cleanups from rev 1.1:
o Restore vendor ID. o Order variable types by size. o Remove a gratuitous temporary variable. Submitted by: bde
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/string/strtok.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/libc/string/strtok.c b/lib/libc/string/strtok.c
index 68b0865..11e63c1 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 <sys/cdefs.h>
__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 <stddef.h>
#ifdef DEBUG_STRTOK
#include <stdio.h>
@@ -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 @@ cont:
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 @@ cont:
/* 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.
OpenPOWER on IntegriCloud