1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-11 05:29:33 +00:00
cc65/testcode/lib/strqtok-test.c

51 lines
1.1 KiB
C
Raw Normal View History

2014-05-20 20:33:16 +00:00
/* strqtok-test.c
**
2014-05-22 17:42:15 +00:00
** 2014-04-21, Paul Foerster
2014-05-20 20:33:16 +00:00
** 2014-05-20, Greg King
**
** This program tests that strqtok() correctly will parse strings
** with quotation marks in them. It should show this list of tokens
** from the test strings:
**
** >This<
** > is only <
** >a<
** >short<
** >quoting<
** >test , honoring blanks, commas<
** >and<
** >(4)<
** >empty<
** ><
** ><
** ><
** ><
** >strings, EOT <
**
2014-05-22 17:42:15 +00:00
** It shouldn't show
2014-05-20 20:33:16 +00:00
**
** >Bogus token<
*/
#include <string.h>
#include <stdio.h>
void main (void)
2014-05-20 20:33:16 +00:00
{
/* b[] and s[] are declared as automatic, not static, variables
** because strqtok() will change them.
** They must be defined together; and, b[] must be defined first
** (because they're copied onto the top-down stack).
*/
char b[] = "Bogus token ";
char s[] = " This , \" is only \"a short "
"quoting\"test , honoring blanks"
", commas\", and (4) empty \"\"\"\"\"\"\"\" \"strings, EOT ";
char *t = strqtok (s, " ,");
2014-05-20 20:33:16 +00:00
while (t != NULL) {
printf (">%s<\n", t);
t = strqtok (NULL, " ,");
2014-05-20 20:33:16 +00:00
}
}