threads::shared disabling
[p5sagit/p5-mst-13.2.git] / regexec.c
index 4bddbf3..51b55f6 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -980,31 +980,28 @@ S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, char *strend, char *sta
                U8 tmpbuf [UTF8_MAXLEN+1];
                U8 foldbuf[UTF8_MAXLEN_FOLD+1];
                STRLEN len, foldlen;
-               STRLEN mlen = utf8_length((U8*)m, (U8*)(m + ln));
-               U8* l; /* The last byte of the last character in s. */
+               char* se;
                
                if (c1 == c2) {
                    while (s <= e) {
                        c = utf8_to_uvchr((U8*)s, &len);
-                       l = utf8_hop((U8*)s, mlen);
                        if ( c == c1
                             && (ln == len ||
-                                !ibcmp_utf8(s, do_utf8,
-                                            l - (U8*)s,
-                                            m, UTF, ln))
+                                ((se = e + 1) &&
+                                 !ibcmp_utf8(s, &se, 0,  do_utf8,
+                                             m, 0  , ln, UTF)))
                             && (norun || regtry(prog, s)) )
                            goto got_it;
                        else {
                             uvchr_to_utf8(tmpbuf, c);
                             f = to_utf8_fold(tmpbuf, foldbuf, &foldlen);
-                            l = utf8_hop(foldbuf, mlen);
                             if ( f != c
                                  && (f == c1 || f == c2)
                                  && (ln == foldlen ||
                                      !ibcmp_utf8((char *)foldbuf,
-                                                 do_utf8,
-                                                 l - foldbuf,
-                                                 m, UTF, ln))
+                                                 0, foldlen, do_utf8,
+                                                 m,
+                                                 0, ln,      UTF))
                                  && (norun || regtry(prog, s)) )
                                  goto got_it;
                        }
@@ -1014,7 +1011,6 @@ S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, char *strend, char *sta
                else {
                    while (s <= e) {
                        c = utf8_to_uvchr((U8*)s, &len);
-                       l = utf8_hop((U8*)s, mlen);
 
                        /* Handle some of the three Greek sigmas cases.
                          * Note that not all the possible combinations
@@ -1029,22 +1025,21 @@ S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, char *strend, char *sta
 
                        if ( (c == c1 || c == c2)
                             && (ln == len ||
-                                !ibcmp_utf8(s, do_utf8,
-                                            l - (U8*)s,
-                                            m, UTF, ln))
+                                ((se = e + 1) &&
+                                 !ibcmp_utf8(s, &se, 0,  do_utf8,
+                                             m, 0,   ln, UTF)))
                             && (norun || regtry(prog, s)) )
                            goto got_it;
                        else {
                             uvchr_to_utf8(tmpbuf, c);
                             f = to_utf8_fold(tmpbuf, foldbuf, &foldlen);
-                            l = utf8_hop(foldbuf, mlen);
                             if ( f != c
                                  && (f == c1 || f == c2)
                                  && (ln == foldlen ||
                                      !ibcmp_utf8((char *)foldbuf,
-                                                 do_utf8,
-                                                 l - foldbuf,
-                                                 m, UTF, ln))
+                                                 0, foldlen, do_utf8,
+                                                 m,
+                                                 0, ln,      UTF))
                                  && (norun || regtry(prog, s)) )
                                  goto got_it;
                        }
@@ -2346,26 +2341,17 @@ S_regmatch(pTHX_ regnode *prog)
            s = STRING(scan);
            ln = STR_LEN(scan);
 
-           {
+           if (do_utf8 || UTF) {
+             /* Either target or the pattern are utf8. */
                char *l = locinput;
-               char *e = s + ln;
+               char *e = PL_regeol;
 
-               if (do_utf8 || UTF) {
-                    /* Either target or the pattern are utf8. */
-                    STRLEN slen = utf8_length((U8*)s, (U8*)e);
-                    char *lend = (char *)utf8_hop((U8*)l, slen);
-
-                    if (ibcmp_utf8(s, TRUE, e - s,
-                                   l, TRUE, lend - l))
-                         sayNO;
-                    else {
-                         l = lend;
-                         s = e;
-                    }
-                    locinput = l;
-                    nextchr = UCHARAT(locinput);
-                    break;
-               }
+               if (ibcmp_utf8(s, 0,  ln, do_utf8,
+                              l, &e, 0,  UTF))
+                    sayNO;
+               locinput = e;
+               nextchr = UCHARAT(locinput);
+               break;
            }
 
            /* Neither the target and the pattern are utf8. */
@@ -4183,14 +4169,14 @@ S_reginclass(pTHX_ register regnode *n, register U8* p, register bool do_utf8)
                if (swash_fetch(sw, p, do_utf8))
                    match = TRUE;
                else if (flags & ANYOF_FOLD) {
-                   STRLEN ulen;
-                   U8 tmpbuf[UTF8_MAXLEN_FOLD+1];
+                   U8 foldbuf[UTF8_MAXLEN_FOLD+1];
+                   STRLEN foldlen;
 
-                   to_utf8_fold(p, tmpbuf, &ulen);
-                   if (swash_fetch(sw, tmpbuf, do_utf8))
+                   to_utf8_fold(p, foldbuf, &foldlen);
+                   if (swash_fetch(sw, foldbuf, do_utf8))
                        match = TRUE;
-                   to_utf8_upper(p, tmpbuf, &ulen);
-                   if (swash_fetch(sw, tmpbuf, do_utf8))
+                   to_utf8_upper(p, foldbuf, &foldlen);
+                   if (swash_fetch(sw, foldbuf, do_utf8))
                        match = TRUE;
                }
            }