lib/tiny-printf.c: Implement vprintf
Implement both printf and vprintf for a bit more flexibility, e.g. allows the panic() function to work with tiny-printf. Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
This commit is contained in:
parent
4363de63a8
commit
962a43cc96
|
@ -40,17 +40,14 @@ static void div_out(unsigned int *num, unsigned int div)
|
||||||
out_dgt(dgt);
|
out_dgt(dgt);
|
||||||
}
|
}
|
||||||
|
|
||||||
int printf(const char *fmt, ...)
|
int vprintf(const char *fmt, va_list va)
|
||||||
{
|
{
|
||||||
va_list va;
|
|
||||||
char ch;
|
char ch;
|
||||||
char *p;
|
char *p;
|
||||||
unsigned int num;
|
unsigned int num;
|
||||||
char buf[12];
|
char buf[12];
|
||||||
unsigned int div;
|
unsigned int div;
|
||||||
|
|
||||||
va_start(va, fmt);
|
|
||||||
|
|
||||||
while ((ch = *(fmt++))) {
|
while ((ch = *(fmt++))) {
|
||||||
if (ch != '%') {
|
if (ch != '%') {
|
||||||
putc(ch);
|
putc(ch);
|
||||||
|
@ -117,6 +114,17 @@ int printf(const char *fmt, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
abort:
|
abort:
|
||||||
va_end(va);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int printf(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
va_start(va, fmt);
|
||||||
|
ret = vprintf(fmt, va);
|
||||||
|
va_end(va);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue