20 static int skip_atoi(
const char **
s)
25 i = i * 10 + *((*s)++) -
'0';
37 #define __do_div(n, base) ({ \
39 __res = ((unsigned long) n) % (unsigned) base; \
40 n = ((unsigned long) n) / (unsigned) base; \
43 static char *
number(
char *
str,
long num,
int base,
int size,
int precision,
47 static const char digits[16] =
"0123456789ABCDEF";
55 locase = (type &
SMALL);
58 if (base < 2 || base > 36)
60 c = (type &
ZEROPAD) ?
'0' :
' ';
67 }
else if (type &
PLUS) {
70 }
else if (type &
SPACE) {
86 tmp[i++] = (digits[
__do_div(num, base)] | locase);
98 else if (base == 16) {
100 *str++ = (
'X' | locase);
106 while (i < precision--)
130 for (str = buf; *
fmt; ++
fmt) {
161 field_width = skip_atoi(&fmt);
162 else if (*fmt ==
'*') {
165 field_width =
va_arg(args,
int);
166 if (field_width < 0) {
167 field_width = -field_width;
177 precision = skip_atoi(&fmt);
178 else if (*fmt ==
'*') {
181 precision =
va_arg(args,
int);
189 if (*fmt ==
'h' || *fmt ==
'l' || *fmt ==
'L') {
200 while (--field_width > 0)
203 while (--field_width > 0)
212 while (len < field_width--)
214 for (i = 0; i < len; ++
i)
216 while (len < field_width--)
221 if (field_width == -1) {
222 field_width = 2 *
sizeof(
void *);
226 (
unsigned long)
va_arg(args,
void *), 16,
227 field_width, precision, flags);
231 if (qualifier ==
'l') {
269 if (qualifier ==
'l')
270 num =
va_arg(args,
unsigned long);
271 else if (qualifier ==
'h') {
275 }
else if (flags &
SIGN)
278 num =
va_arg(args,
unsigned int);
279 str =
number(str, num, base, field_width, precision, flags);
298 char printf_buf[1024];
303 printed =
vsprintf(printf_buf, fmt, args);