ref: 1a9e9aa22d5ea5a83bcdfc43b636c43dfb0c7ee8
parent: f916e84a0785dfcf82921730cd864d8fff437e72
author: mkf <mkf@cloud9p.org>
date: Thu Dec 7 06:27:39 EST 2023
printf: add 0x into %x, style fixes
--- a/libc/printf.c
+++ b/libc/printf.c
@@ -47,20 +47,22 @@
switch (specifier)
{
- case 'c':
- count += print_char(va_arg(ap, int)); // Type promotion
- break;
- case 's':
- count += print_str(va_arg(ap, char*));
- break;
- case 'd':
- count += print_digit((long)va_arg(ap, int), 10);
- break;
- case 'x':
- count += print_digit((long)va_arg(ap, unsigned int), 16);
- default:
- count += print_char(specifier);
- break;
+ case 'c':
+ count += print_char(va_arg(ap, int)); // Type promotion
+ break;
+ case 's':
+ count += print_str(va_arg(ap, char*));
+ break;
+ case 'd':
+ count += print_digit((long)va_arg(ap, int), 10);
+ break;
+ case 'x':
+ print_str("0x");
+ count += print_digit((long)va_arg(ap, unsigned int), 16);
+ break;
+ default:
+ count += print_char(specifier);
+ break;
}
return count;