]> git.saurik.com Git - apple/libc.git/blame - stdio/FreeBSD/vasprintf.c.patch
Libc-763.11.tar.gz
[apple/libc.git] / stdio / FreeBSD / vasprintf.c.patch
CommitLineData
1f2f436a
A
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 @@
3d9156a7 4 #include <sys/cdefs.h>
1f2f436a 5 __FBSDID("$FreeBSD: src/lib/libc/stdio/vasprintf.c,v 1.19 2008/04/17 22:17:54 jhb Exp $");
3d9156a7
A
6
7+#include "xlocale_private.h"
8+
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <errno.h>
1f2f436a
A
12 #include "local.h"
13
14 int
15-vasprintf(str, fmt, ap)
3d9156a7 16+vasprintf_l(str, loc, fmt, ap)
1f2f436a 17 char **str;
3d9156a7 18+ locale_t loc;
1f2f436a
A
19 const char *fmt;
20 __va_list ap;
21 {
22 int ret;
23 FILE f;
24-
3d9156a7 25+ struct __sFILEX ext;
3d9156a7
A
26+ f._extra = &ext;
27+ INITEXTRA(&f);
1f2f436a
A
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);
3d9156a7
A
38+ ret = __vfprintf(&f, loc, fmt, ap);
39 if (ret < 0) {
40 free(f._bf._base);
41 *str = NULL;
1f2f436a
A
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+}