diff options
Diffstat (limited to 'tnslc/utils.tnsl')
-rw-r--r-- | tnslc/utils.tnsl | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tnslc/utils.tnsl b/tnslc/utils.tnsl index 54f01aa..91e8d2e 100644 --- a/tnslc/utils.tnsl +++ b/tnslc/utils.tnsl @@ -21,23 +21,25 @@ {}uint8 csv_pr = "\0\0" -/; in_csv ({}uint8 csv, ~uint8 cstr) [bool] +/; 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 true + return idx ;/ seen = -1 ;; else if (cstr{seen} == csv{i}) @@ -45,13 +47,18 @@ # _printf(~csv_pr{0}) seen++ ;; else if (csv{i} == ',') + idx++ seen = 0 ;; else seen = -1 ;/ ;/ - return seen == sl + /; if (seen == sl) + return idx + ;/ + + return 0 - 1 ;/ /; cstr_copy (~uint8 from, to) |