From af1bd79fd91d1a1efde3cf084643f065c61d330a Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 15 Nov 2025 14:10:28 -0500 Subject: Make EMPTY_TEXT into a macro --- src/stdlib/text.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/stdlib/text.h') diff --git a/src/stdlib/text.h b/src/stdlib/text.h index 821325a9..12b4bc20 100644 --- a/src/stdlib/text.h +++ b/src/stdlib/text.h @@ -27,6 +27,8 @@ typedef struct { #define Text(str) ((Text_t){.length = sizeof(str) - 1, .tag = TEXT_ASCII, .ascii = "" str}) +#define EMPTY_TEXT ((Text_t){.length = 0, .tag = TEXT_ASCII, .ascii = 0}) + static inline Text_t Text_from_str_literal(const char *str) { return (Text_t){.length = strlen(str), .tag = TEXT_ASCII, .ascii = str}; } @@ -121,7 +123,6 @@ MACROLIKE int32_t Text$get_grapheme(Text_t text, int64_t index) { } extern const TypeInfo_t Text$info; -extern Text_t EMPTY_TEXT; #define Text$metamethods \ { \ -- cgit v1.2.3 From cb9d3b1a2c2c59c368f6121a16a9ab928b0ff951 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 23 Nov 2025 00:35:05 -0500 Subject: Added Text.find(text, target, start=1) --- src/stdlib/text.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/stdlib/text.h') diff --git a/src/stdlib/text.h b/src/stdlib/text.h index 12b4bc20..fba8b08f 100644 --- a/src/stdlib/text.h +++ b/src/stdlib/text.h @@ -84,6 +84,7 @@ PUREFUNC bool Text$starts_with(Text_t text, Text_t prefix, Text_t *remainder); PUREFUNC bool Text$ends_with(Text_t text, Text_t suffix, Text_t *remainder); Text_t Text$without_prefix(Text_t text, Text_t prefix); Text_t Text$without_suffix(Text_t text, Text_t suffix); +OptionalInt_t Text$find(Text_t text, Text_t target, Int_t start); Text_t Text$replace(Text_t text, Text_t target, Text_t replacement); Text_t Text$translate(Text_t text, Table_t translations); PUREFUNC bool Text$has(Text_t text, Text_t target); -- cgit v1.2.3 From 4c5d15115d2d6c08c080d7d4a39efe039658d616 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 7 Dec 2025 22:57:28 -0500 Subject: Add comments --- src/stdlib/text.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/stdlib/text.h') diff --git a/src/stdlib/text.h b/src/stdlib/text.h index fba8b08f..9ad7441c 100644 --- a/src/stdlib/text.h +++ b/src/stdlib/text.h @@ -50,6 +50,7 @@ static inline Text_t Text_from_text(Text_t t) { return t; } Text_t Text$_concat(int n, Text_t items[n]); #define Text$concat(...) Text$_concat(sizeof((Text_t[]){__VA_ARGS__}) / sizeof(Text_t), (Text_t[]){__VA_ARGS__}) #define Texts(...) Text$concat(MAP_LIST(convert_to_text, __VA_ARGS__)) +// This function is defined as an extern in `src/stdlib/print.h` // int Text$print(FILE *stream, Text_t t); Text_t Text$slice(Text_t text, Int_t first_int, Int_t last_int); Text_t Text$from(Text_t text, Int_t first); -- cgit v1.2.3