summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-05-07 16:54:18 -0400
committerAndrew Opalach <andrew@akon.city> 2025-05-07 16:54:18 -0400
commit34a5e136b6c79092eee73857bbad25892fe8047a (patch)
treed823061c04ccc0fdd3c4eac59f1bcb279f57c6fa /include
parentfddfc749911bb7be58678976a526bd6d3383f08f (diff)
downloadlibalabaster-34a5e136b6c79092eee73857bbad25892fe8047a.tar.gz
libalabaster-34a5e136b6c79092eee73857bbad25892fe8047a.tar.bz2
libalabaster-34a5e136b6c79092eee73857bbad25892fe8047a.zip
str: Add str_tok()
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'include')
-rw-r--r--include/al/str.h10
1 files changed, 10 insertions, 0 deletions
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;