]>
Commit | Line | Data |
---|---|---|
3d9156a7 A |
1 | --- sprintf.c.orig 2003-05-20 15:22:43.000000000 -0700 |
2 | +++ sprintf.c 2005-02-23 16:40:52.000000000 -0800 | |
3 | @@ -40,6 +40,8 @@ | |
4 | #include <sys/cdefs.h> | |
5 | __FBSDID("$FreeBSD: src/lib/libc/stdio/sprintf.c,v 1.14 2002/09/06 11:23:55 tjr Exp $"); | |
6 | ||
7 | +#include "xlocale_private.h" | |
8 | + | |
9 | #include <stdio.h> | |
10 | #include <stdarg.h> | |
11 | #include <limits.h> | |
12 | @@ -60,7 +62,29 @@ | |
13 | f._extra = &ext; | |
14 | INITEXTRA(&f); | |
15 | va_start(ap, fmt); | |
16 | - ret = __vfprintf(&f, fmt, ap); | |
17 | + ret = __vfprintf(&f, __current_locale(), fmt, ap); | |
18 | + va_end(ap); | |
19 | + *f._p = 0; | |
20 | + return (ret); | |
21 | +} | |
22 | + | |
23 | +int | |
24 | +sprintf_l(char * __restrict str, locale_t loc, char const * __restrict fmt, ...) | |
25 | +{ | |
26 | + int ret; | |
27 | + va_list ap; | |
28 | + FILE f; | |
29 | + struct __sFILEX ext; | |
30 | + | |
31 | + NORMALIZE_LOCALE(loc); | |
32 | + f._file = -1; | |
33 | + f._flags = __SWR | __SSTR; | |
34 | + f._bf._base = f._p = (unsigned char *)str; | |
35 | + f._bf._size = f._w = INT_MAX; | |
36 | + f._extra = &ext; | |
37 | + INITEXTRA(&f); | |
38 | + va_start(ap, fmt); | |
39 | + ret = __vfprintf(&f, loc, fmt, ap); | |
40 | va_end(ap); | |
41 | *f._p = 0; | |
42 | return (ret); |