stacinhtml

Static C in HTML - simple static site generator
git clone git://git.kocotian.pl/stacinhtml.git
Log | Files | Refs | README | LICENSE

commit a1b365f51619ac021623ba4e1f1215d9643e5d0a
parent e6256014630ff87f8dece9f661df1b0dc69fc687
Author: kocotian <kocotian@kocotian.pl>
Date:   Thu, 25 Mar 2021 13:13:50 +0100

Strtok fix

Diffstat:
Mstr.h | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/str.h b/str.h @@ -53,10 +53,13 @@ static ssize_t Strtok(String string, String *out, char c) { char *tmpptr = string.data; - while ((unsigned)(tmpptr - string.data) < string.len) { - if (*(++tmpptr) == c) break; - } - string.len = tmpptr - string.data; + + if (!string.len) return *out = string, 0; + if (*(tmpptr) != c) + while ((unsigned)(tmpptr - string.data) <= string.len) { + if (*(++tmpptr) == c) break; + } + string.len = ++tmpptr - string.data; *out = string; return (tmpptr - string.data); }