]> git.saurik.com Git - apple/libc.git/blob - stdio/FreeBSD/vasprintf.c.patch
Libc-763.11.tar.gz
[apple/libc.git] / stdio / FreeBSD / vasprintf.c.patch
1 --- vasprintf.c.orig 2009-11-30 16:15:30.000000000 -0800
2 +++ vasprintf.c 2009-12-03 15:19:16.000000000 -0800
3 @@ -30,20 +30,27 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/stdio/vasprintf.c,v 1.19 2008/04/17 22:17:54 jhb Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <errno.h>
12 #include "local.h"
13
14 int
15 -vasprintf(str, fmt, ap)
16 +vasprintf_l(str, loc, fmt, ap)
17 char **str;
18 + locale_t loc;
19 const char *fmt;
20 __va_list ap;
21 {
22 int ret;
23 FILE f;
24 -
25 + struct __sFILEX ext;
26 + f._extra = &ext;
27 + INITEXTRA(&f);
28 +
29 + NORMALIZE_LOCALE(loc);
30 f._file = -1;
31 f._flags = __SWR | __SSTR | __SALC;
32 f._bf._base = f._p = (unsigned char *)malloc(128);
33 @@ -55,7 +62,7 @@ vasprintf(str, fmt, ap)
34 f._bf._size = f._w = 127; /* Leave room for the NUL */
35 f._orientation = 0;
36 memset(&f._mbstate, 0, sizeof(mbstate_t));
37 - ret = __vfprintf(&f, fmt, ap);
38 + ret = __vfprintf(&f, loc, fmt, ap);
39 if (ret < 0) {
40 free(f._bf._base);
41 *str = NULL;
42 @@ -66,3 +73,12 @@ vasprintf(str, fmt, ap)
43 *str = (char *)f._bf._base;
44 return (ret);
45 }
46 +
47 +int
48 +vasprintf(str, fmt, ap)
49 + char **str;
50 + const char *fmt;
51 + __va_list ap;
52 +{
53 + return vasprintf_l(str, __current_locale(), fmt, ap);
54 +}