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+
18 static unsigned int num;
22 static void out(char c)
27 static void out_dgt(char dgt)
29 out(dgt + (dgt < 10 ? '0' : (uc ? 'A' : 'a') - 10));
33 static void div_out(unsigned int div)
35 unsigned char dgt = 0;
37 num &= 0xffff; /* just for testing the code with 32 bit ints */
47 int printf(const char *fmt, ...)
55 while ((ch = *(fmt++))) {
68 if (ch >= '0' && ch <= '9') {
70 while (ch >= '0' && ch <= '9') {
71 w = (((w << 2) + w) << 1) + ch - '0';
84 num = va_arg(va, unsigned int);
85 if (ch == 'd' && (int)num < 0) {
98 num = va_arg(va, unsigned int);
105 out((char)(va_arg(va, int)));
108 p = va_arg(va, char*);
118 while (*bf++ && w > 0)
121 putc(lz ? '0' : ' ');