summaryrefslogtreecommitdiff
path: root/tnslc/utils.tnsl
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2023-09-18 22:57:27 -0400
committerKyle Gunger <kgunger12@gmail.com>2023-09-18 22:57:27 -0400
commit2570eded660b769b0f49edb673346b28c6ca7c9b (patch)
treec88c156cd8702597f4115da8f000095ff096608f /tnslc/utils.tnsl
parent8b9b469242cb628fe469edaa4cc55bf952de178b (diff)
stuff
Diffstat (limited to 'tnslc/utils.tnsl')
-rw-r--r--tnslc/utils.tnsl26
1 files changed, 26 insertions, 0 deletions
diff --git a/tnslc/utils.tnsl b/tnslc/utils.tnsl
index 91e8d2e..a1c5884 100644
--- a/tnslc/utils.tnsl
+++ b/tnslc/utils.tnsl
@@ -69,6 +69,14 @@
;/
;/
+/; cstr_make_copy(~uint8 to_copy) [~uint8]
+ int l = cstr_len(to_copy)
+ ~uint8 out = _alloc(l + 1)
+ out{l} = 0
+ cstr_copy(to_copy, out)
+ return out
+;/
+
/; contains_char ({}uint8 arr, uint8 c) [bool]
/; loop (int i = 0; i < len arr) [i++]
/; if (arr{i} == c)
@@ -94,3 +102,21 @@
_write_byte(file, string + i)
;/
;/
+
+/; cstr_add(~uint8 a, b) [~uint8]
+ int al = cstr_len(a)
+ int bl = cstr_len(b)
+ ~uint8 out = _alloc(al + bl + 1)
+
+ /; loop (int i = 0; i < al) [i++]
+ out{i} = a{i}
+ ;/
+
+ /; loop (int i = 0, i < bl) [i++]
+ out{al + i} = b{i}
+ ;/
+
+ out{al + bl} = 0
+ return out
+;/
+