2018-12-19 18:01:53 +00:00
|
|
|
import err
|
2018-07-12 16:30:35 +00:00
|
|
|
|
2018-10-04 21:22:26 +00:00
|
|
|
#if ARCH_I80
|
2018-12-19 18:01:53 +00:00
|
|
|
import string_fastpointers
|
2018-10-04 21:22:26 +00:00
|
|
|
#else
|
2018-12-19 18:01:53 +00:00
|
|
|
import string_fastindices
|
|
|
|
#endif
|
|
|
|
|
2019-01-05 00:19:14 +00:00
|
|
|
void strzappend(pointer buffer, pointer str) {
|
|
|
|
strzcopy(buffer + strzlen(buffer), str)
|
|
|
|
}
|
|
|
|
void strzappendchar(pointer buffer, byte char) {
|
|
|
|
buffer += strzlen(buffer)
|
|
|
|
buffer[0] = char
|
|
|
|
buffer[1] = 0
|
|
|
|
}
|
2018-07-12 16:30:35 +00:00
|
|
|
|
2018-12-19 18:01:53 +00:00
|
|
|
word strz2word(pointer str) {
|
|
|
|
byte i
|
|
|
|
byte char
|
|
|
|
word next
|
|
|
|
word result
|
|
|
|
result = 0
|
|
|
|
i = 0
|
|
|
|
errno = err_ok
|
|
|
|
while true {
|
|
|
|
char = str[i]
|
2019-08-15 22:46:11 +00:00
|
|
|
if char == nullchar {
|
2018-12-19 18:01:53 +00:00
|
|
|
if i == 0 {
|
|
|
|
errno = err_numberformat
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
if '0' <= char <= '0' + 9 {
|
|
|
|
next = result * 10
|
|
|
|
next += char - '0'
|
|
|
|
if next < result {
|
|
|
|
errno = err_range
|
|
|
|
}
|
|
|
|
result = next
|
|
|
|
} else {
|
|
|
|
errno = err_numberformat
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
i += 1
|
2018-07-12 16:30:35 +00:00
|
|
|
}
|
2018-10-04 21:22:26 +00:00
|
|
|
}
|