ReactOS 0.4.16-dev-300-g2aadf2e
mbstok.c File Reference
#include <stdlib.h>
#include <mbstring.h>
Include dependency graph for mbstok.c:

Go to the source code of this file.

Functions

unsigned char_mbstok (unsigned char *s, const unsigned char *delim)
 

Function Documentation

◆ _mbstok()

unsigned char * _mbstok ( unsigned char s,
const unsigned char delim 
)

Definition at line 7 of file mbstok.c.

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
static UINT UINT last
Definition: font.c:45