summaryrefslogtreecommitdiffstats
path: root/lib/libc/string
diff options
context:
space:
mode:
authormike <mike@FreeBSD.org>2002-01-15 08:50:28 +0000
committermike <mike@FreeBSD.org>2002-01-15 08:50:28 +0000
commitbeadda288c8b352afb2115af37fc0d89e94caaa2 (patch)
tree255900270f709c55f21994ac455df4e5a2a81116 /lib/libc/string
parent8d717369429839a39cd22234b6640cfc40c8b729 (diff)
downloadFreeBSD-src-beadda288c8b352afb2115af37fc0d89e94caaa2.zip
FreeBSD-src-beadda288c8b352afb2115af37fc0d89e94caaa2.tar.gz
o Add prototype for printf(3).
style(9): o Order variables in declarations. o Move initialization out of declaration. o Fix over-indents in previous delta.
Diffstat (limited to 'lib/libc/string')
-rw-r--r--lib/libc/string/strtok.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/libc/string/strtok.c b/lib/libc/string/strtok.c
index 9b1dfba..68b0865 100644
--- a/lib/libc/string/strtok.c
+++ b/lib/libc/string/strtok.c
@@ -41,14 +41,16 @@
__FBSDID("$FreeBSD$");
#include <stddef.h>
+#ifdef DEBUG_STRTOK
+#include <stdio.h>
+#endif
#include <string.h>
char *
strtok_r(char *s, const char *delim, char **last)
{
- char *spanp;
int c, sc;
- char *tok;
+ char *spanp, *tok, *w;
if (s == NULL && (s = *last) == NULL)
return (NULL);
@@ -80,7 +82,7 @@ cont:
if (c == 0)
s = NULL;
else {
- char *w = s - 1;
+ w = s - 1;
*w = '\0';
}
*last = s;
@@ -108,23 +110,24 @@ strtok(char *s, const char *delim)
int
main(void)
{
- char test[80], blah[80];
- char *sep = "\\/:;=-";
- char *word, *phrase, *brkt, *brkb;
+ char blah[80], test[80];
+ char *brkb, *brkt, *phrase, *sep, *word;
+
+ sep = "\\/:;=-";
+ phrase = "foo";
printf("String tokenizer test:\n");
strcpy(test, "This;is.a:test:of=the/string\\tokenizer-function.");
for (word = strtok(test, sep); word; word = strtok(NULL, sep))
printf("Next word is \"%s\".\n", word);
- phrase = "foo";
strcpy(test, "This;is.a:test:of=the/string\\tokenizer-function.");
for (word = strtok_r(test, sep, &brkt); word;
- word = strtok_r(NULL, sep, &brkt)) {
+ word = strtok_r(NULL, sep, &brkt)) {
strcpy(blah, "blah:blat:blab:blag");
for (phrase = strtok_r(blah, sep, &brkb); phrase;
- phrase = strtok_r(NULL, sep, &brkb))
+ phrase = strtok_r(NULL, sep, &brkb))
printf("So far we're at %s:%s\n", word, phrase);
}
OpenPOWER on IntegriCloud