kocotian.pl

My personal webpage sources
git clone git://git.kocotian.pl/kocotian.pl.git
Log | Files | Refs | README | LICENSE

commit 01645891b31ea740b1510bd1d34f0b2328124b04
parent 98c7f1d4198ee8995ae8276957cee06cd253d310
Author: kocotian <kocotian@kocotian.pl>
Date:   Wed, 24 Mar 2021 10:38:50 +0100

Striden() function

Diffstat:
Mstr.h | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/str.h b/str.h @@ -31,6 +31,7 @@ typedef struct { static String toString(char *s); static int Strcmp(String a, String b); static ssize_t Strtok(String string, String *out, char c); +static String Striden(String string); static String Strtrim(String str); static String @@ -61,6 +62,18 @@ Strtok(String string, String *out, char c) } static String +Striden(String str) +{ + size_t i; + for (i = 0; ((str.data[i] >= 'a' && str.data[i] <= 'z') + || (str.data[i] >= 'A' && str.data[i] <= 'Z') + || (str.data[i] && str.data[i] >= '0' && str.data[i] <= '9')) + && (i < str.len); ++i); + str.len = i; + return str; +} + +static String Strtrim(String str) { size_t i = 0;