From 48e9d858da36b0fee7787edd12e7f336ccdf04b4 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Wed, 29 Dec 2021 12:14:35 +0100 Subject: Fixed and simplified csview tokensizer call. --- examples/sview_split.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'examples/sview_split.c') diff --git a/examples/sview_split.c b/examples/sview_split.c index 3a079583..ed0365ec 100644 --- a/examples/sview_split.c +++ b/examples/sview_split.c @@ -4,11 +4,13 @@ int main() { // No memory allocations or string length calculations! const csview date = c_sv("2021/03/12"); - const csview year = csview_first_token(date, c_sv("/")); - const csview month = csview_next_token(date, c_sv("/"), year); - const csview day = csview_next_token(date, c_sv("/"), month); + size_t pos = 0; + const csview year = csview_token(date, c_sv("/"), &pos); + const csview month = csview_token(date, c_sv("/"), &pos); + const csview day = csview_token(date, c_sv("/"), &pos); - printf(c_svfmt ", " c_svfmt ", " c_svfmt "\n", c_svarg(year), c_svarg(month), c_svarg(day)); + printf(c_svfmt ", " c_svfmt ", " c_svfmt "\n", + c_svarg(year), c_svarg(month), c_svarg(day)); c_auto (cstr, y, m, d) { y = cstr_from_v(year), m = cstr_from_v(month), d = cstr_from_v(day); -- cgit v1.2.3