2
* This is a modified version of pcre.c containing only the code/data
3
* required to support pcre_exec()
7
/*************************************************
8
* Perl-Compatible Regular Expressions *
9
*************************************************/
12
This is a library of functions to support regular expressions whose syntax
13
and semantics are as close as possible to those of the Perl 5 language. See
14
the file Tech.Notes for some information on the internals.
16
Written by: Philip Hazel <ph10@cam.ac.uk>
18
Copyright (c) 1997-2001 University of Cambridge
20
-----------------------------------------------------------------------------
21
Permission is granted to anyone to use this software for any purpose on any
22
computer system, and to redistribute it freely, subject to the following
25
1. This software is distributed in the hope that it will be useful,
26
but WITHOUT ANY WARRANTY; without even the implied warranty of
27
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
29
2. The origin of this software must not be misrepresented, either by
30
explicit claim or by omission.
32
3. Altered versions must be plainly marked as such, and must not be
33
misrepresented as being the original software.
35
4. If PCRE is embedded in any software that is released under the GNU
36
General Purpose Licence (GPL), then the terms of that licence shall
37
supersede any condition above with which it is incompatible.
38
-----------------------------------------------------------------------------
42
/* Define DEBUG to get debugging output on stdout. */
46
/* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef
47
inline, and there are *still* stupid compilers about that don't like indented
48
pre-processor statements. I suppose it's only been 10 years... */
51
#define DPRINTF(p) PCRE_PRINTF p
53
#define DPRINTF(p) /*nothing*/
56
/* Include the internals header, which itself includes Standard C headers plus
57
the external pcre header. */
59
#include "pcre_exec.h"
62
/* ---- CODE DELETED ---- */
65
/* Min and max values for the common repeats; for the maxima, 0 => infinity */
67
static const char rep_min[] = { 0, 0, 1, 1, 0, 0 };
68
static const char rep_max[] = { 0, 0, 0, 0, 1, 1 };
71
/* ---- CODE DELETED ---- */
74
/* Structure for building a chain of data that actually lives on the
75
* stack, for holding the values of the subject pointer at the start of each
76
* subpattern, so as to detect when an empty string has been matched by a
77
* subpattern - to break infinite loops. */
79
typedef struct eptrblock {
80
struct eptrblock *prev;
81
const uschar *saved_eptr;
84
/* Flag bits for the match() function */
86
#define match_condassert 0x01 /* Called to check a condition assertion */
87
#define match_isgroup 0x02 /* Set if start of bracketed group */
90
/* ---- CODE DELETED ---- */
93
/*************************************************
94
* * Global variables *
95
* *************************************************/
97
/* PCRE is thread-clean and doesn't use any global variables in the normal
98
* sense. However, it calls memory allocation and free functions via the two
99
* indirections below, which are can be changed by the caller, but are shared
100
* between all threads. */
103
static void *kern_malloc(size_t sz)
105
return kmalloc(sz, GFP_KERNEL);
107
void *(*pcre_malloc)(size_t) = kern_malloc;
108
void (*pcre_free)(const void *) = kfree;
110
void *(*pcre_malloc)(size_t) = malloc;
111
void (*pcre_free)(const void *) = free;
115
/*************************************************
116
* * Macros and tables for character handling *
117
* *************************************************/
119
/* When UTF-8 encoding is being used, a character is no longer just a single
120
* byte. The macros for character handling generate simple sequences when used in
121
* byte-mode, and more complicated ones for UTF-8 characters. */
124
#define GETCHARINC(c, eptr) c = *eptr++;
125
#define GETCHARLEN(c, eptr, len) c = *eptr;
126
#define BACKCHAR(eptr)
129
/* ---- CODE DELETED ---- */
132
/*************************************************
133
* Debugging function to print chars *
134
*************************************************/
136
/* Print a sequence of chars in printable format, stopping at the end of the
137
subject if the requested.
140
p points to characters
141
length number to print
142
is_subject TRUE if printing from within md->start_subject
143
md pointer to matching data block, if is_subject is TRUE
149
pchars(const uschar *p, int length, BOOL is_subject, match_data *md)
152
if (is_subject && length > md->end_subject - p) length = md->end_subject - p;
154
if (isprint(c = *(p++))) PCRE_PRINTF("%c", c); else PCRE_PRINTF("\\x%02x", c);
158
/* ---- CODE DELETED ---- */
161
/*************************************************
162
* Match a back-reference *
163
*************************************************/
165
/* If a back reference hasn't been set, the length that is passed is greater
166
than the number of characters left in the string, so the match fails.
169
offset index into the offset vector
170
eptr points into the subject
171
length length to be matched
172
md points to match data block
175
Returns: TRUE if matched
179
match_ref(int offset, register const uschar *eptr, int length, match_data *md,
180
unsigned long int ims)
182
const uschar *p = md->start_subject + md->offset_vector[offset];
185
if (eptr >= md->end_subject)
186
PCRE_PRINTF("matching subject <null>");
189
PCRE_PRINTF("matching subject ");
190
pchars(eptr, length, TRUE, md);
192
PCRE_PRINTF(" against backref ");
193
pchars(p, length, FALSE, md);
197
/* Always fail if not enough characters left */
199
if (length > md->end_subject - eptr) return FALSE;
201
/* Separate the caselesss case for speed */
203
if ((ims & PCRE_CASELESS) != 0)
206
if (md->lcc[*p++] != md->lcc[*eptr++]) return FALSE;
209
{ while (length-- > 0) if (*p++ != *eptr++) return FALSE; }
215
/*************************************************
216
* Match from current position *
217
*************************************************/
219
/* On entry ecode points to the first opcode, and eptr to the first character
220
in the subject string, while eptrb holds the value of eptr at the start of the
221
last bracketed group - used for breaking infinite loops matching zero-length
225
eptr pointer in subject
226
ecode position in code
227
offset_top current top pointer
228
md pointer to "static" info for the match
229
ims current /i, /m, and /s options
230
eptrb pointer to chain of blocks containing eptr at start of
231
brackets - for testing for empty matches
233
match_condassert - this is an assertion condition
234
match_isgroup - this is the start of a bracketed group
236
Returns: TRUE if matched
240
match(register const uschar *eptr, register const uschar *ecode,
241
int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb,
244
unsigned long int original_ims = ims; /* Save for resetting on ')' */
247
/* At the start of a bracketed group, add the current subject pointer to the
248
stack of such pointers, to be re-instated at the end of the group when we hit
249
the closing ket. When match() is called in other circumstances, we don't add to
252
if ((flags & match_isgroup) != 0)
254
newptrb.prev = eptrb;
255
newptrb.saved_eptr = eptr;
259
/* Now start processing the operations. */
263
int op = (int)*ecode;
267
BOOL minimize = FALSE;
269
/* Opening capturing bracket. If there is space in the offset vector, save
270
the current subject position in the working slot at the top of the vector. We
271
mustn't change the current values of the data slot, because they may be set
272
from a previous iteration of this group, and be referred to by a reference
275
If the bracket fails to match, we need to restore this value and also the
276
values of the final offsets, in case they were set by a previous iteration of
279
If there isn't enough space in the offset vector, treat this as if it were a
280
non-capturing bracket. Don't worry about setting the flag for the error case
281
here; that is handled in the code for KET. */
286
int number = op - OP_BRA;
288
/* For extended extraction brackets (large number), we have to fish out the
289
number from a dummy opcode at the start. */
291
if (number > EXTRACT_BASIC_MAX) number = (ecode[4] << 8) | ecode[5];
292
offset = number << 1;
295
PCRE_PRINTF("start bracket %d subject=", number);
296
pchars(eptr, 16, TRUE, md);
300
if (offset < md->offset_max)
302
int save_offset1 = md->offset_vector[offset];
303
int save_offset2 = md->offset_vector[offset+1];
304
int save_offset3 = md->offset_vector[md->offset_end - number];
306
DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
307
md->offset_vector[md->offset_end - number] = eptr - md->start_subject;
311
if (match(eptr, ecode+3, offset_top, md, ims, eptrb, match_isgroup))
313
ecode += (ecode[1] << 8) + ecode[2];
315
while (*ecode == OP_ALT);
317
DPRINTF(("bracket %d failed\n", number));
319
md->offset_vector[offset] = save_offset1;
320
md->offset_vector[offset+1] = save_offset2;
321
md->offset_vector[md->offset_end - number] = save_offset3;
326
/* Insufficient room for saving captured contents */
331
/* Other types of node can be handled by a switch */
335
case OP_BRA: /* Non-capturing bracket: optimized */
336
DPRINTF(("start bracket 0\n"));
339
if (match(eptr, ecode+3, offset_top, md, ims, eptrb, match_isgroup))
341
ecode += (ecode[1] << 8) + ecode[2];
343
while (*ecode == OP_ALT);
344
DPRINTF(("bracket 0 failed\n"));
347
/* Conditional group: compilation checked that there are no more than
348
two branches. If the condition is false, skipping the first branch takes us
349
past the end if there is only one branch, but that's OK because that is
350
exactly what going to the ket would do. */
353
if (ecode[3] == OP_CREF) /* Condition is extraction test */
355
int offset = (ecode[4] << 9) | (ecode[5] << 1); /* Doubled ref number */
357
ecode + ((offset < offset_top && md->offset_vector[offset] >= 0)?
358
6 : 3 + (ecode[1] << 8) + ecode[2]),
359
offset_top, md, ims, eptrb, match_isgroup);
362
/* The condition is an assertion. Call match() to evaluate it - setting
363
the final argument TRUE causes it to stop at the end of an assertion. */
367
if (match(eptr, ecode+3, offset_top, md, ims, NULL,
368
match_condassert | match_isgroup))
370
ecode += 3 + (ecode[4] << 8) + ecode[5];
371
while (*ecode == OP_ALT) ecode += (ecode[1] << 8) + ecode[2];
373
else ecode += (ecode[1] << 8) + ecode[2];
374
return match(eptr, ecode+3, offset_top, md, ims, eptrb, match_isgroup);
376
/* Control never reaches here */
378
/* Skip over conditional reference or large extraction number data if
386
/* End of the pattern. If PCRE_NOTEMPTY is set, fail if we have matched
387
an empty string - recursion will then try other alternatives, if any. */
390
if (md->notempty && eptr == md->start_match) return FALSE;
391
md->end_match_ptr = eptr; /* Record where we ended */
392
md->end_offset_top = offset_top; /* and how many extracts were taken */
395
/* Change option settings */
400
DPRINTF(("ims set to %02lx\n", ims));
403
/* Assertion brackets. Check the alternative branches in turn - the
404
matching won't pass the KET for an assertion. If any one branch matches,
405
the assertion is true. Lookbehind assertions have an OP_REVERSE item at the
406
start of each branch to move the current point backwards, so the code at
407
this level is identical to the lookahead case. */
413
if (match(eptr, ecode+3, offset_top, md, ims, NULL, match_isgroup)) break;
414
ecode += (ecode[1] << 8) + ecode[2];
416
while (*ecode == OP_ALT);
417
if (*ecode == OP_KET) return FALSE;
419
/* If checking an assertion for a condition, return TRUE. */
421
if ((flags & match_condassert) != 0) return TRUE;
423
/* Continue from after the assertion, updating the offsets high water
424
mark, since extracts may have been taken during the assertion. */
426
do ecode += (ecode[1] << 8) + ecode[2]; while (*ecode == OP_ALT);
428
offset_top = md->end_offset_top;
431
/* Negative assertion: all branches must fail to match */
434
case OP_ASSERTBACK_NOT:
437
if (match(eptr, ecode+3, offset_top, md, ims, NULL, match_isgroup))
439
ecode += (ecode[1] << 8) + ecode[2];
441
while (*ecode == OP_ALT);
443
if ((flags & match_condassert) != 0) return TRUE;
448
/* Move the subject pointer back. This occurs only at the start of
449
each branch of a lookbehind assertion. If we are too close to the start to
450
move back, this match function fails. When working with UTF-8 we move
451
back a number of characters, not bytes. */
455
c = (ecode[1] << 8) + ecode[2];
456
for (i = 0; i < c; i++)
462
eptr -= (ecode[1] << 8) + ecode[2];
465
if (eptr < md->start_subject) return FALSE;
469
/* Recursion matches the current regex, nested. If there are any capturing
470
brackets started but not finished, we have to save their starting points
471
and reinstate them after the recursion. However, we don't know how many
472
such there are (offset_top records the completed total) so we just have
473
to save all the potential data. There may be up to 99 such values, which
474
is a bit large to put on the stack, but using malloc for small numbers
475
seems expensive. As a compromise, the stack is used when there are fewer
476
than 16 values to store; otherwise malloc is used. A problem is what to do
477
if the malloc fails ... there is no way of returning to the top level with
478
an error. Save the top 15 values on the stack, and accept that the rest
489
if (c < 16) save = stacksave; else
491
save = (int *)(pcre_malloc)((c+1) * sizeof(int));
499
for (i = 1; i <= c; i++)
500
save[i] = md->offset_vector[md->offset_end - i];
501
rc = match(eptr, md->start_pattern, offset_top, md, ims, eptrb,
503
for (i = 1; i <= c; i++)
504
md->offset_vector[md->offset_end - i] = save[i];
505
if (save != stacksave) (pcre_free)(save);
506
if (!rc) return FALSE;
508
/* In case the recursion has set more capturing values, save the final
509
number, then move along the subject till after the recursive match,
510
and advance one byte in the pattern code. */
512
offset_top = md->end_offset_top;
513
eptr = md->end_match_ptr;
518
/* "Once" brackets are like assertion brackets except that after a match,
519
the point in the subject string is not moved back. Thus there can never be
520
a move back into the brackets. Check the alternative branches in turn - the
521
matching won't pass the KET for this kind of subpattern. If any one branch
522
matches, we carry on as at the end of a normal bracket, leaving the subject
527
const uschar *prev = ecode;
528
const uschar *saved_eptr = eptr;
532
if (match(eptr, ecode+3, offset_top, md, ims, eptrb, match_isgroup))
534
ecode += (ecode[1] << 8) + ecode[2];
536
while (*ecode == OP_ALT);
538
/* If hit the end of the group (which could be repeated), fail */
540
if (*ecode != OP_ONCE && *ecode != OP_ALT) return FALSE;
542
/* Continue as from after the assertion, updating the offsets high water
543
mark, since extracts may have been taken. */
545
do ecode += (ecode[1] << 8) + ecode[2]; while (*ecode == OP_ALT);
547
offset_top = md->end_offset_top;
548
eptr = md->end_match_ptr;
550
/* For a non-repeating ket, just continue at this level. This also
551
happens for a repeating ket if no characters were matched in the group.
552
This is the forcible breaking of infinite loops as implemented in Perl
553
5.005. If there is an options reset, it will get obeyed in the normal
556
if (*ecode == OP_KET || eptr == saved_eptr)
562
/* The repeating kets try the rest of the pattern or restart from the
563
preceding bracket, in the appropriate order. We need to reset any options
564
that changed within the bracket before re-running it, so check the next
567
if (ecode[3] == OP_OPT)
569
ims = (ims & ~PCRE_IMS) | ecode[4];
570
DPRINTF(("ims set to %02lx at group repeat\n", ims));
573
if (*ecode == OP_KETRMIN)
575
if (match(eptr, ecode+3, offset_top, md, ims, eptrb, 0) ||
576
match(eptr, prev, offset_top, md, ims, eptrb, match_isgroup))
579
else /* OP_KETRMAX */
581
if (match(eptr, prev, offset_top, md, ims, eptrb, match_isgroup) ||
582
match(eptr, ecode+3, offset_top, md, ims, eptrb, 0)) return TRUE;
587
/* An alternation is the end of a branch; scan along to find the end of the
588
bracketed group and go to there. */
591
do ecode += (ecode[1] << 8) + ecode[2]; while (*ecode == OP_ALT);
594
/* BRAZERO and BRAMINZERO occur just before a bracket group, indicating
595
that it may occur zero times. It may repeat infinitely, or not at all -
596
i.e. it could be ()* or ()? in the pattern. Brackets with fixed upper
597
repeat limits are compiled as a number of copies, with the optional ones
598
preceded by BRAZERO or BRAMINZERO. */
602
const uschar *next = ecode+1;
603
if (match(eptr, next, offset_top, md, ims, eptrb, match_isgroup))
605
do next += (next[1] << 8) + next[2]; while (*next == OP_ALT);
612
const uschar *next = ecode+1;
613
do next += (next[1] << 8) + next[2]; while (*next == OP_ALT);
614
if (match(eptr, next+3, offset_top, md, ims, eptrb, match_isgroup))
620
/* End of a group, repeated or non-repeating. If we are at the end of
621
an assertion "group", stop matching and return TRUE, but record the
622
current high water mark for use by positive assertions. Do this also
623
for the "once" (not-backup up) groups. */
629
const uschar *prev = ecode - (ecode[1] << 8) - ecode[2];
630
const uschar *saved_eptr = eptrb->saved_eptr;
632
eptrb = eptrb->prev; /* Back up the stack of bracket start pointers */
634
if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT ||
635
*prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT ||
638
md->end_match_ptr = eptr; /* For ONCE */
639
md->end_offset_top = offset_top;
643
/* In all other cases except a conditional group we have to check the
644
group number back at the start and if necessary complete handling an
645
extraction by setting the offsets and bumping the high water mark. */
647
if (*prev != OP_COND)
650
int number = *prev - OP_BRA;
652
/* For extended extraction brackets (large number), we have to fish out
653
the number from a dummy opcode at the start. */
655
if (number > EXTRACT_BASIC_MAX) number = (prev[4] << 8) | prev[5];
656
offset = number << 1;
659
PCRE_PRINTF("end bracket %d", number);
665
if (offset >= md->offset_max) md->offset_overflow = TRUE; else
667
md->offset_vector[offset] =
668
md->offset_vector[md->offset_end - number];
669
md->offset_vector[offset+1] = eptr - md->start_subject;
670
if (offset_top <= offset) offset_top = offset + 2;
675
/* Reset the value of the ims flags, in case they got changed during
679
DPRINTF(("ims reset to %02lx\n", ims));
681
/* For a non-repeating ket, just continue at this level. This also
682
happens for a repeating ket if no characters were matched in the group.
683
This is the forcible breaking of infinite loops as implemented in Perl
684
5.005. If there is an options reset, it will get obeyed in the normal
687
if (*ecode == OP_KET || eptr == saved_eptr)
693
/* The repeating kets try the rest of the pattern or restart from the
694
preceding bracket, in the appropriate order. */
696
if (*ecode == OP_KETRMIN)
698
if (match(eptr, ecode+3, offset_top, md, ims, eptrb, 0) ||
699
match(eptr, prev, offset_top, md, ims, eptrb, match_isgroup))
702
else /* OP_KETRMAX */
704
if (match(eptr, prev, offset_top, md, ims, eptrb, match_isgroup) ||
705
match(eptr, ecode+3, offset_top, md, ims, eptrb, 0)) return TRUE;
710
/* Start of subject unless notbol, or after internal newline if multiline */
713
if (md->notbol && eptr == md->start_subject) return FALSE;
714
if ((ims & PCRE_MULTILINE) != 0)
716
if (eptr != md->start_subject && eptr[-1] != NEWLINE) return FALSE;
720
/* ... else fall through */
722
/* Start of subject assertion */
725
if (eptr != md->start_subject) return FALSE;
729
/* Assert before internal newline if multiline, or before a terminating
730
newline unless endonly is set, else end of subject unless noteol is set. */
733
if ((ims & PCRE_MULTILINE) != 0)
735
if (eptr < md->end_subject) { if (*eptr != NEWLINE) return FALSE; }
736
else { if (md->noteol) return FALSE; }
742
if (md->noteol) return FALSE;
745
if (eptr < md->end_subject - 1 ||
746
(eptr == md->end_subject - 1 && *eptr != NEWLINE)) return FALSE;
752
/* ... else fall through */
754
/* End of subject assertion (\z) */
757
if (eptr < md->end_subject) return FALSE;
761
/* End of subject or ending \n assertion (\Z) */
764
if (eptr < md->end_subject - 1 ||
765
(eptr == md->end_subject - 1 && *eptr != NEWLINE)) return FALSE;
769
/* Word boundary assertions */
771
case OP_NOT_WORD_BOUNDARY:
772
case OP_WORD_BOUNDARY:
774
BOOL prev_is_word = (eptr != md->start_subject) &&
775
((md->ctypes[eptr[-1]] & ctype_word) != 0);
776
BOOL cur_is_word = (eptr < md->end_subject) &&
777
((md->ctypes[*eptr] & ctype_word) != 0);
778
if ((*ecode++ == OP_WORD_BOUNDARY)?
779
cur_is_word == prev_is_word : cur_is_word != prev_is_word)
784
/* Match a single character type; inline for speed */
787
if ((ims & PCRE_DOTALL) == 0 && eptr < md->end_subject && *eptr == NEWLINE)
789
if (eptr++ >= md->end_subject) return FALSE;
792
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
798
if (eptr >= md->end_subject ||
799
(md->ctypes[*eptr++] & ctype_digit) != 0)
805
if (eptr >= md->end_subject ||
806
(md->ctypes[*eptr++] & ctype_digit) == 0)
811
case OP_NOT_WHITESPACE:
812
if (eptr >= md->end_subject ||
813
(md->ctypes[*eptr++] & ctype_space) != 0)
819
if (eptr >= md->end_subject ||
820
(md->ctypes[*eptr++] & ctype_space) == 0)
825
case OP_NOT_WORDCHAR:
826
if (eptr >= md->end_subject ||
827
(md->ctypes[*eptr++] & ctype_word) != 0)
833
if (eptr >= md->end_subject ||
834
(md->ctypes[*eptr++] & ctype_word) == 0)
839
/* Match a back reference, possibly repeatedly. Look past the end of the
840
item to see if there is repeat information following. The code is similar
841
to that for character classes, but repeated for efficiency. Then obey
842
similar code to character type repeats - written out again for speed.
843
However, if the referenced string is the empty string, always treat
844
it as matched, any number of times (otherwise there could be infinite
850
int offset = (ecode[1] << 9) | (ecode[2] << 1); /* Doubled ref number */
851
ecode += 3; /* Advance past item */
853
/* If the reference is unset, set the length to be longer than the amount
854
of subject left; this ensures that every attempt at a match fails. We
855
can't just fail here, because of the possibility of quantifiers with zero
858
length = (offset >= offset_top || md->offset_vector[offset] < 0)?
859
md->end_subject - eptr + 1 :
860
md->offset_vector[offset+1] - md->offset_vector[offset];
862
/* Set up for repetition, or handle the non-repeated case */
872
c = *ecode++ - OP_CRSTAR;
873
minimize = (c & 1) != 0;
874
min = rep_min[c]; /* Pick up values from tables; */
875
max = rep_max[c]; /* zero for max => infinity */
876
if (max == 0) max = INT_MAX;
881
minimize = (*ecode == OP_CRMINRANGE);
882
min = (ecode[1] << 8) + ecode[2];
883
max = (ecode[3] << 8) + ecode[4];
884
if (max == 0) max = INT_MAX;
888
default: /* No repeat follows */
889
if (!match_ref(offset, eptr, length, md, ims)) return FALSE;
891
continue; /* With the main loop */
894
/* If the length of the reference is zero, just continue with the
897
if (length == 0) continue;
899
/* First, ensure the minimum number of matches are present. We get back
900
the length of the reference string explicitly rather than passing the
901
address of eptr, so that eptr can be a register variable. */
903
for (i = 1; i <= min; i++)
905
if (!match_ref(offset, eptr, length, md, ims)) return FALSE;
909
/* If min = max, continue at the same level without recursion.
910
They are not both allowed to be zero. */
912
if (min == max) continue;
914
/* If minimizing, keep trying and advancing the pointer */
920
if (match(eptr, ecode, offset_top, md, ims, eptrb, 0))
922
if (i >= max || !match_ref(offset, eptr, length, md, ims))
926
/* Control never gets here */
929
/* If maximizing, find the longest string and work backwards */
933
const uschar *pp = eptr;
934
for (i = min; i < max; i++)
936
if (!match_ref(offset, eptr, length, md, ims)) break;
941
if (match(eptr, ecode, offset_top, md, ims, eptrb, 0))
948
/* Control never gets here */
952
/* Match a character class, possibly repeatedly. Look past the end of the
953
item to see if there is repeat information following. Then obey similar
954
code to character type repeats - written out again for speed. */
958
const uschar *data = ecode + 1; /* Save for matching */
959
ecode += 33; /* Advance past the item */
969
c = *ecode++ - OP_CRSTAR;
970
minimize = (c & 1) != 0;
971
min = rep_min[c]; /* Pick up values from tables; */
972
max = rep_max[c]; /* zero for max => infinity */
973
if (max == 0) max = INT_MAX;
978
minimize = (*ecode == OP_CRMINRANGE);
979
min = (ecode[1] << 8) + ecode[2];
980
max = (ecode[3] << 8) + ecode[4];
981
if (max == 0) max = INT_MAX;
985
default: /* No repeat follows */
990
/* First, ensure the minimum number of matches are present. */
992
for (i = 1; i <= min; i++)
994
if (eptr >= md->end_subject) return FALSE;
995
GETCHARINC(c, eptr) /* Get character; increment eptr */
998
/* We do not yet support class members > 255 */
999
if (c > 255) return FALSE;
1002
if ((data[c/8] & (1 << (c&7))) != 0) continue;
1006
/* If max == min we can continue with the main loop without the
1009
if (min == max) continue;
1011
/* If minimizing, keep testing the rest of the expression and advancing
1012
the pointer while it matches the class. */
1018
if (match(eptr, ecode, offset_top, md, ims, eptrb, 0))
1020
if (i >= max || eptr >= md->end_subject) return FALSE;
1021
GETCHARINC(c, eptr) /* Get character; increment eptr */
1024
/* We do not yet support class members > 255 */
1025
if (c > 255) return FALSE;
1027
if ((data[c/8] & (1 << (c&7))) != 0) continue;
1030
/* Control never gets here */
1033
/* If maximizing, find the longest possible run, then work backwards. */
1037
const uschar *pp = eptr;
1039
for (i = min; i < max; i++)
1041
if (eptr >= md->end_subject) break;
1042
GETCHARLEN(c, eptr, len) /* Get character, set length if UTF-8 */
1045
/* We do not yet support class members > 255 */
1048
if ((data[c/8] & (1 << (c&7))) == 0) break;
1054
if (match(eptr--, ecode, offset_top, md, ims, eptrb, 0))
1064
/* Control never gets here */
1066
/* Match a run of characters */
1070
register int length = ecode[1];
1073
#ifdef DEBUG /* Sigh. Some compilers never learn. */
1074
if (eptr >= md->end_subject)
1075
PCRE_PRINTF("matching subject <null> against pattern ");
1078
PCRE_PRINTF("matching subject ");
1079
pchars(eptr, length, TRUE, md);
1080
PCRE_PRINTF(" against pattern ");
1082
pchars(ecode, length, FALSE, md);
1086
if (length > md->end_subject - eptr) return FALSE;
1087
if ((ims & PCRE_CASELESS) != 0)
1089
while (length-- > 0)
1090
if (md->lcc[*ecode++] != md->lcc[*eptr++])
1095
while (length-- > 0) if (*ecode++ != *eptr++) return FALSE;
1100
/* Match a single character repeatedly; different opcodes share code. */
1103
min = max = (ecode[1] << 8) + ecode[2];
1110
max = (ecode[1] << 8) + ecode[2];
1111
minimize = *ecode == OP_MINUPTO;
1121
c = *ecode++ - OP_STAR;
1122
minimize = (c & 1) != 0;
1123
min = rep_min[c]; /* Pick up values from tables; */
1124
max = rep_max[c]; /* zero for max => infinity */
1125
if (max == 0) max = INT_MAX;
1127
/* Common code for all repeated single-character matches. We can give
1128
up quickly if there are fewer than the minimum number of characters left in
1132
if (min > md->end_subject - eptr) return FALSE;
1135
/* The code is duplicated for the caseless and caseful cases, for speed,
1136
since matching characters is likely to be quite common. First, ensure the
1137
minimum number of matches are present. If min = max, continue at the same
1138
level without recursing. Otherwise, if minimizing, keep trying the rest of
1139
the expression and advancing one matching character if failing, up to the
1140
maximum. Alternatively, if maximizing, find the maximum number of
1141
characters and work backwards. */
1143
DPRINTF(("matching %c{%d,%d} against subject %.*s\n", c, min, max,
1146
if ((ims & PCRE_CASELESS) != 0)
1149
for (i = 1; i <= min; i++)
1150
if (c != md->lcc[*eptr++]) return FALSE;
1151
if (min == max) continue;
1156
if (match(eptr, ecode, offset_top, md, ims, eptrb, 0))
1158
if (i >= max || eptr >= md->end_subject ||
1159
c != md->lcc[*eptr++])
1162
/* Control never gets here */
1166
const uschar *pp = eptr;
1167
for (i = min; i < max; i++)
1169
if (eptr >= md->end_subject || c != md->lcc[*eptr]) break;
1173
if (match(eptr--, ecode, offset_top, md, ims, eptrb, 0))
1177
/* Control never gets here */
1180
/* Caseful comparisons */
1184
for (i = 1; i <= min; i++) if (c != *eptr++) return FALSE;
1185
if (min == max) continue;
1190
if (match(eptr, ecode, offset_top, md, ims, eptrb, 0))
1192
if (i >= max || eptr >= md->end_subject || c != *eptr++) return FALSE;
1194
/* Control never gets here */
1198
const uschar *pp = eptr;
1199
for (i = min; i < max; i++)
1201
if (eptr >= md->end_subject || c != *eptr) break;
1205
if (match(eptr--, ecode, offset_top, md, ims, eptrb, 0))
1210
/* Control never gets here */
1212
/* Match a negated single character */
1215
if (eptr >= md->end_subject) return FALSE;
1217
if ((ims & PCRE_CASELESS) != 0)
1219
if (md->lcc[*ecode++] == md->lcc[*eptr++]) return FALSE;
1223
if (*ecode++ == *eptr++) return FALSE;
1227
/* Match a negated single character repeatedly. This is almost a repeat of
1228
the code for a repeated single character, but I haven't found a nice way of
1229
commoning these up that doesn't require a test of the positive/negative
1230
option for each character match. Maybe that wouldn't add very much to the
1231
time taken, but character matching *is* what this is all about... */
1234
min = max = (ecode[1] << 8) + ecode[2];
1241
max = (ecode[1] << 8) + ecode[2];
1242
minimize = *ecode == OP_NOTMINUPTO;
1251
case OP_NOTMINQUERY:
1252
c = *ecode++ - OP_NOTSTAR;
1253
minimize = (c & 1) != 0;
1254
min = rep_min[c]; /* Pick up values from tables; */
1255
max = rep_max[c]; /* zero for max => infinity */
1256
if (max == 0) max = INT_MAX;
1258
/* Common code for all repeated single-character matches. We can give
1259
up quickly if there are fewer than the minimum number of characters left in
1263
if (min > md->end_subject - eptr) return FALSE;
1266
/* The code is duplicated for the caseless and caseful cases, for speed,
1267
since matching characters is likely to be quite common. First, ensure the
1268
minimum number of matches are present. If min = max, continue at the same
1269
level without recursing. Otherwise, if minimizing, keep trying the rest of
1270
the expression and advancing one matching character if failing, up to the
1271
maximum. Alternatively, if maximizing, find the maximum number of
1272
characters and work backwards. */
1274
DPRINTF(("negative matching %c{%d,%d} against subject %.*s\n", c, min, max,
1277
if ((ims & PCRE_CASELESS) != 0)
1280
for (i = 1; i <= min; i++)
1281
if (c == md->lcc[*eptr++]) return FALSE;
1282
if (min == max) continue;
1287
if (match(eptr, ecode, offset_top, md, ims, eptrb, 0))
1289
if (i >= max || eptr >= md->end_subject ||
1290
c == md->lcc[*eptr++])
1293
/* Control never gets here */
1297
const uschar *pp = eptr;
1298
for (i = min; i < max; i++)
1300
if (eptr >= md->end_subject || c == md->lcc[*eptr]) break;
1304
if (match(eptr--, ecode, offset_top, md, ims, eptrb, 0))
1308
/* Control never gets here */
1311
/* Caseful comparisons */
1315
for (i = 1; i <= min; i++) if (c == *eptr++) return FALSE;
1316
if (min == max) continue;
1321
if (match(eptr, ecode, offset_top, md, ims, eptrb, 0))
1323
if (i >= max || eptr >= md->end_subject || c == *eptr++) return FALSE;
1325
/* Control never gets here */
1329
const uschar *pp = eptr;
1330
for (i = min; i < max; i++)
1332
if (eptr >= md->end_subject || c == *eptr) break;
1336
if (match(eptr--, ecode, offset_top, md, ims, eptrb, 0))
1341
/* Control never gets here */
1343
/* Match a single character type repeatedly; several different opcodes
1344
share code. This is very similar to the code for single characters, but we
1345
repeat it in the interests of efficiency. */
1348
min = max = (ecode[1] << 8) + ecode[2];
1354
case OP_TYPEMINUPTO:
1356
max = (ecode[1] << 8) + ecode[2];
1357
minimize = *ecode == OP_TYPEMINUPTO;
1362
case OP_TYPEMINSTAR:
1364
case OP_TYPEMINPLUS:
1366
case OP_TYPEMINQUERY:
1367
c = *ecode++ - OP_TYPESTAR;
1368
minimize = (c & 1) != 0;
1369
min = rep_min[c]; /* Pick up values from tables; */
1370
max = rep_max[c]; /* zero for max => infinity */
1371
if (max == 0) max = INT_MAX;
1373
/* Common code for all repeated single character type matches */
1376
ctype = *ecode++; /* Code for the character type */
1378
/* First, ensure the minimum number of matches are present. Use inline
1379
code for maximizing the speed, and do the type test once at the start
1380
(i.e. keep it out of the loop). Also we can test that there are at least
1381
the minimum number of bytes before we start, except when doing '.' in
1382
UTF8 mode. Leave the test in in all cases; in the special case we have
1383
to test after each character. */
1385
if (min > md->end_subject - eptr) return FALSE;
1386
if (min > 0) switch(ctype)
1392
for (i = 1; i <= min; i++)
1394
if (eptr >= md->end_subject ||
1395
(*eptr++ == NEWLINE && (ims & PCRE_DOTALL) == 0))
1397
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
1402
/* Non-UTF8 can be faster */
1403
if ((ims & PCRE_DOTALL) == 0)
1404
{ for (i = 1; i <= min; i++) if (*eptr++ == NEWLINE) return FALSE; }
1409
for (i = 1; i <= min; i++)
1410
if ((md->ctypes[*eptr++] & ctype_digit) != 0) return FALSE;
1414
for (i = 1; i <= min; i++)
1415
if ((md->ctypes[*eptr++] & ctype_digit) == 0) return FALSE;
1418
case OP_NOT_WHITESPACE:
1419
for (i = 1; i <= min; i++)
1420
if ((md->ctypes[*eptr++] & ctype_space) != 0) return FALSE;
1424
for (i = 1; i <= min; i++)
1425
if ((md->ctypes[*eptr++] & ctype_space) == 0) return FALSE;
1428
case OP_NOT_WORDCHAR:
1429
for (i = 1; i <= min; i++)
1430
if ((md->ctypes[*eptr++] & ctype_word) != 0)
1435
for (i = 1; i <= min; i++)
1436
if ((md->ctypes[*eptr++] & ctype_word) == 0)
1441
/* If min = max, continue at the same level without recursing */
1443
if (min == max) continue;
1445
/* If minimizing, we have to test the rest of the pattern before each
1446
subsequent match. */
1452
if (match(eptr, ecode, offset_top, md, ims, eptrb, 0)) return TRUE;
1453
if (i >= max || eptr >= md->end_subject) return FALSE;
1459
if ((ims & PCRE_DOTALL) == 0 && c == NEWLINE) return FALSE;
1462
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
1467
if ((md->ctypes[c] & ctype_digit) != 0) return FALSE;
1471
if ((md->ctypes[c] & ctype_digit) == 0) return FALSE;
1474
case OP_NOT_WHITESPACE:
1475
if ((md->ctypes[c] & ctype_space) != 0) return FALSE;
1479
if ((md->ctypes[c] & ctype_space) == 0) return FALSE;
1482
case OP_NOT_WORDCHAR:
1483
if ((md->ctypes[c] & ctype_word) != 0) return FALSE;
1487
if ((md->ctypes[c] & ctype_word) == 0) return FALSE;
1491
/* Control never gets here */
1494
/* If maximizing it is worth using inline code for speed, doing the type
1495
test once at the start (i.e. keep it out of the loop). */
1499
const uschar *pp = eptr;
1504
/* Special code is required for UTF8, but when the maximum is unlimited
1505
we don't need it. */
1508
if (md->utf8 && max < INT_MAX)
1510
if ((ims & PCRE_DOTALL) == 0)
1512
for (i = min; i < max; i++)
1514
if (eptr >= md->end_subject || *eptr++ == NEWLINE) break;
1515
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
1520
for (i = min; i < max; i++)
1523
while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
1529
/* Non-UTF8 can be faster */
1530
if ((ims & PCRE_DOTALL) == 0)
1532
for (i = min; i < max; i++)
1534
if (eptr >= md->end_subject || *eptr == NEWLINE) break;
1541
if (c > md->end_subject - eptr) c = md->end_subject - eptr;
1547
for (i = min; i < max; i++)
1549
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) != 0)
1556
for (i = min; i < max; i++)
1558
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) == 0)
1564
case OP_NOT_WHITESPACE:
1565
for (i = min; i < max; i++)
1567
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) != 0)
1574
for (i = min; i < max; i++)
1576
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) == 0)
1582
case OP_NOT_WORDCHAR:
1583
for (i = min; i < max; i++)
1585
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) != 0)
1592
for (i = min; i < max; i++)
1594
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) == 0)
1603
if (match(eptr--, ecode, offset_top, md, ims, eptrb, 0))
1607
while (eptr > pp && (*eptr & 0xc0) == 0x80) eptr--;
1612
/* Control never gets here */
1614
/* There's been some horrible disaster. */
1617
DPRINTF(("Unknown opcode %d\n", *ecode));
1618
md->errorcode = PCRE_ERROR_UNKNOWN_NODE;
1622
/* Do not stick any code in here without much thought; it is assumed
1623
that "continue" in the code above comes out to here to repeat the main
1626
} /* End of main loop */
1627
/* Control never reaches here */
1631
/*************************************************
1632
* Execute a Regular Expression *
1633
*************************************************/
1635
/* This function applies a compiled re to a subject string and picks out
1636
portions of the string if it matches. Two elements in the vector are set for
1637
each substring: the offsets to the start and end of the substring.
1640
external_re points to the compiled expression
1641
external_extra points to "hints" from pcre_study() or is NULL
1642
subject points to the subject string
1643
length length of subject string (may contain binary zeros)
1644
start_offset where to start in the subject string
1646
offsets points to a vector of ints to be filled in with offsets
1647
offsetcount the number of elements in the vector
1649
Returns: > 0 => success; value is the number of elements filled in
1650
= 0 => success, but offsets is not big enough
1651
-1 => failed to match
1652
< -1 => some kind of unexpected problem
1656
pcre_exec(const pcre *external_re, const pcre_extra *external_extra,
1657
const char *subject, int length, int start_offset, int options, int *offsets,
1660
int resetcount, ocount;
1661
int first_char = -1;
1664
unsigned long int ims = 0;
1665
match_data match_block;
1666
const uschar *start_bits = NULL;
1667
const uschar *start_match = (const uschar *)subject + start_offset;
1668
const uschar *end_subject;
1669
const uschar *req_char_ptr = start_match - 1;
1670
const real_pcre *re = (const real_pcre *)external_re;
1671
const real_pcre_extra *extra = (const real_pcre_extra *)external_extra;
1672
BOOL using_temporary_offsets = FALSE;
1676
if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;
1678
if (re == NULL || subject == NULL ||
1679
(offsets == NULL && offsetcount > 0)) return PCRE_ERROR_NULL;
1680
if (re->magic_number != MAGIC_NUMBER) return PCRE_ERROR_BADMAGIC;
1682
anchored = ((re->options | options) & PCRE_ANCHORED) != 0;
1683
startline = (re->options & PCRE_STARTLINE) != 0;
1685
match_block.start_pattern = re->code;
1686
match_block.start_subject = (const uschar *)subject;
1687
match_block.end_subject = match_block.start_subject + length;
1688
end_subject = match_block.end_subject;
1690
match_block.endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
1691
match_block.utf8 = (re->options & PCRE_UTF8) != 0;
1693
match_block.notbol = (options & PCRE_NOTBOL) != 0;
1694
match_block.noteol = (options & PCRE_NOTEOL) != 0;
1695
match_block.notempty = (options & PCRE_NOTEMPTY) != 0;
1697
match_block.errorcode = PCRE_ERROR_NOMATCH; /* Default error */
1699
match_block.lcc = re->tables + lcc_offset;
1700
match_block.ctypes = re->tables + ctypes_offset;
1702
/* The ims options can vary during the matching as a result of the presence
1703
of (?ims) items in the pattern. They are kept in a local variable so that
1704
restoring at the exit of a group is easy. */
1706
ims = re->options & (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL);
1708
/* If the expression has got more back references than the offsets supplied can
1709
hold, we get a temporary bit of working store to use during the matching.
1710
Otherwise, we can use the vector supplied, rounding down its size to a multiple
1713
ocount = offsetcount - (offsetcount % 3);
1715
if (re->top_backref > 0 && re->top_backref >= ocount/3)
1717
ocount = re->top_backref * 3 + 3;
1718
match_block.offset_vector = (int *)(pcre_malloc)(ocount * sizeof(int));
1719
if (match_block.offset_vector == NULL) return PCRE_ERROR_NOMEMORY;
1720
using_temporary_offsets = TRUE;
1721
DPRINTF(("Got memory to hold back references\n"));
1723
else match_block.offset_vector = offsets;
1725
match_block.offset_end = ocount;
1726
match_block.offset_max = (2*ocount)/3;
1727
match_block.offset_overflow = FALSE;
1729
/* Compute the minimum number of offsets that we need to reset each time. Doing
1730
this makes a huge difference to execution time when there aren't many brackets
1733
resetcount = 2 + re->top_bracket * 2;
1734
if (resetcount > offsetcount) resetcount = ocount;
1736
/* Reset the working variable associated with each extraction. These should
1737
never be used unless previously set, but they get saved and restored, and so we
1738
initialize them to avoid reading uninitialized locations. */
1740
if (match_block.offset_vector != NULL)
1742
register int *iptr = match_block.offset_vector + ocount;
1743
register int *iend = iptr - resetcount/2 + 1;
1744
while (--iptr >= iend) *iptr = -1;
1747
/* Set up the first character to match, if available. The first_char value is
1748
never set for an anchored regular expression, but the anchoring may be forced
1749
at run time, so we have to test for anchoring. The first char may be unset for
1750
an unanchored pattern, of course. If there's no first char and the pattern was
1751
studied, there may be a bitmap of possible first characters. */
1755
if ((re->options & PCRE_FIRSTSET) != 0)
1757
first_char = re->first_char;
1758
if ((ims & PCRE_CASELESS) != 0) first_char = match_block.lcc[first_char];
1761
if (!startline && extra != NULL &&
1762
(extra->options & PCRE_STUDY_MAPPED) != 0)
1763
start_bits = extra->start_bits;
1766
/* For anchored or unanchored matches, there may be a "last known required
1767
character" set. If the PCRE_CASELESS is set, implying that the match starts
1768
caselessly, or if there are any changes of this flag within the regex, set up
1769
both cases of the character. Otherwise set the two values the same, which will
1770
avoid duplicate testing (which takes significant time). This covers the vast
1771
majority of cases. It will be suboptimal when the case flag changes in a regex
1772
and the required character in fact is caseful. */
1774
if ((re->options & PCRE_REQCHSET) != 0)
1776
req_char = re->req_char;
1777
req_char2 = ((re->options & (PCRE_CASELESS | PCRE_ICHANGED)) != 0)?
1778
(re->tables + fcc_offset)[req_char] : req_char;
1781
/* Loop for handling unanchored repeated matching attempts; for anchored regexs
1782
the loop runs just once. */
1787
register int *iptr = match_block.offset_vector;
1788
register int *iend = iptr + resetcount;
1790
/* Reset the maximum number of extractions we might see. */
1792
while (iptr < iend) *iptr++ = -1;
1794
/* Advance to a unique first char if possible */
1796
if (first_char >= 0)
1798
if ((ims & PCRE_CASELESS) != 0)
1799
while (start_match < end_subject &&
1800
match_block.lcc[*start_match] != first_char)
1803
while (start_match < end_subject && *start_match != first_char)
1807
/* Or to just after \n for a multiline match if possible */
1811
if (start_match > match_block.start_subject + start_offset)
1813
while (start_match < end_subject && start_match[-1] != NEWLINE)
1818
/* Or to a non-unique first char after study */
1820
else if (start_bits != NULL)
1822
while (start_match < end_subject)
1824
register int c = *start_match;
1825
if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++; else break;
1829
#ifdef DEBUG /* Sigh. Some compilers never learn. */
1830
PCRE_PRINTF(">>>> Match against: ");
1831
pchars(start_match, end_subject - start_match, TRUE, &match_block);
1835
/* If req_char is set, we know that that character must appear in the subject
1836
for the match to succeed. If the first character is set, req_char must be
1837
later in the subject; otherwise the test starts at the match point. This
1838
optimization can save a huge amount of backtracking in patterns with nested
1839
unlimited repeats that aren't going to match. We don't know what the state of
1840
case matching may be when this character is hit, so test for it in both its
1841
cases if necessary. However, the different cased versions will not be set up
1842
unless PCRE_CASELESS was given or the casing state changes within the regex.
1843
Writing separate code makes it go faster, as does using an autoincrement and
1844
backing off on a match. */
1848
register const uschar *p = start_match + ((first_char >= 0)? 1 : 0);
1850
/* We don't need to repeat the search if we haven't yet reached the
1851
place we found it at last time. */
1853
if (p > req_char_ptr)
1855
/* Do a single test if no case difference is set up */
1857
if (req_char == req_char2)
1859
while (p < end_subject)
1861
if (*p++ == req_char) { p--; break; }
1865
/* Otherwise test for either case */
1869
while (p < end_subject)
1871
register int pp = *p++;
1872
if (pp == req_char || pp == req_char2) { p--; break; }
1876
/* If we can't find the required character, break the matching loop */
1878
if (p >= end_subject) break;
1880
/* If we have found the required character, save the point where we
1881
found it, so that we don't search again next time round the loop if
1882
the start hasn't passed this character yet. */
1888
/* When a match occurs, substrings will be set for all internal extractions;
1889
we just need to set up the whole thing as substring 0 before returning. If
1890
there were too many extractions, set the return code to zero. In the case
1891
where we had to get some local store to hold offsets for backreferences, copy
1892
those back references that we can. In this case there need not be overflow
1893
if certain parts of the pattern were not used. */
1895
match_block.start_match = start_match;
1896
if (!match(start_match, re->code, 2, &match_block, ims, NULL, match_isgroup))
1899
/* Copy the offset information from temporary store if necessary */
1901
if (using_temporary_offsets)
1903
if (offsetcount >= 4)
1905
memcpy(offsets + 2, match_block.offset_vector + 2,
1906
(offsetcount - 2) * sizeof(int));
1907
DPRINTF(("Copied offsets from temporary memory\n"));
1909
if (match_block.end_offset_top > offsetcount)
1910
match_block.offset_overflow = TRUE;
1912
DPRINTF(("Freeing temporary memory\n"));
1913
(pcre_free)(match_block.offset_vector);
1916
rc = match_block.offset_overflow? 0 : match_block.end_offset_top/2;
1918
if (offsetcount < 2) rc = 0; else
1920
offsets[0] = start_match - match_block.start_subject;
1921
offsets[1] = match_block.end_match_ptr - match_block.start_subject;
1924
DPRINTF((">>>> returning %d\n", rc));
1928
/* This "while" is the end of the "do" above */
1931
match_block.errorcode == PCRE_ERROR_NOMATCH &&
1932
start_match++ < end_subject);
1934
if (using_temporary_offsets)
1936
DPRINTF(("Freeing temporary memory\n"));
1937
(pcre_free)(match_block.offset_vector);
1940
DPRINTF((">>>> returning %d\n", match_block.errorcode));
1942
return match_block.errorcode;