]> git.saurik.com Git - apple/libc.git/blob - stdio/FreeBSD/ungetwc.c.patch
Libc-594.9.5.tar.gz
[apple/libc.git] / stdio / FreeBSD / ungetwc.c.patch
1 --- ungetwc.c.orig 2004-11-25 11:38:35.000000000 -0800
2 +++ ungetwc.c 2005-02-23 17:38:14.000000000 -0800
3 @@ -27,6 +27,8 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/stdio/ungetwc.c,v 1.9 2004/07/20 08:27:27 tjr Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 #include "namespace.h"
10 #include <errno.h>
11 #include <stdio.h>
12 @@ -41,14 +43,14 @@
13 * Non-MT-safe version.
14 */
15 wint_t
16 -__ungetwc(wint_t wc, FILE *fp)
17 +__ungetwc(wint_t wc, FILE *fp, locale_t loc)
18 {
19 char buf[MB_LEN_MAX];
20 size_t len;
21
22 if (wc == WEOF)
23 return (WEOF);
24 - if ((len = __wcrtomb(buf, wc, &fp->_extra->mbstate)) == (size_t)-1) {
25 + if ((len = loc->__lc_ctype->__wcrtomb(buf, wc, &fp->_extra->mbstate, loc)) == (size_t)-1) {
26 fp->_flags |= __SERR;
27 return (WEOF);
28 }
29 @@ -69,7 +71,21 @@
30
31 FLOCKFILE(fp);
32 ORIENT(fp, 1);
33 - r = __ungetwc(wc, fp);
34 + r = __ungetwc(wc, fp, __current_locale());
35 + FUNLOCKFILE(fp);
36 +
37 + return (r);
38 +}
39 +
40 +wint_t
41 +ungetwc_l(wint_t wc, FILE *fp, locale_t loc)
42 +{
43 + wint_t r;
44 +
45 + NORMALIZE_LOCALE(loc);
46 + FLOCKFILE(fp);
47 + ORIENT(fp, 1);
48 + r = __ungetwc(wc, fp, loc);
49 FUNLOCKFILE(fp);
50
51 return (r);