From 34a5e136b6c79092eee73857bbad25892fe8047a Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Wed, 7 May 2025 16:54:18 -0400 Subject: str: Add str_tok() Signed-off-by: Andrew Opalach --- include/al/str.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/al/str.h b/include/al/str.h index a3ddd8e..10f30ea 100644 --- a/include/al/str.h +++ b/include/al/str.h @@ -158,6 +158,16 @@ static inline u32 al_str_find_str(str *s, str *c) return AL_STR_NPOS; } +static inline bool al_str_tok(str *result, char delim) +{ + u32 index = al_str_find(result, delim); + if (index == AL_STR_NPOS) { + return false; + } + *result = al_str_substr(result, index + 1, result->length); + return true; +} + static inline u32 al_str_hash(str *s) { u32 hash = 5381; -- cgit v1.2.3-101-g0448