mirror of
https://github.com/KarolS/millfork.git
synced 2024-11-06 22:05:01 +00:00
48 lines
925 B
Plaintext
48 lines
925 B
Plaintext
import err
|
|
|
|
#if ARCH_I80
|
|
import string_fastpointers
|
|
#else
|
|
import string_fastindices
|
|
#endif
|
|
|
|
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
|
|
}
|
|
|
|
word strz2word(pointer str) {
|
|
byte i
|
|
byte char
|
|
word next
|
|
word result
|
|
result = 0
|
|
i = 0
|
|
errno = err_ok
|
|
while true {
|
|
char = str[i]
|
|
if char == 0 {
|
|
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
|
|
}
|
|
}
|