147 {
148 for (; *format != '\0'; format++) {
150
151
152 if (*format != '%') {
153 output (*format, aux);
154 continue;
155 }
156 format++;
157
158
159 if (*format == '%') {
160 output ('%', aux);
161 continue;
162 }
163
164
166
167
168 switch (*format) {
169 case 'd':
170 case 'i':
171 {
172
174
175 switch (c.type) {
177 value = (
signed char)
va_arg (args,
int);
178 break;
180 value = (short)
va_arg (args,
int);
181 break;
183 value =
va_arg (args,
int);
184 break;
187 break;
189 value =
va_arg (args,
long);
190 break;
192 value =
va_arg (args,
long long);
193 break;
196 break;
198 value =
va_arg (args,
size_t);
201 break;
202 default:
204 }
205
207 true, value < 0, &
base_d, &c, output, aux);
208 }
209 break;
210
211 case 'o':
212 case 'u':
213 case 'x':
214 case 'X':
215 {
216
219
220 switch (c.type) {
221 case CHAR:
222 value = (
unsigned char)
va_arg (args,
unsigned);
223 break;
224 case SHORT:
225 value = (
unsigned short)
va_arg (args,
unsigned);
226 break;
227 case INT:
228 value =
va_arg (args,
unsigned);
229 break;
230 case INTMAX:
232 break;
233 case LONG:
234 value =
va_arg (args,
unsigned long);
235 break;
236 case LONGLONG:
237 value =
va_arg (args,
unsigned long long);
238 break;
239 case PTRDIFFT:
241#if UINTMAX_MAX != PTRDIFF_MAX
243#endif
244 break;
245 case SIZET:
246 value =
va_arg (args,
size_t);
247 break;
248 default:
250 }
251
252 switch (*format) {
253 case 'o': b = &
base_o;
break;
254 case 'u': b = &
base_d;
break;
255 case 'x': b = &
base_x;
break;
256 case 'X': b = &
base_X;
break;
258 }
259
261 }
262 break;
263
264 case 'c':
265 {
266
267 char ch =
va_arg (args,
int);
269 }
270 break;
271
272 case 's':
273 {
274
275 const char *
s =
va_arg (args,
char *);
278
279
280
281
283 }
284 break;
285
286 case 'p':
287 {
288
289
290 void *p =
va_arg (args,
void *);
291
292 c.flags = POUND;
294 &
base_x, &c, output, aux);
295 }
296 break;
297
298 case 'f':
299 case 'e':
300 case 'E':
301 case 'g':
302 case 'G':
303 case 'n':
304
305
306 __printf (
"<<no %%%c in kernel>>", output, aux, *format);
307 break;
308
309 default:
310 __printf (
"<<no %%%c conversion>>", output, aux, *format);
311 break;
312 }
313 }
314}
#define NOT_REACHED()
Definition: debug.h:34
static uint8_t s[256]
Definition: random.c:17
#define va_arg(LIST, TYPE)
Definition: stdarg.h:11
#define NULL
Definition: stddef.h:4
__PTRDIFF_TYPE__ ptrdiff_t
Definition: stddef.h:9
int64_t intmax_t
Definition: stdint.h:39
uint64_t uintmax_t
Definition: stdint.h:43
#define SIZE_MAX
Definition: stdint.h:49
uint64_t uintptr_t
Definition: stdint.h:36
#define PTRDIFF_MAX
Definition: stdint.h:47
static const struct integer_base base_x
Definition: stdio.c:129
void __printf(const char *format, void(*output)(char, void *), void *aux,...)
Definition: stdio.c:538
static const struct integer_base base_o
Definition: stdio.c:128
static void format_integer(uintmax_t value, bool is_signed, bool negative, const struct integer_base *, const struct printf_conversion *, void(*output)(char, void *), void *aux)
Definition: stdio.c:437
static const char * parse_conversion(const char *format, struct printf_conversion *, va_list *)
Definition: stdio.c:321
static void format_string(const char *string, int length, struct printf_conversion *, void(*output)(char, void *), void *aux)
Definition: stdio.c:523
static const struct integer_base base_X
Definition: stdio.c:130
static const struct integer_base base_d
Definition: stdio.c:127
size_t strnlen(const char *, size_t)
Definition: string.c:284
@ INTMAX
Definition: stdio.c:112
@ LONGLONG
Definition: stdio.c:114
@ CHAR
Definition: stdio.c:109
@ SIZET
Definition: stdio.c:116
@ LONG
Definition: stdio.c:113
@ SHORT
Definition: stdio.c:110
@ INT
Definition: stdio.c:111
@ PTRDIFFT
Definition: stdio.c:115