2 ** strqtok() is like strtok(): It finds pieces of text, in a string, that are
3 ** surrounded by given delimiter characters. It returns each piece, in turn,
4 ** as a string, until every piece has been found. Then, it returns NULL. But,
5 ** strqtok() recognizes quotation marks. A mark makes delimiters look ordinary
6 ** until another quotation mark is seen. That allows us to include delimiters
7 ** in tokens. (This version doesn't allow escaped quotation marks.)
9 ** 2014-04-19, Daniel Serpell
10 ** 2014-04-21, Paul Foerster
11 ** 2014-04-25, Greg King
18 char* __fastcall__ strqtok (register char* s1, const char* s2)
22 static char* next = "";
31 /* Search for the start of a token. */
32 while (strchr (s2, c = *s1)) {
43 /* Save the start of the token. */
46 /* Search for the end of a non-quoted token. */
47 while ((c = *s1) != '\"' && !strchr (s2, c)) {
51 /* The end of the last token is the end of the token list;
52 ** don't go beyond it.
57 /* (A possible begin-quote mark will be rememberred.) */
64 /* Don't let a quote mark be rememberred. */
67 /* Save the start of the token. */
70 /* Search for the end of a quoted token. */
71 if ((s1 = strchr (s1, '\"')) == NULL) {
72 /* The quoted token ended with '\0'; therefore, point to a '\0',
73 ** so that the next call will return NULL.