blob: 9fe113ad4a21723b6d592c58c49a2def1ae8428f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/; 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) [bool]
int sl = cstr_len(cstr)
int cl = len csv
int seen = 0
/; loop (int i = 0; i < cl) [i++]
/; if (seen < 0)
/; if (csv{i} == ',')
seen = 0
;/
continue
;/
/; if (seen !< sl)
/; if (csv{i} == ',')
return true
;/
seen = -1
;; else if (cstr{seen} == csv{i})
csv_pr{0} = cstr{seen}
# _printf(~csv_pr{0})
seen++
;; else if (csv{i} == ',')
seen = 0
;; else
seen = -1
;/
;/
return seen == sl
;/
/; cstr_copy (~uint8 from, to)
int ln = cstr_len(from)
/; loop (int i = 0; i !> ln) [i++]
to{i} = from{i}
;/
;/
/; contains_char ({}uint8 arr, uint8 c) [bool]
/; loop (int i = 0; i < len arr) [i++]
/; if (arr{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)
;/
;/
|