1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-11 11:30:13 +00:00

More conforming to the cc65 project's apparent writing style.

This commit is contained in:
Greg King 2014-05-23 16:52:02 -04:00
parent a92f51fea5
commit 2cc26e6e23
2 changed files with 53 additions and 52 deletions

View File

@ -1,14 +1,14 @@
/* /*
** strqtok() is like strtok(): It finds pieces of text, in a string, that are * strqtok() is like strtok(): It finds pieces of text, in a string, that are
** surrounded by given delimiter characters. It returns each piece, in turn, * surrounded by given delimiter characters. It returns each piece, in turn,
** as a string, until every piece has been found. Then, it returns NULL. But, * as a string, until every piece has been found. Then, it returns NULL. But,
** strqtok() recognizes quotation marks. A mark makes delimiters look ordinary * strqtok() recognizes quotation marks. A mark makes delimiters look ordinary
** until another quotation mark is seen. That allows us to include delimiters * until another quotation mark is seen. That allows us to include delimiters
** in tokens. (This version doesn't allow escaped quotation marks.) * in tokens. (This version doesn't allow escaped quotation marks.)
** *
** 2014-04-19, Daniel Serpell * 2014-04-19, Daniel Serpell
** 2014-04-21, Paul Foerster * 2014-04-21, Paul Foerster
** 2014-04-25, Greg King * 2014-04-25, Greg King
*/ */
@ -49,7 +49,7 @@ char* __fastcall__ strqtok (register char* s1, const char* s2)
} }
if (c == '\0') { if (c == '\0') {
/* The end of the last token is the end of the token list; /* The end of the last token is the end of the token list;
** don't go beyond it. * don't go beyond it.
*/ */
goto found; goto found;
} }
@ -70,7 +70,7 @@ char* __fastcall__ strqtok (register char* s1, const char* s2)
/* Search for the end of a quoted token. */ /* Search for the end of a quoted token. */
if ((s1 = strchr (s1, '\"')) == NULL) { if ((s1 = strchr (s1, '\"')) == NULL) {
/* The quoted token ended with '\0'; therefore, point to a '\0', /* The quoted token ended with '\0'; therefore, point to a '\0',
** so that the next call will return NULL. * so that the next call will return NULL.
*/ */
next = ""; next = "";
return start; return start;

View File

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