Skip to content

Commit 1bc34ff

Browse files
authored
pcre2grep: document better possible multiline matching misses (PCRE2Project#252)
While at it, remove a misplaced cast that would cause problems for subjects over 2GB and a few typos.
1 parent cf6f984 commit 1bc34ff

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

doc/pcre2grep.1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ The block of memory that is actually used is three times the "buffer size", to
6868
allow for buffering "before" and "after" lines. If the buffer size is too
6969
small, fewer than requested "before" and "after" lines may be output.
7070
.P
71+
When matching with a multiline pattern, the size of the buffer must be at least
72+
half of the maximum match expected or the pattern might fail to match.
73+
.P
7174
Patterns can be no longer than 8KiB or BUFSIZ bytes, whichever is the greater.
7275
BUFSIZ is defined in \fB<stdio.h>\fP. When there is more than one pattern
7376
(specified by the use of \fB-e\fP and/or \fB-f\fP), each pattern is applied to
@@ -211,7 +214,7 @@ exactly the same as the number of lines that would have been output, but if the
211214
\fB-M\fP (multiline) option is used (without \fB-v\fP), there may be more
212215
suppressed lines than the count (that is, the number of matches).
213216
.sp
214-
If no lines are selected, the number zero is output. If several files are are
217+
If no lines are selected, the number zero is output. If several files are
215218
being scanned, a count is output for each of them and the \fB-t\fP option can
216219
be used to cause a total to be output at the end. However, if the
217220
\fB--files-with-matches\fP option is also used, only those files whose counts
@@ -506,8 +509,10 @@ well as possibly handling a two-character newline sequence.
506509
.sp
507510
There is a limit to the number of lines that can be matched, imposed by the way
508511
that \fBpcre2grep\fP buffers the input file as it scans it. With a sufficiently
509-
large processing buffer, this should not be a problem, but the \fB-M\fP option
510-
does not work when input is read line by line (see \fB--line-buffered\fP.)
512+
large processing buffer, this should not be a problem.
513+
.sp
514+
The \fB-M\fP option does not work when input is read line by line (see
515+
\fB--line-buffered\fP.)
511516
.TP
512517
\fB-m\fP \fInumber\fP, \fB--max-count\fP=\fInumber\fP
513518
Stop processing after finding \fInumber\fP matching lines, or non-matching

maint/ucptest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Script Extensions and Boolean properties, there may be a mixture of positive
7676
and negative requirements. All must be satisfied.
7777
7878
Sequences of two or more characters are shown as ranges, for example
79-
U+0041..U+004A. No more than 100 lines are are output. If there are more
79+
U+0041..U+004A. No more than 100 lines are output. If there are more
8080
characters, the list ends with ...
8181
8282
The command "list" must be followed by one of property names script, bool,

src/pcre2_compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5753,8 +5753,8 @@ for (;; pptr++)
57535753
57545754
If the class contains characters outside the 0-255 range, a different
57555755
opcode is compiled. It may optionally have a bit map for characters < 256,
5756-
but those above are are explicitly listed afterwards. A flag code unit
5757-
tells whether the bitmap is present, and whether this is a negated class or
5756+
but those above are explicitly listed afterwards. A flag code unit tells
5757+
whether the bitmap is present, and whether this is a negated class or
57585758
not. */
57595759

57605760
case META_CLASS_NOT:

src/pcre2grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ if (slen > 200)
18561856

18571857
for (int i = 1; p != NULL; p = p->next, i++)
18581858
{
1859-
int rc = pcre2_match(p->compiled, (PCRE2_SPTR)matchptr, (int)length,
1859+
int rc = pcre2_match(p->compiled, (PCRE2_SPTR)matchptr, length,
18601860
startoffset, options, match_data, match_context);
18611861
if (rc == PCRE2_ERROR_NOMATCH) continue;
18621862

0 commit comments

Comments
 (0)