14 Star 0 Fork 38

src-openEuler/pcre2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-pcre2grep-document-better-possible-multiline-matchin.patch 3.85 KB
一键复制 编辑 原始数据 按行查看 历史
fly_fzc 提交于 2024-07-23 10:47 +08:00 . document better possible multiline matching misses
From 1bc34ffa64c33381d793fb5cdddf3f484e603d23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= <carenas@gmail.com>
Date: Fri, 12 May 2023 07:54:02 -0700
Subject: [PATCH] pcre2grep: document better possible multiline matching misses
(#252)
While at it, remove a misplaced cast that would cause problems for
subjects over 2GB and a few typos.
Conflict:don't modify ucptest.c because ucptest.c doesn't exist in current version.
Reference:https://github.com/PCRE2Project/pcre2/commit/1bc34ffa64c33381d793fb5cdddf3f484e603d23
---
doc/pcre2grep.1 | 11 ++++++++---
src/pcre2_compile.c | 4 ++--
src/pcre2grep.c | 2 +-
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/doc/pcre2grep.1 b/doc/pcre2grep.1
index 1081591..5077304 100644
--- a/doc/pcre2grep.1
+++ b/doc/pcre2grep.1
@@ -66,6 +66,9 @@ The block of memory that is actually used is three times the "buffer size", to
allow for buffering "before" and "after" lines. If the buffer size is too
small, fewer than requested "before" and "after" lines may be output.
.P
+When matching with a multiline pattern, the size of the buffer must be at least
+half of the maximum match expected or the pattern might fail to match.
+.P
Patterns can be no longer than 8KiB or BUFSIZ bytes, whichever is the greater.
BUFSIZ is defined in \fB<stdio.h>\fP. When there is more than one pattern
(specified by the use of \fB-e\fP and/or \fB-f\fP), each pattern is applied to
@@ -201,7 +204,7 @@ exactly the same as the number of lines that would have been output, but if the
\fB-M\fP (multiline) option is used (without \fB-v\fP), there may be more
suppressed lines than the count (that is, the number of matches).
.sp
-If no lines are selected, the number zero is output. If several files are are
+If no lines are selected, the number zero is output. If several files are
being scanned, a count is output for each of them and the \fB-t\fP option can
be used to cause a total to be output at the end. However, if the
\fB--files-with-matches\fP option is also used, only those files whose counts
@@ -490,8 +493,10 @@ well as possibly handling a two-character newline sequence.
.sp
There is a limit to the number of lines that can be matched, imposed by the way
that \fBpcre2grep\fP buffers the input file as it scans it. With a sufficiently
-large processing buffer, this should not be a problem, but the \fB-M\fP option
-does not work when input is read line by line (see \fB--line-buffered\fP.)
+large processing buffer, this should not be a problem.
+.sp
+The \fB-M\fP option does not work when input is read line by line (see
+\fB--line-buffered\fP.)
.TP
\fB-m\fP \fInumber\fP, \fB--max-count\fP=\fInumber\fP
Stop processing after finding \fInumber\fP matching lines, or non-matching
diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c
index b906dc0..c6d4c60 100644
--- a/src/pcre2_compile.c
+++ b/src/pcre2_compile.c
@@ -5549,8 +5549,8 @@ for (;; pptr++)
If the class contains characters outside the 0-255 range, a different
opcode is compiled. It may optionally have a bit map for characters < 256,
- but those above are are explicitly listed afterwards. A flag code unit
- tells whether the bitmap is present, and whether this is a negated class or
+ but those above are explicitly listed afterwards. A flag code unit tells
+ whether the bitmap is present, and whether this is a negated class or
not. */
case META_CLASS_NOT:
diff --git a/src/pcre2grep.c b/src/pcre2grep.c
index 1484d67..d2ab620 100644
--- a/src/pcre2grep.c
+++ b/src/pcre2grep.c
@@ -1856,7 +1856,7 @@ if (slen > 200)
for (int i = 1; p != NULL; p = p->next, i++)
{
- int rc = pcre2_match(p->compiled, (PCRE2_SPTR)matchptr, (int)length,
+ int rc = pcre2_match(p->compiled, (PCRE2_SPTR)matchptr, length,
startoffset, options, match_data, match_context);
if (rc == PCRE2_ERROR_NOMATCH) continue;
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/pcre2.git
git@gitee.com:src-openeuler/pcre2.git
src-openeuler
pcre2
pcre2
master

搜索帮助