Coding-style and whitespace fixes (also to make the code more similar
[coreboot.git] / src / console / vsprintf.c
blob1ce6bd1e88df5af06acd52be5f7ec50019dc9a64
1 /*
2 * linux/lib/vsprintf.c
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
7 /* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
8 /*
9 * Wirzenius wrote this portably, Torvalds fucked it up :-)
11 #include <stdarg.h>
12 #include <string.h>
14 int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args);
16 /* FIXME this global makes vsprintf non-reentrant */
18 static char *str_buf;
19 static void str_tx_byte(unsigned char byte)
21 *str_buf = byte;
22 str_buf++;
25 int vsprintf(char * buf, const char *fmt, va_list args)
27 int i;
28 str_buf = buf;
29 i = vtxprintf(str_tx_byte, fmt, args);
30 /* maeder/Ispiri -- The null termination was missing a deference */
31 /* and was just zeroing out the pointer instead */
32 *str_buf = '\0';
33 return i;
36 int sprintf(char * buf, const char *fmt, ...)
38 va_list args;
39 int i;
41 va_start(args, fmt);
42 i=vsprintf(buf,fmt,args);
43 va_end(args);
44 return i;