mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:13:03 +00:00
Create a branch for header work.
svn path=/branches/header-work/; revision=45691
This commit is contained in:
parent
14fe274b1c
commit
9ea495ba33
19538 changed files with 0 additions and 1063950 deletions
57
lib/sdk/crt/mbstring/mbstok.c
Normal file
57
lib/sdk/crt/mbstring/mbstok.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include <stdlib.h>
|
||||
#include <mbstring.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
unsigned char * _mbstok(unsigned char *s, const unsigned char *delim)
|
||||
{
|
||||
const unsigned char *spanp;
|
||||
int c, sc;
|
||||
unsigned char *tok;
|
||||
static unsigned char *last;
|
||||
|
||||
|
||||
if (s == NULL && (s = last) == NULL)
|
||||
return (NULL);
|
||||
|
||||
/*
|
||||
* Skip (span) leading delimiters (s += strspn(s, delim), sort of).
|
||||
*/
|
||||
cont:
|
||||
c = *s;
|
||||
s = _mbsinc(s);
|
||||
|
||||
for (spanp = delim; (sc = *spanp) != 0; spanp = _mbsinc(spanp)) {
|
||||
if (c == sc)
|
||||
goto cont;
|
||||
}
|
||||
|
||||
if (c == 0) { /* no non-delimiter characters */
|
||||
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;
|
||||
s = _mbsinc(s);
|
||||
spanp = delim;
|
||||
do {
|
||||
if ((sc = *spanp) == c) {
|
||||
if (c == 0)
|
||||
s = NULL;
|
||||
else
|
||||
s[-1] = 0;
|
||||
last = s;
|
||||
return (tok);
|
||||
}
|
||||
spanp = _mbsinc(spanp);
|
||||
} while (sc != 0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue