libc: support not printing 0 digit with precision of 0
This commit is contained in:
parent
7be561c1b1
commit
cc8b933cda
11
apps/test-printf.c
Normal file
11
apps/test-printf.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
printf("%.3d\n", 42);
|
||||
printf("%.10d\n", 12345);
|
||||
printf("%.1d\n", 0);
|
||||
printf("%.0d\n", 0);
|
||||
printf("%.0d\n", 1);
|
||||
printf("%.0d\n", 123);
|
||||
return 0;
|
||||
}
|
@ -7,7 +7,9 @@ static void print_dec(unsigned int value, unsigned int width, char * buf, int *
|
||||
unsigned int i = 9;
|
||||
if (precision == -1) precision = 1;
|
||||
|
||||
if (value < 10UL) {
|
||||
if (value == 0) {
|
||||
n_width = 0;
|
||||
} else if (value < 10UL) {
|
||||
n_width = 1;
|
||||
} else if (value < 100UL) {
|
||||
n_width = 2;
|
||||
|
Loading…
Reference in New Issue
Block a user