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
This commit is contained in:
Mike Barcroft 2002-01-15 17:52:21 +00:00
parent f5c1e082d2
commit 4681597d9a

View File

@ -1,4 +1,4 @@
/* /*-
* Copyright (c) 1998 Softweyr LLC. All rights reserved. * Copyright (c) 1998 Softweyr LLC. All rights reserved.
* *
* strtok_r, from Berkeley strtok * strtok_r, from Berkeley strtok
@ -10,7 +10,6 @@
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
*
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notices, this list of conditions and the following disclaimer. * notices, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
@ -40,6 +39,12 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __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> #include <stddef.h>
#ifdef DEBUG_STRTOK #ifdef DEBUG_STRTOK
#include <stdio.h> #include <stdio.h>
@ -49,8 +54,8 @@ __FBSDID("$FreeBSD$");
char * char *
strtok_r(char *s, const char *delim, char **last) strtok_r(char *s, const char *delim, char **last)
{ {
char *spanp, *tok;
int c, sc; int c, sc;
char *spanp, *tok, *w;
if (s == NULL && (s = *last) == NULL) if (s == NULL && (s = *last) == NULL)
return (NULL); return (NULL);
@ -60,9 +65,10 @@ strtok_r(char *s, const char *delim, char **last)
*/ */
cont: cont:
c = *s++; c = *s++;
for (spanp = (char *)delim; (sc = *spanp++) != 0;) for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
if (c == sc) if (c == sc)
goto cont; goto cont;
}
if (c == 0) { /* no non-delimiter characters */ if (c == 0) { /* no non-delimiter characters */
*last = NULL; *last = NULL;
@ -81,10 +87,8 @@ cont:
if ((sc = *spanp++) == c) { if ((sc = *spanp++) == c) {
if (c == 0) if (c == 0)
s = NULL; s = NULL;
else { else
w = s - 1; s[-1] = '\0';
*w = '\0';
}
*last = s; *last = s;
return (tok); return (tok);
} }
@ -93,7 +97,6 @@ cont:
/* NOTREACHED */ /* NOTREACHED */
} }
char * char *
strtok(char *s, const char *delim) strtok(char *s, const char *delim)
{ {
@ -102,7 +105,6 @@ strtok(char *s, const char *delim)
return (strtok_r(s, delim, &last)); return (strtok_r(s, delim, &last));
} }
#ifdef DEBUG_STRTOK #ifdef DEBUG_STRTOK
/* /*
* Test the tokenizer. * Test the tokenizer.