X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=lib%2Fstrsep.c;h=b71e9f7bf25ab34e17084b737af5ecccd2a0f85a;hb=783500ad13ededece6c8912af1c937f990880e1f;hp=f8e55b5351cc3a283d344f3c90af340a6f74e252;hpb=00fb3c8dcbb940338fea9f6cab689b4924266305;p=fio.git diff --git a/lib/strsep.c b/lib/strsep.c index f8e55b53..b71e9f7b 100644 --- a/lib/strsep.c +++ b/lib/strsep.c @@ -2,25 +2,28 @@ char *strsep(char **stringp, const char *delim) { - char *s; - const char *spanp; - int c, sc; - char *tok; + char *s, *tok; + const char *spanp; + int c, sc; - if ((s = *stringp) == NULL) - return (NULL); - for (tok = s;;) { - c = *s++; - spanp = delim; - do { - if ((sc = *spanp++) == c) { - if (c == 0) - s = NULL; - else - s[-1] = 0; - *stringp = s; - return (tok); - } - } while (sc != 0); - } + s = *stringp; + if (!s) + return NULL; + + tok = s; + do { + c = *s++; + spanp = delim; + do { + sc = *spanp++; + if (sc == c) { + if (c == 0) + s = NULL; + else + s[-1] = 0; + *stringp = s; + return tok; + } + } while (sc != 0); + } while (1); }