Blame SOURCES/perl-5.26.1-fix-TRIE_READ_CHAR-and-DECL_TRIE_TYPE-to-acco.patch

243a19
From d58a6811d830c2f2f850a03a18129c38cb732791 Mon Sep 17 00:00:00 2001
243a19
From: Yves Orton <demerphq@gmail.com>
243a19
Date: Tue, 13 Feb 2018 16:11:55 +1100
243a19
Subject: 5.26.1: fix TRIE_READ_CHAR and DECL_TRIE_TYPE to account for non-utf8
243a19
 target
243a19
243a19
---
243a19
 regexec.c     | 14 ++++++++++----
243a19
 t/re/re_tests |  1 +
243a19
 2 files changed, 11 insertions(+), 4 deletions(-)
243a19
243a19
diff --git a/regexec.c b/regexec.c
243a19
index fa888823bd..cf81b07e30 100644
243a19
--- a/regexec.c
243a19
+++ b/regexec.c
243a19
@@ -1472,7 +1472,7 @@ Perl_re_intuit_start(pTHX_
243a19
 #define DECL_TRIE_TYPE(scan) \
243a19
     const enum { trie_plain, trie_utf8, trie_utf8_fold, trie_latin_utf8_fold,       \
243a19
                  trie_utf8_exactfa_fold, trie_latin_utf8_exactfa_fold,              \
243a19
-                 trie_utf8l, trie_flu8 }                                            \
243a19
+                 trie_utf8l, trie_flu8, trie_flu8_latin }                           \
243a19
                     trie_type = ((scan->flags == EXACT)                             \
243a19
                                  ? (utf8_target ? trie_utf8 : trie_plain)           \
243a19
                                  : (scan->flags == EXACTL)                          \
243a19
@@ -1482,10 +1482,12 @@ Perl_re_intuit_start(pTHX_
243a19
                                          ? trie_utf8_exactfa_fold                   \
243a19
                                          : trie_latin_utf8_exactfa_fold)            \
243a19
                                       : (scan->flags == EXACTFLU8                   \
243a19
-                                         ? trie_flu8                                \
243a19
+                                         ? (utf8_target                             \
243a19
+                                           ? trie_flu8                              \
243a19
+                                           : trie_flu8_latin)                       \
243a19
                                          : (utf8_target                             \
243a19
                                            ? trie_utf8_fold                         \
243a19
-                                           :   trie_latin_utf8_fold)))
243a19
+                                           : trie_latin_utf8_fold)))
243a19
 
243a19
 /* 'uscan' is set to foldbuf, and incremented, so below the end of uscan is
243a19
  * 'foldbuf+sizeof(foldbuf)' */
243a19
@@ -1496,7 +1498,7 @@ STMT_START {
243a19
     switch (trie_type) {                                                            \
243a19
     case trie_flu8:                                                                 \
243a19
         _CHECK_AND_WARN_PROBLEMATIC_LOCALE;                                         \
243a19
-        if (utf8_target && UTF8_IS_ABOVE_LATIN1(*uc)) {                             \
243a19
+        if (UTF8_IS_ABOVE_LATIN1(*uc)) {                                            \
243a19
             _CHECK_AND_OUTPUT_WIDE_LOCALE_UTF8_MSG(uc, uc_end - uc);                \
243a19
         }                                                                           \
243a19
         goto do_trie_utf8_fold;                                                     \
243a19
@@ -1519,10 +1521,14 @@ STMT_START {
243a19
             uscan = foldbuf + skiplen;                                              \
243a19
         }                                                                           \
243a19
         break;                                                                      \
243a19
+    case trie_flu8_latin:                                                           \
243a19
+        _CHECK_AND_WARN_PROBLEMATIC_LOCALE;                                         \
243a19
+        goto do_trie_latin_utf8_fold;                                               \
243a19
     case trie_latin_utf8_exactfa_fold:                                              \
243a19
         flags |= FOLD_FLAGS_NOMIX_ASCII;                                            \
243a19
         /* FALLTHROUGH */                                                           \
243a19
     case trie_latin_utf8_fold:                                                      \
243a19
+      do_trie_latin_utf8_fold:                                                      \
243a19
         if ( foldlen>0 ) {                                                          \
243a19
             uvc = utf8n_to_uvchr( (const U8*) uscan, foldlen, &len, uniflags );     \
243a19
             foldlen -= len;                                                         \
243a19
diff --git a/t/re/re_tests b/t/re/re_tests
243a19
index 410fceadac..78baed6ffc 100644
243a19
--- a/t/re/re_tests
243a19
+++ b/t/re/re_tests
243a19
@@ -1985,6 +1985,7 @@ AB\s+\x{100}	AB \x{100}X	y	-	-
243a19
 /(?x)[a b]/xx	\N{SPACE}	yS	$&	 	# Note a space char here
243a19
 /(?xx)[a b]/x	\N{SPACE}	n	-	-
243a19
 /(?-x:[a b])/xx	\N{SPACE}	yS	$&	 	# Note a space char here
243a19
+(?il)\x{100}|\x{100}|\x{FF}	\xFF	y	$&	\xFF
243a19
 
243a19
 # Keep these lines at the end of the file
243a19
 # vim: softtabstop=0 noexpandtab
243a19
-- 
243a19
2.11.0
243a19