]> git.saurik.com Git - apple/libc.git/blob - regex/FreeBSD/regexec.c.patch
409ee1709e8cba4b0ae5bec91ac41fd2e07e8a6a
[apple/libc.git] / regex / FreeBSD / regexec.c.patch
1 --- regexec.c.bsdnew 2009-11-11 11:29:04.000000000 -0800
2 +++ regexec.c 2009-11-11 12:21:46.000000000 -0800
3 @@ -39,6 +39,8 @@ static char sccsid[] = "@(#)regexec.c 8.
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/regex/regexec.c,v 1.8 2007/06/11 03:05:54 delphij Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 /*
10 * the outer shell of regexec()
11 *
12 @@ -62,12 +64,12 @@ __FBSDID("$FreeBSD: src/lib/libc/regex/r
13 static int nope __unused = 0; /* for use in asserts; shuts lint up */
14
15 static __inline size_t
16 -xmbrtowc(wint_t *wi, const char *s, size_t n, mbstate_t *mbs, wint_t dummy)
17 +xmbrtowc(wint_t *wi, const char *s, size_t n, mbstate_t *mbs, wint_t dummy, locale_t loc)
18 {
19 size_t nr;
20 wchar_t wc;
21
22 - nr = mbrtowc(&wc, s, n, mbs);
23 + nr = mbrtowc_l(&wc, s, n, mbs, loc);
24 if (wi != NULL)
25 *wi = wc;
26 if (nr == 0)
27 @@ -86,7 +88,8 @@ xmbrtowc_dummy(wint_t *wi,
28 const char *s,
29 size_t n __unused,
30 mbstate_t *mbs __unused,
31 - wint_t dummy __unused)
32 + wint_t dummy __unused,
33 + locale_t loc __unused)
34 {
35
36 if (wi != NULL)
37 @@ -176,6 +179,8 @@ xmbrtowc_dummy(wint_t *wi,
38 /* function names */
39 #define LNAMES /* flag */
40
41 +#undef __FBSDID
42 +#define __FBSDID(x)
43 #include "engine.c"
44
45 /* multibyte character & large states version */
46 @@ -224,7 +229,8 @@ regexec(const regex_t * __restrict preg,
47 return(REG_BADPAT);
48 eflags = GOODFLAGS(eflags);
49
50 - if (MB_CUR_MAX > 1)
51 + g->loc = __current_locale();
52 + if (MB_CUR_MAX_L(g->loc) > 1)
53 return(mmatcher(g, (char *)string, nmatch, pmatch, eflags));
54 else if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags&REG_LARGE))
55 return(smatcher(g, (char *)string, nmatch, pmatch, eflags));