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 printf(const char *fmt, ...)
54 while ((ch = *(fmt++))) {
67 if (ch >= '0' && ch <= '9') {
69 while (ch >= '0' && ch <= '9') {
70 w = (w * 10) + ch - '0';
83 num = va_arg(va, unsigned int);
84 if (ch == 'd' && (int)num < 0) {
88 for (div = 1000000000; div; div /= 10)
92 num = va_arg(va, unsigned int);
93 for (div = 0x10000000; div; div /= 0x10)
97 out((char)(va_arg(va, int)));
100 p = va_arg(va, char*);
110 while (*bf++ && w > 0)
113 putc(lz ? '0' : ' ');