diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2023-09-18 22:57:27 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2023-09-18 22:57:27 -0400 |
commit | 2570eded660b769b0f49edb673346b28c6ca7c9b (patch) | |
tree | c88c156cd8702597f4115da8f000095ff096608f /tnslc/utils.tnsl | |
parent | 8b9b469242cb628fe469edaa4cc55bf952de178b (diff) |
stuff
Diffstat (limited to 'tnslc/utils.tnsl')
-rw-r--r-- | tnslc/utils.tnsl | 26 |
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 +;/ + |