ReactOS 0.4.15-dev-8138-g1e75ea8
mbstok.c
Go to the documentation of this file.
1#include <stdlib.h>
2#include <mbstring.h>
3
4/*
5 * @implemented
6 */
7unsigned char * _mbstok(unsigned char *s, const unsigned char *delim)
8{
9 const unsigned char *spanp;
10 int c, sc;
11 unsigned char *tok;
12 static unsigned char *last;
13
14
15 if (s == NULL && (s = last) == NULL)
16 return (NULL);
17
18 /*
19 * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
20 */
21 cont:
22 c = *s;
23 s = _mbsinc(s);
24
25 for (spanp = delim; (sc = *spanp) != 0; spanp = _mbsinc(spanp)) {
26 if (c == sc)
27 goto cont;
28 }
29
30 if (c == 0) { /* no non-delimiter characters */
31 last = NULL;
32 return (NULL);
33 }
34 tok = s - 1;
35
36 /*
37 * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
38 * Note that delim must have one NUL; we stop if we see that, too.
39 */
40 for (;;) {
41 c = *s;
42 s = _mbsinc(s);
43 spanp = delim;
44 do {
45 if ((sc = *spanp) == c) {
46 if (c == 0)
47 s = NULL;
48 else
49 s[-1] = 0;
50 last = s;
51 return (tok);
52 }
53 spanp = _mbsinc(spanp);
54 } while (sc != 0);
55 }
56 /* NOTREACHED */
57}
#define NULL
Definition: types.h:112
GLdouble s
Definition: gl.h:2039
const GLubyte * c
Definition: glext.h:8905
_Check_return_ _CRTIMP unsigned char *__cdecl _mbsinc(_In_z_ const unsigned char *_Ptr)
#define c
Definition: ke_i.h:80
unsigned char * _mbstok(unsigned char *s, const unsigned char *delim)
Definition: mbstok.c:7
static UINT UINT last
Definition: font.c:45