From 2cc26e6e23bd3341dee4e12710df322740e64018 Mon Sep 17 00:00:00 2001 From: Greg King Date: Fri, 23 May 2014 16:52:02 -0400 Subject: [PATCH] More conforming to the cc65 project's apparent writing style. --- libsrc/common/strqtok.c | 36 +++++++++---------- testcode/lib/strqtok-test.c | 69 +++++++++++++++++++------------------ 2 files changed, 53 insertions(+), 52 deletions(-) diff --git a/libsrc/common/strqtok.c b/libsrc/common/strqtok.c index 132a50d69..6e791f898 100644 --- a/libsrc/common/strqtok.c +++ b/libsrc/common/strqtok.c @@ -1,15 +1,15 @@ /* -** 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, -** as a string, until every piece has been found. Then, it returns NULL. But, -** strqtok() recognizes quotation marks. A mark makes delimiters look ordinary -** until another quotation mark is seen. That allows us to include delimiters -** in tokens. (This version doesn't allow escaped quotation marks.) -** -** 2014-04-19, Daniel Serpell -** 2014-04-21, Paul Foerster -** 2014-04-25, Greg King -*/ + * 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, + * as a string, until every piece has been found. Then, it returns NULL. But, + * strqtok() recognizes quotation marks. A mark makes delimiters look ordinary + * until another quotation mark is seen. That allows us to include delimiters + * in tokens. (This version doesn't allow escaped quotation marks.) + * + * 2014-04-19, Daniel Serpell + * 2014-04-21, Paul Foerster + * 2014-04-25, Greg King + */ #include @@ -17,9 +17,9 @@ char* __fastcall__ strqtok (register char* s1, const char* s2) { - static char c; - static char *start; - static char *next = ""; + static char c; + static char* start; + static char* next = ""; if (s1 == NULL) { s1 = next; @@ -49,8 +49,8 @@ char* __fastcall__ strqtok (register char* s1, const char* s2) } if (c == '\0') { /* 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; } @@ -70,8 +70,8 @@ char* __fastcall__ strqtok (register char* s1, const char* s2) /* Search for the end of a quoted token. */ if ((s1 = strchr (s1, '\"')) == NULL) { /* 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 = ""; return start; } diff --git a/testcode/lib/strqtok-test.c b/testcode/lib/strqtok-test.c index 576ab531d..d49082917 100644 --- a/testcode/lib/strqtok-test.c +++ b/testcode/lib/strqtok-test.c @@ -1,31 +1,32 @@ /* strqtok-test.c -** -** 2014-04-21, Paul Foerster -** 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 < -** -** It shouldn't show -** -** >Bogus token< -*/ + * + * 2014-04-21, Paul Foerster + * 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 < + * + * It shouldn't show + * + * >Bogus token< + * + */ #include #include @@ -33,15 +34,15 @@ void main (void) { /* 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 " + * 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, " ,"); + char* t = strqtok (s, " ,"); while (t != NULL) { printf (">%s<\n", t); -- 2.39.5