summaryrefslogtreecommitdiff
path: root/tnslc/utils.tnsl
diff options
context:
space:
mode:
Diffstat (limited to 'tnslc/utils.tnsl')
-rw-r--r--tnslc/utils.tnsl122
1 files changed, 0 insertions, 122 deletions
diff --git a/tnslc/utils.tnsl b/tnslc/utils.tnsl
deleted file mode 100644
index a1c5884..0000000
--- a/tnslc/utils.tnsl
+++ /dev/null
@@ -1,122 +0,0 @@
-/; cstr_len (~uint8 cstr) [int]
- int i = 0
- /; loop (cstr{i} !== 0) [i++] ;/
- return i
-;/
-
-/; cstr_eq (~uint8 a, b) [bool]
- int ln = cstr_len(a)
- /; if (ln !== cstr_len(b))
- return false
- ;/
-
- /; loop (int i = 0; i < ln) [i++]
- /; if (a{i} !== b{i})
- return false
- ;/
- ;/
-
- return true
-;/
-
-{}uint8 csv_pr = "\0\0"
-
-/; in_csv ({}uint8 csv, ~uint8 cstr) [int]
- int sl = cstr_len(cstr)
- int cl = len csv
- int seen = 0
- int idx = 0
-
- /; loop (int i = 0; i < cl) [i++]
-
- /; if (seen < 0)
- /; if (csv{i} == ',')
- seen = 0
- idx++
- ;/
- continue
- ;/
-
- /; if (seen !< sl)
- /; if (csv{i} == ',')
- return idx
- ;/
- seen = -1
- ;; else if (cstr{seen} == csv{i})
- csv_pr{0} = cstr{seen}
- # _printf(~csv_pr{0})
- seen++
- ;; else if (csv{i} == ',')
- idx++
- seen = 0
- ;; else
- seen = -1
- ;/
- ;/
-
- /; if (seen == sl)
- return idx
- ;/
-
- return 0 - 1
-;/
-
-/; cstr_copy (~uint8 from, to)
- int ln = cstr_len(from)
-
- /; loop (int i = 0; i !> ln) [i++]
- to{i} = from{i}
- ;/
-;/
-
-/; 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)
- return true
- ;/
- ;/
- return false
-;/
-
-/; cstr_contains (~uint8 cstr, uint8 c) [bool]
- int j = cstr_len(cstr)
- /; loop (int i = 0; i < j) [i++]
- /; if (cstr{i} == c)
- return true
- ;/
- ;/
- return false
-;/
-
-/; write_to_file(~void file, ~uint8 string)
- int ln = cstr_len(string)
- /; loop (int i = 0; i < ln) [i++]
- _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
-;/
-