blob: 91e8d2e8df163efd22cb6dfedb427323555fca3c (
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/; 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}
;/
;/
/; 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)
;/
;/
|