]> git.sur5r.net Git - cc65/blob - testcode/lib/strqtok-test.c
Fixed _textcolor definition.
[cc65] / testcode / lib / strqtok-test.c
1 /* strqtok-test.c
2 **
3 ** 2014-04-21, Paul Foerster
4 ** 2014-05-20, Greg King
5 **
6 ** This program tests that strqtok() correctly will parse strings
7 ** with quotation marks in them.  It should show this list of tokens
8 ** from the test strings:
9 **
10 ** >This<
11 ** >  is only    <
12 ** >a<
13 ** >short<
14 ** >quoting<
15 ** >test ,  honoring  blanks, commas<
16 ** >and<
17 ** >(4)<
18 ** >empty<
19 ** ><
20 ** ><
21 ** ><
22 ** ><
23 ** >strings,   EOT  <
24 **
25 ** It shouldn't show
26 **
27 ** >Bogus token<
28 **
29 */
30
31 #include <string.h>
32 #include <stdio.h>
33
34 void main (void)
35 {
36     /* b[] and s[] are declared as automatic, not static, variables
37     ** because strqtok() will change them.
38     ** They must be defined together; and, b[] must be defined first
39     ** (because they're copied onto the top-down stack).
40     */
41     char  b[] = "Bogus token ";
42     char  s[] = "  This ,  \"  is only    \"a   short   "
43         "quoting\"test ,  honoring  blanks"
44         ", commas\", and (4) empty \"\"\"\"\"\"\"\" \"strings,   EOT  ";
45     char* t = strqtok (s, " ,");
46
47     while (t != NULL) {
48         printf (">%s<\n", t);
49         t = strqtok (NULL, " ,");
50     }
51 }