blob: a65fddeb29408cece7ad5d124773502215907826 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include "xstdio.h"
#include "string.h"
#include "os.h"
// TODO: this comes from a header
#ident "$Revision: 1.23 $"
static void* proutSprintf(void* s, const char* buf, size_t n);
int sprintf(char* s, const char* fmt, ...) {
int ans;
va_list ap;
va_start(ap, fmt);
ans = _Printf(proutSprintf, s, fmt, ap);
if (ans >= 0) {
s[ans] = 0;
}
return ans;
}
static void* proutSprintf(void* s, const char* buf, size_t n) {
return (char*)memcpy(s, buf, n) + n;
}
|