VirtualBox

source: kBuild/vendor/sed/current/testsuite/uniq.good

Last change on this file was 599, checked in by bird, 18 years ago

GNU sed 4.1.5.

File size: 36.0 KB
Line 
1
2#define DPRINTF(p) /*nothing */
3#define DPRINTF(p) printf p
4#define GETCHAR(c, eptr) c = *eptr;
5#define GETCHARINC(c, eptr) c = *eptr++;
6#define class pcre_class
7#define match_condassert 0x01 /* Called to check a condition assertion */
8#define match_isgroup 0x02 /* Set if start of bracketed group */
9#else
10#endif
11#ifdef DEBUG /* Sigh. Some compilers never learn. */
12#ifdef DEBUG
13#ifdef __cplusplus
14#include "internal.h"
15&& length - re->max_match_size > start_offset)
16((*ecode++ == OP_BEG_WORD) ? prev_is_word : cur_is_word))
17((md->ctypes[*eptr] & ctype_word) != 0);
18((md->ctypes[eptr[-1]] & ctype_word) != 0);
19(eptr == md->end_subject - 1 && *eptr != '\n'))
20(i.e. keep it out of the loop). Also we can test that there are at least
21(md->ctypes[*eptr++] & ctype_digit) != 0)
22(md->ctypes[*eptr++] & ctype_digit) == 0)
23(md->ctypes[*eptr++] & ctype_space) != 0)
24(md->ctypes[*eptr++] & ctype_space) == 0)
25(md->ctypes[*eptr++] & ctype_word) != 0)
26(md->ctypes[*eptr++] & ctype_word) == 0)
27(offsetcount - 2) * sizeof (int));
28(offsets == NULL && offsetcount > 0))
29(pcre_free) (match_block.offset_vector);
30(pcre_free) (save);
31(re->tables + fcc_offset)[req_char] : req_char;
32* Match a back-reference *
33* Execute a Regular Expression *
34* Match from current position *
35* Debugging function to print chars *
36* Perl-Compatible Regular Expressions *
37* Macros and tables for character handling *
38*************************************************/
39*/
40*iptr = -1;
41*iptr++ = -1;
42*prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT ||
43*prev == OP_ONCE)
44-----------------------------------------------------------------------------
45-1 => failed to match
46/*
47/* "Once" brackets are like assertion brackets except that after a match,
48/* ... else fall through */
49/* Advance to a possible match for an initial string after study */
50/* Allow compilation as C++ source code, should anybody want to do that. */
51/* Always fail if not enough characters left */
52/* An alternation is the end of a branch; scan along to find the end of the
53/* Assert before internal newline if multiline, or before a terminating
54/* Assertion brackets. Check the alternative branches in turn - the
55/* At the start of a bracketed group, add the current subject pointer to the
56/* BRAZERO and BRAMINZERO occur just before a bracket group, indicating
57/* Caseful comparisons */
58/* Change option settings */
59/* Common code for all repeated single character type matches */
60/* Common code for all repeated single-character matches. We can give
61/* Compute the minimum number of offsets that we need to reset each time. Doing
62/* Conditional group: compilation checked that there are no more than
63/* Continue as from after the assertion, updating the offsets high water
64/* Continue from after the assertion, updating the offsets high water
65/* Control never gets here */
66/* Control never reaches here */
67/* Copy the offset information from temporary store if necessary */
68/* Do a single test if no case difference is set up */
69/* Do not stick any code in here without much thought; it is assumed
70/* End of a group, repeated or non-repeating. If we are at the end of
71/* End of subject assertion (\z) */
72/* End of subject or ending \n assertion (\Z) */
73/* End of the pattern. If PCRE_NOTEMPTY is set, fail if we have matched
74/* First, ensure the minimum number of matches are present. */
75/* First, ensure the minimum number of matches are present. Use inline
76/* First, ensure the minimum number of matches are present. We get back
77/* Flag bits for the match() function */
78/* For a non-repeating ket, just continue at this level. This also
79/* For anchored or unanchored matches, there may be a "last known required
80/* For extended extraction brackets (large number), we have to fish out
81/* For extended extraction brackets (large number), we have to fish out the
82/* For matches anchored to the end of the pattern, we can often avoid
83/* If a back reference hasn't been set, the length that is passed is greater
84/* If checking an assertion for a condition, return TRUE. */
85/* If hit the end of the group (which could be repeated), fail */
86/* If max == min we can continue with the main loop without the
87/* If maximizing it is worth using inline code for speed, doing the type
88/* If maximizing, find the longest possible run, then work backwards. */
89/* If maximizing, find the longest string and work backwards */
90/* If min = max, continue at the same level without recursing */
91/* If min = max, continue at the same level without recursion.
92/* If minimizing, keep testing the rest of the expression and advancing
93/* If minimizing, keep trying and advancing the pointer */
94/* If minimizing, we have to test the rest of the pattern before each
95/* If req_char is set, we know that that character must appear in the subject
96/* If the expression has got more back references than the offsets supplied can
97/* If the length of the reference is zero, just continue with the
98/* If the reference is unset, set the length to be longer than the amount
99/* If we can't find the required character, break the matching loop */
100/* If we have found the required character, save the point where we
101/* In all other cases except a conditional group we have to check the
102/* In case the recursion has set more capturing values, save the final
103/* Include the internals header, which itself includes Standard C headers plus
104/* Insufficient room for saving captured contents */
105/* Loop for handling unanchored repeated matching attempts; for anchored regexs
106/* Match a back reference, possibly repeatedly. Look past the end of the
107/* Match a character class, possibly repeatedly. Look past the end of the
108/* Match a negated single character */
109/* Match a negated single character repeatedly. This is almost a repeat of
110/* Match a run of characters */
111/* Match a single character repeatedly; different opcodes share code. */
112/* Match a single character type repeatedly; several different opcodes
113/* Match a single character type; inline for speed */
114/* Min and max values for the common repeats; for the maxima, 0 => infinity */
115/* Move the subject pointer back. This occurs only at the start of
116/* Negative assertion: all branches must fail to match */
117/* Now start processing the operations. */
118/* OP_KETRMAX */
119/* On entry ecode points to the first opcode, and eptr to the first character
120/* Opening capturing bracket. If there is space in the offset vector, save
121/* Or to a non-unique first char after study */
122/* Or to a unique first char if possible */
123/* Or to just after \n for a multiline match if possible */
124/* Other types of node can be handled by a switch */
125/* Otherwise test for either case */
126/* Print a sequence of chars in printable format, stopping at the end of the
127/* Recursion matches the current regex, nested. If there are any capturing
128/* Reset the maximum number of extractions we might see. */
129/* Reset the value of the ims flags, in case they got changed during
130/* Reset the working variable associated with each extraction. These should
131/* Separate the caselesss case for speed */
132/* Set up for repetition, or handle the non-repeated case */
133/* Set up the first character to match, if available. The first_char value is
134/* Skip over conditional reference data or large extraction number data if
135/* Start of subject assertion */
136/* Start of subject unless notbol, or after internal newline if multiline */
137/* Structure for building a chain of data that actually lives on the
138/* The code is duplicated for the caseless and caseful cases, for speed,
139/* The condition is an assertion. Call match() to evaluate it - setting
140/* The ims options can vary during the matching as a result of the presence
141/* The repeating kets try the rest of the pattern or restart from the
142/* There's been some horrible disaster. */
143/* This "while" is the end of the "do" above */
144/* This function applies a compiled re to a subject string and picks out
145/* Use a macro for debugging printing, 'cause that limits the use of #ifdef
146/* We don't need to repeat the search if we haven't yet reached the
147/* When a match occurs, substrings will be set for all internal extractions;
148/* Word boundary assertions */
149/*************************************************
1501. This software is distributed in the hope that it will be useful,
1512. The origin of this software must not be misrepresented, either by
1523. Altered versions must be plainly marked as such, and must not be
1534. If PCRE is embedded in any software that is released under the GNU
1545.005. If there is an options reset, it will get obeyed in the normal
1556 : 3 + (ecode[1] << 8) + ecode[2]),
156< -1 => some kind of unexpected problem
157= 0 => success, but offsets is not big enough
158Arguments:
159BOOL anchored;
160BOOL cur_is_word = (eptr < md->end_subject) &&
161BOOL is_subject;
162BOOL minimize = FALSE;
163BOOL prev_is_word = (eptr != md->start_subject) &&
164BOOL rc;
165BOOL startline;
166BOOL using_temporary_offsets = FALSE;
167Copyright (c) 1997-2000 University of Cambridge
168DPRINTF ((">>>> returning %d\n", match_block.errorcode));
169DPRINTF ((">>>> returning %d\n", rc));
170DPRINTF (("Copied offsets from temporary memory\n"));
171DPRINTF (("Freeing temporary memory\n"));
172DPRINTF (("Got memory to hold back references\n"));
173DPRINTF (("Unknown opcode %d\n", *ecode));
174DPRINTF (("bracket %d failed\n", number));
175DPRINTF (("bracket 0 failed\n"));
176DPRINTF (("ims reset to %02lx\n", ims));
177DPRINTF (("ims set to %02lx at group repeat\n", ims));
178DPRINTF (("ims set to %02lx\n", ims));
179DPRINTF (("matching %c{%d,%d} against subject %.*s\n", c, min, max,
180DPRINTF (("negative matching %c{%d,%d} against subject %.*s\n", c, min, max,
181DPRINTF (("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
182DPRINTF (("start bracket 0\n"));
183GETCHAR (c, eptr) /* Get character */
184GETCHARINC (c, eptr) /* Get character; increment eptr */
185General Purpose Licence (GPL), then the terms of that licence shall
186However, if the referenced string is the empty string, always treat
187If the bracket fails to match, we need to restore this value and also the
188If there isn't enough space in the offset vector, treat this as if it were a
189MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
190Otherwise, we can use the vector supplied, rounding down its size to a multiple
191Permission is granted to anyone to use this software for any purpose on any
192REPEATCHAR:
193REPEATNOTCHAR:
194REPEATTYPE:
195Returns: > 0 => success; value is the number of elements filled in
196Returns: TRUE if matched
197Returns: TRUE if matched
198Returns: nothing
199They are not both allowed to be zero. */
200This is a library of functions to support regular expressions whose syntax
201This is the forcible breaking of infinite loops as implemented in Perl
202Writing separate code makes it go faster, as does using an autoincrement and
203Written by: Philip Hazel <ph10@cam.ac.uk>
204a move back into the brackets. Check the alternative branches in turn - the
205address of eptr, so that eptr can be a register variable. */
206an assertion "group", stop matching and return TRUE, but record the
207an empty string - recursion will then try other alternatives, if any. */
208an error. Save the top 15 values on the stack, and accept that the rest
209an unanchored pattern, of course. If there's no first char and the pattern was
210analyzing most of the pattern. length > re->max_match_size is
211anchored = ((re->options | options) & PCRE_ANCHORED) != 0;
212and advance one byte in the pattern code. */
213and reinstate them after the recursion. However, we don't know how many
214and semantics are as close as possible to those of the Perl 5 language. See
215and the required character in fact is caseful. */
216at run time, so we have to test for anchoring. The first char may be unset for
217avoid duplicate testing (which takes significant time). This covers the vast
218backing off on a match. */
219bmtable = extra->data.bmtable;
220both cases of the character. Otherwise set the two values the same, which will
221bracketed group and go to there. */
222brackets - for testing for empty matches
223brackets started but not finished, we have to save their starting points
224break;
225but WITHOUT ANY WARRANTY; without even the implied warranty of
226c != md->lcc[*eptr++])
227c = *ecode++ - OP_CRSTAR;
228c = *ecode++ - OP_NOTSTAR;
229c = *ecode++ - OP_STAR;
230c = *ecode++ - OP_TYPESTAR;
231c = *ecode++;
232c = *eptr++;
233c = 15;
234c = max - min;
235c = md->end_subject - eptr;
236c = md->lcc[c];
237c = md->offset_max;
238c == md->lcc[*eptr++])
239can't just fail here, because of the possibility of quantifiers with zero
240case OP_ALT:
241case OP_ANY:
242case OP_ASSERT:
243case OP_ASSERTBACK:
244case OP_ASSERTBACK_NOT:
245case OP_ASSERT_NOT:
246case OP_BEG_WORD:
247case OP_BRA: /* Non-capturing bracket: optimized */
248case OP_BRAMINZERO:
249case OP_BRANUMBER:
250case OP_BRAZERO:
251case OP_CHARS:
252case OP_CIRC:
253case OP_CLASS:
254case OP_COND:
255case OP_CREF:
256case OP_CRMINPLUS:
257case OP_CRMINQUERY:
258case OP_CRMINRANGE:
259case OP_CRMINSTAR:
260case OP_CRPLUS:
261case OP_CRQUERY:
262case OP_CRRANGE:
263case OP_CRSTAR:
264case OP_DIGIT:
265case OP_DOLL:
266case OP_END:
267case OP_END_WORD:
268case OP_EOD:
269case OP_EODN:
270case OP_EXACT:
271case OP_KET:
272case OP_KETRMAX:
273case OP_KETRMIN:
274case OP_MINPLUS:
275case OP_MINQUERY:
276case OP_MINSTAR:
277case OP_MINUPTO:
278case OP_NOT:
279case OP_NOTEXACT:
280case OP_NOTMINPLUS:
281case OP_NOTMINQUERY:
282case OP_NOTMINSTAR:
283case OP_NOTMINUPTO:
284case OP_NOTPLUS:
285case OP_NOTQUERY:
286case OP_NOTSTAR:
287case OP_NOTUPTO:
288case OP_NOT_DIGIT:
289case OP_NOT_WHITESPACE:
290case OP_NOT_WORDCHAR:
291case OP_NOT_WORD_BOUNDARY:
292case OP_ONCE:
293case OP_OPT:
294case OP_PLUS:
295case OP_QUERY:
296case OP_RECURSE:
297case OP_REF:
298case OP_REVERSE:
299case OP_SOD:
300case OP_STAR:
301case OP_TYPEEXACT:
302case OP_TYPEMINPLUS:
303case OP_TYPEMINQUERY:
304case OP_TYPEMINSTAR:
305case OP_TYPEMINUPTO:
306case OP_TYPEPLUS:
307case OP_TYPEQUERY:
308case OP_TYPESTAR:
309case OP_TYPEUPTO:
310case OP_UPTO:
311case OP_WHITESPACE:
312case OP_WORDCHAR:
313case OP_WORD_BOUNDARY:
314case matching may be when this character is hit, so test for it in both its
315caselessly, or if there are any changes of this flag within the regex, set up
316cases if necessary. However, the different cased versions will not be set up
317character" set. If the PCRE_CASELESS is set, implying that the match starts
318characters and work backwards. */
319code for maximizing the speed, and do the type test once at the start
320code to character type repeats - written out again for speed. */
321commoning these up that doesn't require a test of the positive/negative
322computer system, and to redistribute it freely, subject to the following
323const char *subject;
324const pcre *re;
325const pcre_extra *extra;
326const uschar *bmtable = NULL;
327const uschar *data = ecode + 1; /* Save for matching */
328const uschar *end_subject;
329const uschar *next = ecode + 1;
330const uschar *p = md->start_subject + md->offset_vector[offset];
331const uschar *p;
332const uschar *pp = eptr;
333const uschar *prev = ecode - (ecode[1] << 8) - ecode[2];
334const uschar *prev = ecode;
335const uschar *req_char_ptr = start_match - 1;
336const uschar *saved_eptr = eptr;
337const uschar *saved_eptr = eptrb->saved_eptr;
338const uschar *saved_eptr;
339const uschar *start_bits = NULL;
340const uschar *start_match = (const uschar *) subject + start_offset;
341continue; /* With the main loop */
342continue;
343course of events. */
344ctype = *ecode++; /* Code for the character type */
345cur_is_word == prev_is_word : cur_is_word != prev_is_word)
346current high water mark for use by positive assertions. Do this also
347default: /* No repeat follows */
348default:
349do
350each branch of a lookbehind assertion. If we are too close to the start to
351each substring: the offsets to the start and end of the substring.
352ecode position in code
353ecode + ((offset < offset_top && md->offset_vector[offset] >= 0) ?
354ecode += (ecode[1] << 8) + ecode[2];
355ecode += 2;
356ecode += 3 + (ecode[4] << 8) + ecode[5];
357ecode += 33; /* Advance past the item */
358ecode += 3; /* Advance past the item */
359ecode += 3;
360ecode += 5;
361ecode = next + 3;
362ecode++;
363else
364else if ((extra->options & PCRE_STUDY_BM) != 0)
365else if (first_char >= 0)
366else if (start_bits != NULL)
367else if (startline)
368encountered */
369end_subject = match_block.end_subject;
370eptr pointer in subject
371eptr points into the subject
372eptr += c;
373eptr += length;
374eptr += min;
375eptr -= (ecode[1] << 8) + ecode[2];
376eptr -= length;
377eptr = md->end_match_ptr;
378eptr++;
379eptrb pointer to chain of blocks containing eptr at start of
380eptrb = &newptrb;
381eptrb = eptrb->prev; /* Back up the stack of bracket start pointers */
382eptrblock *eptrb;
383eptrblock newptrb;
384eptrblock;
385exactly what going to the ket would do. */
386explicit claim or by omission.
387external_extra points to "hints" from pcre_study() or is NULL
388external_re points to the compiled expression
389extraction by setting the offsets and bumping the high water mark. */
390first_char = match_block.lcc[first_char];
391first_char = re->first_char;
392flags can contain
393for (;;)
394for (i = 1; i <= c; i++)
395for (i = 1; i <= min; i++)
396for (i = min; i < max; i++)
397for (i = min;; i++)
398for the "once" (not-backup up) groups. */
399for the match to succeed. If the first character is set, req_char must be
400found it, so that we don't search again next time round the loop if
401from a previous iteration of this group, and be referred to by a reference
402goto REPEATCHAR;
403goto REPEATNOTCHAR;
404goto REPEATTYPE;
405group number back at the start and if necessary complete handling an
406happens for a repeating ket if no characters were matched in the group.
407here; that is handled in the code for KET. */
408hold, we get a temporary bit of working store to use during the matching.
409i.e. it could be ()* or ()? in the pattern. Brackets with fixed upper
410if (!anchored)
411if (!match (start_match, re->code, 2, &match_block, ims, NULL, match_isgroup))
412if (!match_ref (offset, eptr, length, md, ims))
413if (!md->endonly)
414if (!rc)
415if (!startline && extra != NULL)
416if ((*ecode++ == OP_WORD_BOUNDARY) ?
417if ((data[c / 8] & (1 << (c & 7))) != 0)
418if ((data[c / 8] & (1 << (c & 7))) == 0)
419if ((extra->options & PCRE_STUDY_MAPPED) != 0)
420if ((flags & match_condassert) != 0)
421if ((flags & match_isgroup) != 0)
422if ((ims & PCRE_CASELESS) != 0)
423if ((ims & PCRE_DOTALL) == 0 && c == '\n')
424if ((ims & PCRE_DOTALL) == 0 && eptr < md->end_subject && *eptr == '\n')
425if ((ims & PCRE_DOTALL) == 0)
426if ((ims & PCRE_MULTILINE) != 0)
427if ((md->ctypes[*eptr++] & ctype_digit) != 0)
428if ((md->ctypes[*eptr++] & ctype_digit) == 0)
429if ((md->ctypes[*eptr++] & ctype_space) != 0)
430if ((md->ctypes[*eptr++] & ctype_space) == 0)
431if ((md->ctypes[*eptr++] & ctype_word) != 0)
432if ((md->ctypes[*eptr++] & ctype_word) == 0)
433if ((md->ctypes[c] & ctype_digit) != 0)
434if ((md->ctypes[c] & ctype_digit) == 0)
435if ((md->ctypes[c] & ctype_space) != 0)
436if ((md->ctypes[c] & ctype_space) == 0)
437if ((md->ctypes[c] & ctype_word) != 0)
438if ((md->ctypes[c] & ctype_word) == 0)
439if ((options & ~PUBLIC_EXEC_OPTIONS) != 0)
440if ((re->options & PCRE_FIRSTSET) != 0)
441if ((re->options & PCRE_REQCHSET) != 0)
442if ((start_bits[c / 8] & (1 << (c & 7))) == 0)
443if (*ecode != OP_ONCE && *ecode != OP_ALT)
444if (*ecode == OP_KET || eptr == saved_eptr)
445if (*ecode == OP_KET)
446if (*ecode == OP_KETRMIN)
447if (*ecode++ != *eptr++)
448if (*ecode++ == *eptr++)
449if (*eptr != '\n')
450if (*eptr++ == '\n')
451if (*p++ != *eptr++)
452if (*p++ == req_char)
453if (*prev != OP_COND)
454if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT ||
455if (bmtable != NULL)
456if (bmtable[*start_match])
457if (c != *eptr++)
458if (c != md->lcc[*eptr++])
459if (c < 16)
460if (c == *eptr++)
461if (c == md->lcc[*eptr++])
462if (c > md->end_subject - eptr)
463if (cur_is_word == prev_is_word ||
464if (ecode[3] == OP_CREF) /* Condition is extraction test */
465if (ecode[3] == OP_OPT)
466if (eptr != md->start_subject && eptr[-1] != '\n')
467if (eptr != md->start_subject)
468if (eptr < md->end_subject - 1 ||
469if (eptr < md->end_subject)
470if (eptr < md->start_subject)
471if (eptr >= md->end_subject ||
472if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) != 0)
473if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) == 0)
474if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) != 0)
475if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) == 0)
476if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) != 0)
477if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) == 0)
478if (eptr >= md->end_subject || *eptr == '\n')
479if (eptr >= md->end_subject || c != *eptr)
480if (eptr >= md->end_subject || c != md->lcc[*eptr])
481if (eptr >= md->end_subject || c == *eptr)
482if (eptr >= md->end_subject || c == md->lcc[*eptr])
483if (eptr >= md->end_subject)
484if (eptr++ >= md->end_subject)
485if (i >= max || !match_ref (offset, eptr, length, md, ims))
486if (i >= max || eptr >= md->end_subject ||
487if (i >= max || eptr >= md->end_subject || c != *eptr++)
488if (i >= max || eptr >= md->end_subject || c == *eptr++)
489if (i >= max || eptr >= md->end_subject)
490if (is_subject && length > md->end_subject - p)
491if (isprint (c = *(p++)))
492if (length == 0)
493if (length > md->end_subject - eptr)
494if (match (eptr, ecode + 3, offset_top, md, ims, NULL,
495if (match (eptr, ecode + 3, offset_top, md, ims, NULL, match_isgroup))
496if (match (eptr, ecode + 3, offset_top, md, ims, eptrb, 0) ||
497if (match (eptr, ecode + 3, offset_top, md, ims, eptrb, match_isgroup))
498if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
499if (match (eptr, next + 3, offset_top, md, ims, eptrb, match_isgroup))
500if (match (eptr, next, offset_top, md, ims, eptrb, match_isgroup))
501if (match (eptr, prev, offset_top, md, ims, eptrb, match_isgroup) ||
502if (match (eptr--, ecode, offset_top, md, ims, eptrb, 0))
503if (match_block.end_offset_top > offsetcount)
504if (match_block.offset_vector != NULL)
505if (match_block.offset_vector == NULL)
506if (max == 0)
507if (md->lcc[*ecode++] != md->lcc[*eptr++])
508if (md->lcc[*ecode++] == md->lcc[*eptr++])
509if (md->lcc[*p++] != md->lcc[*eptr++])
510if (md->notbol && eptr == md->start_subject)
511if (md->notempty && eptr == md->start_match)
512if (md->noteol)
513if (min == max)
514if (min > 0)
515if (min > md->end_subject - eptr)
516if (minimize)
517if (number > 0)
518if (number > EXTRACT_BASIC_MAX)
519if (offset < md->offset_max)
520if (offset >= md->offset_max)
521if (offset_top <= offset)
522if (offsetcount < 2)
523if (offsetcount >= 4)
524if (op > OP_BRA)
525if (p > req_char_ptr)
526if (p >= end_subject)
527if (pp == req_char || pp == req_char2)
528if (re == NULL || subject == NULL ||
529if (re->magic_number != MAGIC_NUMBER)
530if (re->max_match_size >= 0
531if (re->top_backref > 0 && re->top_backref >= ocount / 3)
532if (req_char == req_char2)
533if (req_char >= 0)
534if (resetcount > offsetcount)
535if (save != stacksave)
536if (save == NULL)
537if (skipped_chars)
538if (start_match + bmtable[256] > end_subject)
539if (start_match > match_block.start_subject + start_offset)
540if (using_temporary_offsets)
541if certain parts of the pattern were not used. */
542if the malloc fails ... there is no way of returning to the top level with
543implied in the second condition, because start_offset > 0. */
544ims current /i, /m, and /s options
545ims the ims flags
546ims = (ims & ~PCRE_IMS) | ecode[4];
547ims = ecode[1];
548ims = original_ims;
549ims = re->options & (PCRE_CASELESS | PCRE_MULTILINE | PCRE_DOTALL);
550in the pattern. */
551in the subject string, while eptrb holds the value of eptr at the start of the
552initialize them to avoid reading uninitialized locations. */
553inline, and there are *still* stupid compilers about that don't like indented
554inside the group.
555int
556int *offsets;
557int *save;
558int c;
559int first_char = -1;
560int flags;
561int length;
562int min, max, ctype;
563int number = *prev - OP_BRA;
564int number = op - OP_BRA;
565int offset = (ecode[1] << 9) | (ecode[2] << 1); /* Doubled reference number */
566int offset = (ecode[4] << 9) | (ecode[5] << 1); /* Doubled reference number */
567int offset;
568int offset_top;
569int offsetcount;
570int op = (int) *ecode;
571int options;
572int rc;
573int req_char = -1;
574int req_char2 = -1;
575int resetcount, ocount;
576int save_offset1 = md->offset_vector[offset];
577int save_offset2 = md->offset_vector[offset + 1];
578int save_offset3 = md->offset_vector[md->offset_end - number];
579int skipped_chars = 0;
580int stacksave[15];
581int start_offset;
582is a bit large to put on the stack, but using malloc for small numbers
583is_subject TRUE if printing from within md->start_subject
584it as matched, any number of times (otherwise there could be infinite
585item to see if there is repeat information following. The code is similar
586item to see if there is repeat information following. Then obey similar
587last bracketed group - used for breaking infinite loops matching zero-length
588later in the subject; otherwise the test starts at the match point. This
589length length of subject string (may contain binary zeros)
590length length to be matched
591length number to print
592length = (offset >= offset_top || md->offset_vector[offset] < 0) ?
593length = md->end_subject - p;
594level without recursing. Otherwise, if minimizing, keep trying the rest of
595loop. */
596loops). */
597main loop. */
598majority of cases. It will be suboptimal when the case flag changes in a regex
599mark, since extracts may have been taken during the assertion. */
600mark, since extracts may have been taken. */
601match (eptr, ecode + 3, offset_top, md, ims, eptrb, 0))
602match (eptr, ecode, offset_top, md, ims, eptrb, flags)
603match (eptr, prev, offset_top, md, ims, eptrb, match_isgroup))
604match_block.ctypes = re->tables + ctypes_offset;
605match_block.end_subject = match_block.start_subject + length;
606match_block.endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
607match_block.errorcode = PCRE_ERROR_NOMATCH; /* Default error */
608match_block.errorcode == PCRE_ERROR_NOMATCH &&
609match_block.lcc = re->tables + lcc_offset;
610match_block.lcc[*start_match] != first_char)
611match_block.notbol = (options & PCRE_NOTBOL) != 0;
612match_block.notempty = (options & PCRE_NOTEMPTY) != 0;
613match_block.noteol = (options & PCRE_NOTEOL) != 0;
614match_block.offset_end = ocount;
615match_block.offset_max = (2 * ocount) / 3;
616match_block.offset_overflow = FALSE;
617match_block.offset_overflow = TRUE;
618match_block.offset_vector = (int *) (pcre_malloc) (ocount * sizeof (int));
619match_block.offset_vector = offsets;
620match_block.start_match = start_match;
621match_block.start_pattern = re->code;
622match_block.start_subject = (const uschar *) subject;
623match_condassert - this is an assertion condition
624match_condassert | match_isgroup))
625match_data *md;
626match_data match_block;
627match_isgroup - this is the start of a bracketed group
628match_isgroup);
629match_ref (offset, eptr, length, md, ims)
630matches, we carry on as at the end of a normal bracket, leaving the subject
631matching won't pass the KET for an assertion. If any one branch matches,
632matching won't pass the KET for this kind of subpattern. If any one branch
633max = (ecode[1] << 8) + ecode[2];
634max = (ecode[3] << 8) + ecode[4];
635max = INT_MAX;
636max = rep_max[c]; /* zero for max => infinity */
637max, eptr));
638maximum. Alternatively, if maximizing, find the maximum number of
639may be wrong. */
640md pointer to "static" info for the match
641md pointer to matching data block, if is_subject is TRUE
642md points to match data block
643md->end_match_ptr = eptr; /* For ONCE */
644md->end_match_ptr = eptr; /* Record where we ended */
645md->end_offset_top = offset_top; /* and how many extracts were taken */
646md->end_offset_top = offset_top;
647md->end_subject - eptr + 1 :
648md->errorcode = PCRE_ERROR_UNKNOWN_NODE;
649md->offset_overflow = TRUE;
650md->offset_vector[md->offset_end - i] = save[i];
651md->offset_vector[md->offset_end - number] = eptr - md->start_subject;
652md->offset_vector[md->offset_end - number] = save_offset3;
653md->offset_vector[md->offset_end - number];
654md->offset_vector[offset + 1] - md->offset_vector[offset];
655md->offset_vector[offset + 1] = eptr - md->start_subject;
656md->offset_vector[offset + 1] = save_offset2;
657md->offset_vector[offset] =
658md->offset_vector[offset] = save_offset1;
659memcpy (offsets + 2, match_block.offset_vector + 2,
660min = (ecode[1] << 8) + ecode[2];
661min = 0;
662min = max = (ecode[1] << 8) + ecode[2];
663min = max = 1;
664min = rep_min[c]; /* Pick up values from tables; */
665minima. */
666minimize = (*ecode == OP_CRMINRANGE);
667minimize = (c & 1) != 0;
668minimize = *ecode == OP_MINUPTO;
669minimize = *ecode == OP_NOTMINUPTO;
670minimize = *ecode == OP_TYPEMINUPTO;
671minimize = TRUE;
672minimum number of matches are present. If min = max, continue at the same
673misrepresented as being the original software.
674move back, this match function fails. */
675mustn't change the current values of the data slot, because they may be set
676need to recurse. */
677never be used unless previously set, but they get saved and restored, and so we
678never set for an anchored regular expression, but the anchoring may be forced
679newline unless endonly is set, else end of subject unless noteol is set. */
680newptrb.prev = eptrb;
681newptrb.saved_eptr = eptr;
682next += (next[1] << 8) + next[2];
683non-capturing bracket. Don't worry about setting the flag for the error case
684number = (ecode[4] << 8) | ecode[5];
685number = (prev[4] << 8) | prev[5];
686number from a dummy opcode at the start. */
687number, then move along the subject till after the recursive match,
688ocount = offsetcount - (offsetcount % 3);
689ocount = re->top_backref * 3 + 3;
690of (?ims) items in the pattern. They are kept in a local variable so that
691of 3. */
692of subject left; this ensures that every attempt at a match fails. We
693offset index into the offset vector
694offset = number << 1;
695offset_top current top pointer
696offset_top = md->end_offset_top;
697offset_top = offset + 2;
698offset_top, md, ims, eptrb, match_isgroup);
699offsetcount the number of elements in the vector
700offsets points to a vector of ints to be filled in with offsets
701offsets[0] = start_match - match_block.start_subject;
702offsets[1] = match_block.end_match_ptr - match_block.start_subject;
703op = OP_BRA;
704opcode. */
705optimization can save a huge amount of backtracking in patterns with nested
706option for each character match. Maybe that wouldn't add very much to the
707options option bits
708p points to characters
709p--;
710past the end if there is only one branch, but that's OK because that is
711pchars (ecode, length, FALSE, md);
712pchars (eptr, 16, TRUE, md);
713pchars (eptr, length, TRUE, md);
714pchars (p, length, FALSE, md);
715pchars (p, length, is_subject, md)
716pchars (start_match, end_subject - start_match, TRUE, &match_block);
717pcre_exec (re, extra, subject, length, start_offset, options, offsets, offsetcount)
718place we found it at last time. */
719pointer. */
720portions of the string if it matches. Two elements in the vector are set for
721pre-processor statements. I suppose it's only been 10 years... */
722preceded by BRAZERO or BRAMINZERO. */
723preceding bracket, in the appropriate order. */
724preceding bracket, in the appropriate order. We need to reset any options
725printf (" against backref ");
726printf (" against pattern ");
727printf ("%c", c);
728printf (">>>> Match against: ");
729printf (">>>>> Skipped %d chars to reach first character\n",
730printf ("\\x%02x", c);
731printf ("\n");
732printf ("end bracket %d", number);
733printf ("matching subject ");
734printf ("matching subject <null> against pattern ");
735printf ("matching subject <null>");
736printf ("start bracket %d subject=", number);
737rc = 0;
738rc = match (eptr, md->start_pattern, offset_top, md, ims, eptrb,
739rc = match_block.offset_overflow ? 0 : match_block.end_offset_top / 2;
740register const uschar *ecode;
741register const uschar *eptr;
742register const uschar *p = start_match + ((first_char >= 0) ? 1 : 0);
743register int *iend = iptr + resetcount;
744register int *iend = iptr - resetcount / 2 + 1;
745register int *iptr = match_block.offset_vector + ocount;
746register int *iptr = match_block.offset_vector;
747register int c = *start_match;
748register int c;
749register int i;
750register int length = ecode[1];
751register int pp = *p++;
752repeat it in the interests of efficiency. */
753repeat limits are compiled as a number of copies, with the optional ones
754req_char = re->req_char;
755req_char2 = ((re->options & (PCRE_CASELESS | PCRE_ICHANGED)) != 0) ?
756req_char_ptr = p;
757resetcount = 2 + re->top_bracket * 2;
758resetcount = ocount;
759restoring at the exit of a group is easy. */
760restrictions:
761return FALSE;
762return PCRE_ERROR_BADMAGIC;
763return PCRE_ERROR_BADOPTION;
764return PCRE_ERROR_NOMATCH;
765return PCRE_ERROR_NOMEMORY;
766return PCRE_ERROR_NULL;
767return TRUE;
768return match (eptr,
769return match (eptr, ecode + 3, offset_top, md, ims, eptrb, match_isgroup);
770return match_block.errorcode;
771return rc;
772save = (int *) (pcre_malloc) ((c + 1) * sizeof (int));
773save = stacksave;
774save[i] = md->offset_vector[md->offset_end - i];
775seems expensive. As a compromise, the stack is used when there are fewer
776share code. This is very similar to the code for single characters, but we
777similar code to character type repeats - written out again for speed.
778since matching characters is likely to be quite common. First, ensure the
779skipped_chars += bmtable[*start_match],
780skipped_chars += bmtable[256] - 1;
781skipped_chars -= bmtable[256] - 1;
782skipped_chars);
783skipped_chars++,
784stack of such pointers, to be re-instated at the end of the group when we hit
785stack, for holding the values of the subject pointer at the start of each
786start of each branch to move the current point backwards, so the code at
787start_bits = extra->data.start_bits;
788start_match += bmtable[*start_match];
789start_match += bmtable[256] - 1;
790start_match -= bmtable[256] - 1;
791start_match = (const uschar *) subject + length - re->max_match_size;
792start_match++ < end_subject);
793start_match++;
794start_offset where to start in the subject string
795startline = (re->options & PCRE_STARTLINE) != 0;
796static BOOL
797static const char rep_max[] =
798static const char rep_min[] =
799static void
800strings.
801struct eptrblock *prev;
802studied, there may be a bitmap of possible first characters. */
803subject points to the subject string
804subject if the requested.
805subpattern - to break infinite loops. */
806subpattern, so as to detect when an empty string has been matched by a
807subsequent match. */
808such there are (offset_top records the completed total) so we just have
809supersede any condition above with which it is incompatible.
810switch (*ecode)
811switch (ctype)
812switch (op)
813test once at the start (i.e. keep it out of the loop). */
814than 16 values to store; otherwise malloc is used. A problem is what to do
815than the number of characters left in the string, so the match fails.
816that "continue" in the code above comes out to here to repeat the main
817that changed within the bracket before re-running it, so check the next
818that it may occur zero times. It may repeat infinitely, or not at all -
819the assertion is true. Lookbehind assertions have an OP_REVERSE item at the
820the closing ket. When match() is called in other circumstances, we don't add to
821the code for a repeated single character, but I haven't found a nice way of
822the current subject position in the working slot at the top of the vector. We
823the expression and advancing one matching character if failing, up to the
824the external pcre header. */
825the file Tech.Notes for some information on the internals.
826the final argument TRUE causes it to stop at the end of an assertion. */
827the group. */
828the length of the reference string explicitly rather than passing the
829the loop runs just once. */
830the minimum number of bytes before we start. */
831the number from a dummy opcode at the start. */
832the point in the subject string is not moved back. Thus there can never be
833the pointer while it matches the class. */
834the same bracket.
835the stack. */
836the start hasn't passed this character yet. */
837the subject. */
838there were too many extractions, set the return code to zero. In the case
839this level is identical to the lookahead case. */
840this makes a huge difference to execution time when there aren't many brackets
841those back references that we can. In this case there need not be overflow
842time taken, but character matching *is* what this is all about... */
843to save all the potential data. There may be up to 99 such values, which
844to that for character classes, but repeated for efficiency. Then obey
845two branches. If the condition is false, skipping the first branch takes us
846typedef struct eptrblock
847unless PCRE_CASELESS was given or the casing state changes within the regex.
848unlimited repeats that aren't going to match. We don't know what the state of
849unsigned long int ims = 0;
850unsigned long int ims;
851unsigned long int original_ims = ims; /* Save for resetting on ')' */
852up quickly if there are fewer than the minimum number of characters left in
853using_temporary_offsets = TRUE;
854values of the final offsets, in case they were set by a previous iteration of
855we just need to set up the whole thing as substring 0 before returning. If
856where we had to get some local store to hold offsets for backreferences, copy
857while (!anchored &&
858while (*ecode == OP_ALT)
859while (*ecode == OP_ALT);
860while (*next == OP_ALT);
861while (--iptr >= iend)
862while (eptr >= pp)
863while (iptr < iend)
864while (length-- > 0)
865while (p < end_subject)
866while (start_match < end_subject &&
867while (start_match < end_subject && *start_match != first_char)
868while (start_match < end_subject && start_match[-1] != '\n')
869while (start_match < end_subject)
870{
871{0, 0, 0, 0, 1, 1};
872{0, 0, 1, 1, 0, 0};
873} /* End of main loop */
874}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette