Browse Source

Fix the "printf" bug

Before: The printf can't support i% format printing.
	Now: The printf can support i% format printing.
	Test: In the pmon, calling printf("%i", (int)b), you can observe whether successfully printed.

	Targets: all
master
meiwenbin 13 years ago
committed by wanghongmei
parent
commit
f04b744169
  1. 8
      lib/libc/vsprintf.c

8
lib/libc/vsprintf.c

@ -62,7 +62,7 @@ vsprintf (char *d, const char *s, va_list ap)
fmt = FMT_RJUST; fmt = FMT_RJUST;
width = trunc = haddot = longlong = 0; width = trunc = haddot = longlong = 0;
for (; *s; s++) { for (; *s; s++) {
if (strchr ("dobpxXulscefg%", *s)) if (strchr ("diobpxXulscefg%", *s))
break; break;
else if (*s == '-') else if (*s == '-')
fmt = FMT_LJUST; fmt = FMT_LJUST;
@ -109,9 +109,9 @@ vsprintf (char *d, const char *s, va_list ap)
++s; ++s;
} }
} }
if (strchr ("dobpxXu", *s)) { if (strchr ("diobpxXu", *s)) {
if (*s == 'd') if ((*s == 'd') || (*s == 'i'))
base = -10; base = -10;
else if (*s == 'u') else if (*s == 'u')
base = 10; base = 10;
else if (*s == 'x' || *s == 'X') else if (*s == 'x' || *s == 'X')

Loading…
Cancel
Save