11 Star 0 Fork 33

src-openEuler/pcre2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-Fixing-an-issue-using-empty-character-sets-in-jit.patch 2.36 KB
一键复制 编辑 原始数据 按行查看 历史
From 994536c96fa571bcfd9232001e73b78c6afb9e67 Mon Sep 17 00:00:00 2001
From: Zoltan Herczeg <hzmester@freemail.hu>
Date: Thu, 21 Mar 2024 07:33:17 +0000
Subject: [PATCH] Fixing an issue using empty character sets in jit
Conflict:adapt context
Reference:https://github.com/PCRE2Project/pcre2/commit/994536c96fa571bcfd9232001e73b78c6afb9e67
---
src/pcre2_jit_compile.c | 23 ++++++++++++++++-------
src/pcre2_jit_test.c | 1 +
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/pcre2_jit_compile.c b/src/pcre2_jit_compile.c
index afff36a..c19723b 100644
--- a/src/pcre2_jit_compile.c
+++ b/src/pcre2_jit_compile.c
@@ -6186,25 +6186,34 @@ if (max < 1)
/* Convert last_count to priority. */
for (i = 0; i < max; i++)
{
- SLJIT_ASSERT(chars[i].count > 0 && chars[i].last_count <= chars[i].count);
+ SLJIT_ASSERT(chars[i].last_count <= chars[i].count);
- if (chars[i].count == 1)
+ switch (chars[i].count)
{
+ case 0:
+ chars[i].count = 255;
+ chars[i].last_count = 0;
+ break;
+
+ case 1:
chars[i].last_count = (chars[i].last_count == 1) ? 7 : 5;
/* Simplifies algorithms later. */
chars[i].chars[1] = chars[i].chars[0];
- }
- else if (chars[i].count == 2)
- {
+ break;
+
+ case 2:
SLJIT_ASSERT(chars[i].chars[0] != chars[i].chars[1]);
if (is_powerof2(chars[i].chars[0] ^ chars[i].chars[1]))
chars[i].last_count = (chars[i].last_count == 2) ? 6 : 4;
else
chars[i].last_count = (chars[i].last_count == 2) ? 3 : 2;
- }
- else
+ break;
+
+ default:
chars[i].last_count = (chars[i].count == 255) ? 0 : 1;
+ break;
+ }
}
#ifdef JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD
diff --git a/src/pcre2_jit_test.c b/src/pcre2_jit_test.c
index f051bd2..6d95bb9 100644
--- a/src/pcre2_jit_test.c
+++ b/src/pcre2_jit_test.c
@@ -396,6 +396,7 @@ static struct regression_test_case regression_test_cases[] = {
{ MU, A, 0, 0, "[\\x{10001}-\\x{10fffe}]+", "#\xc3\xa9\xe2\xb1\xa5\xf0\x90\x80\x80\xf0\x90\x80\x81\xf4\x8f\xbf\xbe\xf4\x8f\xbf\xbf" },
{ MU, A, 0, 0, "[^\\x{10001}-\\x{10fffe}]+", "\xf0\x90\x80\x81#\xc3\xa9\xe2\xb1\xa5\xf0\x90\x80\x80\xf4\x8f\xbf\xbf\xf4\x8f\xbf\xbe" },
{ CMU, A, 0, 0 | F_NOMATCH, "^[\\x{0100}-\\x{017f}]", " " },
+ { M, A, 0, 0 | F_NOMATCH, "[^\\S\\W]{6}", "abcdefghijk" },
/* Unicode properties. */
{ MUP, A, 0, 0, "[1-5\xc3\xa9\\w]", "\xc3\xa1_" },
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/pcre2.git
git@gitee.com:src-openeuler/pcre2.git
src-openeuler
pcre2
pcre2
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385