Removed log from the standard library
This commit is contained in:
25
lib/io/fmt.q
Normal file
25
lib/io/fmt.q
Normal file
@ -0,0 +1,25 @@
|
||||
import mem
|
||||
import sys
|
||||
|
||||
number(x int) {
|
||||
buffer := mem.alloc(20)
|
||||
address, count := itoa(x, buffer)
|
||||
sys.write(1, address, count)
|
||||
mem.free(buffer)
|
||||
}
|
||||
|
||||
itoa(x int, buffer []byte) -> (*byte, int) {
|
||||
end := buffer + len(buffer)
|
||||
tmp := end
|
||||
digit := 0
|
||||
|
||||
loop {
|
||||
x, digit = x / 10
|
||||
tmp -= 1
|
||||
tmp[0] = '0' + digit
|
||||
|
||||
if x == 0 {
|
||||
return tmp, end - tmp
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user