2 * Tiny printf version for SPL
5 * http://www.sparetimelabs.com/printfrevisited/printfrevisited.php
7 * Copyright (C) 2004,2008 Kustaa Nyholm
9 * SPDX-License-Identifier: LGPL-2.1+
19 static void out(char c)
24 static void out_dgt(char dgt)
26 out(dgt + (dgt < 10 ? '0' : 'a' - 10));
30 static void div_out(unsigned int *num, unsigned int div)
32 unsigned char dgt = 0;
43 int vprintf(const char *fmt, va_list va)
51 while ((ch = *(fmt++))) {
64 if (ch >= '0' && ch <= '9') {
66 while (ch >= '0' && ch <= '9') {
67 w = (w * 10) + ch - '0';
80 num = va_arg(va, unsigned int);
81 if (ch == 'd' && (int)num < 0) {
85 for (div = 1000000000; div; div /= 10)
89 num = va_arg(va, unsigned int);
90 for (div = 0x10000000; div; div /= 0x10)
94 out((char)(va_arg(va, int)));
97 p = va_arg(va, char*);
107 while (*bf++ && w > 0)
110 putc(lz ? '0' : ' ');
120 int printf(const char *fmt, ...)
126 ret = vprintf(fmt, va);