From 5bdf96234a388cbd3854747b0667620ebb60ccdf Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 18 Oct 2025 19:02:07 -0400 Subject: Improved CLI parsing and add CString.join() --- src/stdlib/c_strings.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/stdlib/c_strings.c') diff --git a/src/stdlib/c_strings.c b/src/stdlib/c_strings.c index 54ea1e40..57960577 100644 --- a/src/stdlib/c_strings.c +++ b/src/stdlib/c_strings.c @@ -65,6 +65,17 @@ static void CString$deserialize(FILE *in, void *out, List_t *pointers, const Typ *(const char **)out = str; } +public +const char *CString$join(const char *glue, List_t strings) { + Text_t ret = EMPTY_TEXT; + Text_t glue_text = Text$from_str(glue); + for (int64_t i = 0; i < (int64_t)strings.length; i++) { + if (i > 0) ret = Texts(ret, glue_text); + ret = Texts(ret, Text$from_str(*(const char **)(strings.data + i * strings.stride))); + } + return Text$as_c_string(ret); +} + public const TypeInfo_t CString$info = { .size = sizeof(const char *), -- cgit v1.2.3