Change 14001 by jhi@alpha on 2002/01/01 17:29:05

        Better support for multicharacter foldings.
        Now all but two of the CaseFold.txt cases work-- but
        only when the target string is single-character, some
        regex maloptimization probably at work.

Affected files ...

.... //depot/perl/regexec.c#233 edit

Differences ...

==== //depot/perl/regexec.c#233 (text) ====
Index: perl/regexec.c
--- perl/regexec.c.~1~  Tue Jan  1 10:45:06 2002
+++ perl/regexec.c      Tue Jan  1 10:45:06 2002
@@ -960,7 +960,7 @@
            c1 = *(U8*)m;
            c2 = PL_fold_locale[c1];
          do_exactf:
-           e = strend - ln;
+           e = do_utf8 ? s + ln - 1 : strend - ln;
 
            if (norun && e < s)
                e = s;                  /* Due to minlen logic of intuit() */
@@ -2406,31 +2406,37 @@
 
                if (do_utf8 && UTF) {
                     /* Both the target and the pattern are utf8. */
+                    U8 lfoldbuf[UTF8_MAXLEN_FOLD+1], *lf;
+                    U8 sfoldbuf[UTF8_MAXLEN_FOLD+1], *sf;
+                    STRLEN lfoldlen, sfoldlen;
+                    STRLEN llen = 0;
+                    STRLEN slen = 0;
+
                     while (s < e) {
-                         if (l >= PL_regeol)
-                              sayNO;
-                         if (UTF8SKIP(s) != UTF8SKIP(l) ||
-                             memNE(s, (char*)l, UTF8SKIP(s))) {
-                              U8 lfoldbuf[UTF8_MAXLEN_FOLD+1];
-                              STRLEN lfoldlen;
+                         /* Fold them and walk them characterwise.  */
 
-                              /* Try one of them folded. */
-
+                         if (llen == 0) {
                               to_utf8_fold((U8*)l, lfoldbuf, &lfoldlen);
-                              if (UTF8SKIP(s) != lfoldlen ||
-                                  memNE(s, (char*)lfoldbuf, lfoldlen)) {
-                                   U8 sfoldbuf[UTF8_MAXLEN_FOLD+1];
-                                   STRLEN sfoldlen;
+                              lf   = lfoldbuf;
+                              llen = lfoldlen;
+                         }
 
-                                   /* Try both of them folded. */
+                         if (slen == 0) {
+                              to_utf8_fold((U8*)s, sfoldbuf, &sfoldlen);
+                              sf   = sfoldbuf;
+                              slen = sfoldlen;
+                         }
 
-                                   to_utf8_fold((U8*)s, sfoldbuf, &sfoldlen);
-                                   if (sfoldlen != lfoldlen ||
-                                       memNE((char*)sfoldbuf,
-                                             (char*)lfoldbuf, lfoldlen))
-                                     sayNO;
-                              }
+                         while (llen && slen) {
+                              if (UTF8SKIP(lf) != UTF8SKIP(sf) ||
+                                  memNE((char*)lf, (char*)sf, UTF8SKIP(lf)))
+                                   sayNO;
+                              llen -= UTF8SKIP(lf);
+                              lf   += UTF8SKIP(lf);
+                              slen -= UTF8SKIP(sf);
+                              sf   += UTF8SKIP(sf);
                          }
+                         
                          l += UTF8SKIP(l);
                          s += UTF8SKIP(s);
                     }
End of Patch.

Reply via email to