blob: 1ce6bd1e88df5af06acd52be5f7ec50019dc9a64 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/*
* linux/lib/vsprintf.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*/
/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
/*
* Wirzenius wrote this portably, Torvalds fucked it up :-)
*/
#include <stdarg.h>
#include <string.h>
int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args);
/* FIXME this global makes vsprintf non-reentrant */
static char *str_buf;
static void str_tx_byte(unsigned char byte)
{
*str_buf = byte;
str_buf++;
}
int vsprintf(char * buf, const char *fmt, va_list args)
{
int i;
str_buf = buf;
i = vtxprintf(str_tx_byte, fmt, args);
/* maeder/Ispiri -- The null termination was missing a deference */
/* and was just zeroing out the pointer instead */
*str_buf = '\0';
return i;
}
int sprintf(char * buf, const char *fmt, ...)
{
va_list args;
int i;
va_start(args, fmt);
i=vsprintf(buf,fmt,args);
va_end(args);
return i;
}
|