1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

re-indented to follow "project curl"-style, renamed curl_ prefix to Curl_

This commit is contained in:
Daniel Stenberg 2001-05-29 19:20:21 +00:00
parent d567659bf4
commit 88d536eb3b

View File

@ -72,65 +72,56 @@
#include <stddef.h> #include <stddef.h>
char * char *
curl_strtok_r(char *s, const char *delim, char **last) Curl_strtok_r(char *s, const char *delim, char **last)
{ {
char *spanp; char *spanp;
int c, sc; int c, sc;
char *tok; char *tok;
if (s == NULL && (s = *last) == NULL) if (s == NULL && (s = *last) == NULL) {
{ return NULL;
return NULL; }
/*
* Skip (span) leading delimiters (s += strspn(s, delim), sort of).
*/
cont:
c = *s++;
for (spanp = (char *)delim; (sc = *spanp++) != 0; ) {
if (c == sc) {
goto cont;
} }
}
/* if (c == 0) { /* no non-delimiter characters */
* Skip (span) leading delimiters (s += strspn(s, delim), sort of). *last = NULL;
*/ return NULL;
cont: }
tok = s - 1;
/*
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
* Note that delim must have one NUL; we stop if we see that, too.
*/
for (;;) {
c = *s++; c = *s++;
for (spanp = (char *)delim; (sc = *spanp++) != 0; ) spanp = (char *)delim;
{ do {
if (c == sc) if ((sc = *spanp++) == c) {
{ if (c == 0) {
goto cont; s = NULL;
} }
else {
char *w = s - 1;
*w = '\0';
}
*last = s;
return tok;
}
} }
while (sc != 0);
if (c == 0) /* no non-delimiter characters */ }
{ /* NOTREACHED */
*last = NULL;
return NULL;
}
tok = s - 1;
/*
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
* Note that delim must have one NUL; we stop if we see that, too.
*/
for (;;)
{
c = *s++;
spanp = (char *)delim;
do
{
if ((sc = *spanp++) == c)
{
if (c == 0)
{
s = NULL;
}
else
{
char *w = s - 1;
*w = '\0';
}
*last = s;
return tok;
}
}
while (sc != 0);
}
/* NOTREACHED */
} }
#endif #endif