am,fix: printf cannot correctly handle trailing zeros
All checks were successful
Build abstract machine with nix / build-packages (abstract-machine) (push) Successful in 16s
Build abstract machine with nix / build-packages (nemu) (push) Successful in 7s
Build abstract machine with nix / build-packages (nemu-lib) (push) Successful in 7s
Build abstract machine with nix / build-packages (rv32Cross.abstract-machine) (push) Successful in 12s
Build npc tests / npc-build (flow) (push) Successful in 8s
Build npc tests / npc-build (flow-simlib) (push) Successful in 9s

This commit is contained in:
xinyangli 2024-08-15 17:38:12 +08:00
parent 3d64dbd200
commit 0e408882b2
Signed by: xin
SSH key fingerprint: SHA256:qZ/tzd8lYRtUFSrfBDBMcUqV4GHKxqeqRA3huItgvbk

View file

@ -123,13 +123,9 @@ void print_int_to_buf(char **buf, int *pos, int num, int width, char pad) {
width--;
}
if (reverse == 0) {
append_to_buffer(buf, pos, '0');
} else {
while (reverse != 0) {
append_to_buffer(buf, pos, '0' + (reverse % 10));
reverse /= 10;
}
for (int i = 0; i < count; i++) {
append_to_buffer(buf, pos, '0' + (reverse % 10));
reverse /= 10;
}
}