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

2c161b
From 1a076cf2730d3a1fbb174af6f56c554691f4cdc3 Mon Sep 17 00:00:00 2001
2c161b
From: Yves Orton <demerphq@gmail.com>
2c161b
Date: Mon, 19 Feb 2018 13:49:46 +1100
2c161b
Subject: [PATCH] v5.24.3: fix TRIE_READ_CHAR and DECL_TRIE_TYPE to account for
2c161b
 non-utf8 target
2c161b
MIME-Version: 1.0
2c161b
Content-Type: text/plain; charset=UTF-8
2c161b
Content-Transfer-Encoding: 8bit
2c161b
2c161b
Petr Pisar: Ported to 5.24.0.
2c161b
2c161b
Signed-off-by: Petr Písař <ppisar@redhat.com>
2c161b
---
2c161b
 regexec.c     | 14 ++++++++++----
2c161b
 t/re/re_tests |  1 +
2c161b
 2 files changed, 11 insertions(+), 4 deletions(-)
2c161b
2c161b
diff --git a/regexec.c b/regexec.c
2c161b
index 3fd12c4..05e148f 100644
2c161b
--- a/regexec.c
2c161b
+++ b/regexec.c
2c161b
@@ -1451,7 +1451,7 @@ Perl_re_intuit_start(pTHX_
2c161b
 #define DECL_TRIE_TYPE(scan) \
2c161b
     const enum { trie_plain, trie_utf8, trie_utf8_fold, trie_latin_utf8_fold,       \
2c161b
                  trie_utf8_exactfa_fold, trie_latin_utf8_exactfa_fold,              \
2c161b
-                 trie_utf8l, trie_flu8 }                                            \
2c161b
+                 trie_utf8l, trie_flu8, trie_flu8_latin }                           \
2c161b
                     trie_type = ((scan->flags == EXACT)                             \
2c161b
                                  ? (utf8_target ? trie_utf8 : trie_plain)           \
2c161b
                                  : (scan->flags == EXACTL)                          \
2c161b
@@ -1461,10 +1461,12 @@ Perl_re_intuit_start(pTHX_
2c161b
                                          ? trie_utf8_exactfa_fold                   \
2c161b
                                          : trie_latin_utf8_exactfa_fold)            \
2c161b
                                       : (scan->flags == EXACTFLU8                   \
2c161b
-                                         ? trie_flu8                                \
2c161b
+                                         ? (utf8_target                             \
2c161b
+                                           ? trie_flu8                              \
2c161b
+                                           : trie_flu8_latin)                       \
2c161b
                                          : (utf8_target                             \
2c161b
                                            ? trie_utf8_fold                         \
2c161b
-                                           :   trie_latin_utf8_fold)))
2c161b
+                                           : trie_latin_utf8_fold)))
2c161b
 
2c161b
 /* 'uscan' is set to foldbuf, and incremented, so below the end of uscan is
2c161b
  * 'foldbuf+sizeof(foldbuf)' */
2c161b
@@ -1475,7 +1477,7 @@ STMT_START {
2c161b
     switch (trie_type) {                                                            \
2c161b
     case trie_flu8:                                                                 \
2c161b
         _CHECK_AND_WARN_PROBLEMATIC_LOCALE;                                         \
2c161b
-        if (utf8_target && UTF8_IS_ABOVE_LATIN1(*uc)) {                             \
2c161b
+        if (UTF8_IS_ABOVE_LATIN1(*uc)) {                                            \
2c161b
             _CHECK_AND_OUTPUT_WIDE_LOCALE_UTF8_MSG(uc, uc_end - uc);                \
2c161b
         }                                                                           \
2c161b
         goto do_trie_utf8_fold;                                                     \
2c161b
@@ -1497,10 +1499,14 @@ STMT_START {
2c161b
             uscan = foldbuf + skiplen;                                              \
2c161b
         }                                                                           \
2c161b
         break;                                                                      \
2c161b
+    case trie_flu8_latin:                                                           \
2c161b
+        _CHECK_AND_WARN_PROBLEMATIC_LOCALE;                                         \
2c161b
+        goto do_trie_latin_utf8_fold;                                               \
2c161b
     case trie_latin_utf8_exactfa_fold:                                              \
2c161b
         flags |= FOLD_FLAGS_NOMIX_ASCII;                                            \
2c161b
         /* FALLTHROUGH */                                                           \
2c161b
     case trie_latin_utf8_fold:                                                      \
2c161b
+      do_trie_latin_utf8_fold:                                                      \
2c161b
         if ( foldlen>0 ) {                                                          \
2c161b
             uvc = utf8n_to_uvchr( (const U8*) uscan, foldlen, &len, uniflags );     \
2c161b
             foldlen -= len;                                                         \
2c161b
diff --git a/t/re/re_tests b/t/re/re_tests
2c161b
index 7e8522d..ab7ddbb 100644
2c161b
--- a/t/re/re_tests
2c161b
+++ b/t/re/re_tests
2c161b
@@ -1968,6 +1968,7 @@ ab(?#Comment){2}c	abbc	y	$&	abbc
2c161b
 (?:.||)(?|)000000000@	000000000@	y	$&	000000000@		#  [perl #126405]
2c161b
 aa$|a(?R)a|a	aaa	y	$&	aaa		# [perl 128420] recursive matches
2c161b
 (?:\1|a)([bcd])\1(?:(?R)|e)\1	abbaccaddedcb	y	$&	abbaccaddedcb		# [perl 128420] recursive match with backreferences
2c161b
+(?il)\x{100}|\x{100}|\x{FF}	\xFF	y	$&	\xFF
2c161b
 
2c161b
 # Keep these lines at the end of the file
2c161b
 # vim: softtabstop=0 noexpandtab
2c161b
-- 
2c161b
2.14.3
2c161b