]> git.saurik.com Git - apple/libc.git/blob - regex/FreeBSD/regexec.c.patch
c6943c3c9a5449db15743f0a147ba7a502bab59e
[apple/libc.git] / regex / FreeBSD / regexec.c.patch
1 --- regexec.c.orig 2004-11-25 11:38:33.000000000 -0800
2 +++ regexec.c 2005-02-24 14:20:50.000000000 -0800
3 @@ -43,6 +43,8 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/regex/regexec.c,v 1.6 2004/07/12 07:35:59 tjr Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 /*
10 * the outer shell of regexec()
11 *
12 @@ -66,17 +68,18 @@
13 static int nope __unused = 0; /* for use in asserts; shuts lint up */
14
15 static __inline size_t
16 -xmbrtowc(wi, s, n, mbs, dummy)
17 +xmbrtowc(wi, s, n, mbs, dummy, loc)
18 wint_t *wi;
19 const char *s;
20 size_t n;
21 mbstate_t *mbs;
22 wint_t dummy;
23 +locale_t loc;
24 {
25 size_t nr;
26 wchar_t wc;
27
28 - nr = mbrtowc(&wc, s, n, mbs);
29 + nr = mbrtowc_l(&wc, s, n, mbs, loc);
30 if (wi != NULL)
31 *wi = wc;
32 if (nr == 0)
33 @@ -91,12 +94,13 @@
34 }
35
36 static __inline size_t
37 -xmbrtowc_dummy(wi, s, n, mbs, dummy)
38 +xmbrtowc_dummy(wi, s, n, mbs, dummy, loc)
39 wint_t *wi;
40 const char *s;
41 size_t n __unused;
42 mbstate_t *mbs __unused;
43 wint_t dummy __unused;
44 +locale_t loc;
45 {
46
47 if (wi != NULL)
48 @@ -186,6 +190,8 @@
49 /* function names */
50 #define LNAMES /* flag */
51
52 +#undef __FBSDID
53 +#define __FBSDID(x)
54 #include "engine.c"
55
56 /* multibyte character & large states version */
57 @@ -235,7 +241,8 @@
58 return(REG_BADPAT);
59 eflags = GOODFLAGS(eflags);
60
61 - if (MB_CUR_MAX > 1)
62 + g->loc = __current_locale();
63 + if (MB_CUR_MAX_L(g->loc) > 1)
64 return(mmatcher(g, (char *)string, nmatch, pmatch, eflags));
65 else if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags&REG_LARGE))
66 return(smatcher(g, (char *)string, nmatch, pmatch, eflags));