Lines Matching full:pattern
202 LOCAL(Py_ssize_t) SRE(match)(SRE_STATE* state, const SRE_CODE* pattern, int toplevel);
205 SRE(count)(SRE_STATE* state, const SRE_CODE* pattern, Py_ssize_t maxcount) in SRE()
217 switch (pattern[0]) { in SRE()
221 TRACE(("|%p|%p|COUNT IN\n", pattern, ptr)); in SRE()
222 while (ptr < end && SRE(charset)(state, pattern + 2, *ptr)) in SRE()
228 TRACE(("|%p|%p|COUNT ANY\n", pattern, ptr)); in SRE()
236 TRACE(("|%p|%p|COUNT ANY_ALL\n", pattern, ptr)); in SRE()
242 chr = pattern[1]; in SRE()
243 TRACE(("|%p|%p|COUNT LITERAL %d\n", pattern, ptr, chr)); in SRE()
256 chr = pattern[1]; in SRE()
257 TRACE(("|%p|%p|COUNT LITERAL_IGNORE %d\n", pattern, ptr, chr)); in SRE()
264 chr = pattern[1]; in SRE()
265 TRACE(("|%p|%p|COUNT LITERAL_UNI_IGNORE %d\n", pattern, ptr, chr)); in SRE()
272 chr = pattern[1]; in SRE()
273 TRACE(("|%p|%p|COUNT LITERAL_LOC_IGNORE %d\n", pattern, ptr, chr)); in SRE()
280 chr = pattern[1]; in SRE()
281 TRACE(("|%p|%p|COUNT NOT_LITERAL %d\n", pattern, ptr, chr)); in SRE()
294 chr = pattern[1]; in SRE()
295 TRACE(("|%p|%p|COUNT NOT_LITERAL_IGNORE %d\n", pattern, ptr, chr)); in SRE()
302 chr = pattern[1]; in SRE()
303 TRACE(("|%p|%p|COUNT NOT_LITERAL_UNI_IGNORE %d\n", pattern, ptr, chr)); in SRE()
310 chr = pattern[1]; in SRE()
311 TRACE(("|%p|%p|COUNT NOT_LITERAL_LOC_IGNORE %d\n", pattern, ptr, chr)); in SRE()
317 /* repeated single character pattern */ in SRE()
318 TRACE(("|%p|%p|COUNT SUBPATTERN\n", pattern, ptr)); in SRE()
320 i = SRE(match)(state, pattern, 0); in SRE()
326 TRACE(("|%p|%p|COUNT %" PY_FORMAT_SIZE_T "d\n", pattern, ptr, in SRE()
331 TRACE(("|%p|%p|COUNT %" PY_FORMAT_SIZE_T "d\n", pattern, ptr, in SRE()
338 SRE(info)(SRE_STATE* state, const SRE_CODE* pattern)
349 if (pattern[3] && end - ptr < pattern[3])
353 if (pattern[2] & SRE_INFO_PREFIX && pattern[5] > 1) {
355 for (i = 0; i < pattern[5]; i++)
356 if ((SRE_CODE) ptr[i] != pattern[7 + i])
358 return pattern[0] + 2 * pattern[6];
360 return pattern[0];
517 nextctx->pattern = nextpattern; \
535 const SRE_CODE* pattern; member
546 /* check if string matches the given pattern. returns <0 for
549 SRE(match)(SRE_STATE* state, const SRE_CODE* pattern, int toplevel) in SRE()
560 TRACE(("|%p|%p|ENTER\n", pattern, state->ptr)); in SRE()
565 ctx->pattern = pattern; in SRE()
573 if (ctx->pattern[0] == SRE_OP_INFO) { in SRE()
576 if (ctx->pattern[3] && (uintptr_t)(end - ctx->ptr) < ctx->pattern[3]) { in SRE()
579 end - ctx->ptr, (Py_ssize_t) ctx->pattern[3])); in SRE()
582 ctx->pattern += ctx->pattern[1] + 1; in SRE()
590 switch (*ctx->pattern++) { in SRE()
595 TRACE(("|%p|%p|MARK %d\n", ctx->pattern, in SRE()
596 ctx->ptr, ctx->pattern[0])); in SRE()
597 i = ctx->pattern[0]; in SRE()
611 ctx->pattern++; in SRE()
617 TRACE(("|%p|%p|LITERAL %d\n", ctx->pattern, in SRE()
618 ctx->ptr, *ctx->pattern)); in SRE()
619 if (ctx->ptr >= end || (SRE_CODE) ctx->ptr[0] != ctx->pattern[0]) in SRE()
621 ctx->pattern++; in SRE()
628 TRACE(("|%p|%p|NOT_LITERAL %d\n", ctx->pattern, in SRE()
629 ctx->ptr, *ctx->pattern)); in SRE()
630 if (ctx->ptr >= end || (SRE_CODE) ctx->ptr[0] == ctx->pattern[0]) in SRE()
632 ctx->pattern++; in SRE()
637 /* end of pattern */ in SRE()
638 TRACE(("|%p|%p|SUCCESS\n", ctx->pattern, ctx->ptr)); in SRE()
651 TRACE(("|%p|%p|AT %d\n", ctx->pattern, ctx->ptr, *ctx->pattern)); in SRE()
652 if (!SRE(at)(state, ctx->ptr, *ctx->pattern)) in SRE()
654 ctx->pattern++; in SRE()
660 TRACE(("|%p|%p|CATEGORY %d\n", ctx->pattern, in SRE()
661 ctx->ptr, *ctx->pattern)); in SRE()
662 if (ctx->ptr >= end || !sre_category(ctx->pattern[0], ctx->ptr[0])) in SRE()
664 ctx->pattern++; in SRE()
671 TRACE(("|%p|%p|ANY\n", ctx->pattern, ctx->ptr)); in SRE()
680 TRACE(("|%p|%p|ANY_ALL\n", ctx->pattern, ctx->ptr)); in SRE()
689 TRACE(("|%p|%p|IN\n", ctx->pattern, ctx->ptr)); in SRE()
691 !SRE(charset)(state, ctx->pattern + 1, *ctx->ptr)) in SRE()
693 ctx->pattern += ctx->pattern[0]; in SRE()
699 ctx->pattern, ctx->ptr, ctx->pattern[0])); in SRE()
701 sre_lower_ascii(*ctx->ptr) != *ctx->pattern) in SRE()
703 ctx->pattern++; in SRE()
709 ctx->pattern, ctx->ptr, ctx->pattern[0])); in SRE()
711 sre_lower_unicode(*ctx->ptr) != *ctx->pattern) in SRE()
713 ctx->pattern++; in SRE()
719 ctx->pattern, ctx->ptr, ctx->pattern[0])); in SRE()
721 || !char_loc_ignore(*ctx->pattern, *ctx->ptr)) in SRE()
723 ctx->pattern++; in SRE()
729 ctx->pattern, ctx->ptr, *ctx->pattern)); in SRE()
731 sre_lower_ascii(*ctx->ptr) == *ctx->pattern) in SRE()
733 ctx->pattern++; in SRE()
739 ctx->pattern, ctx->ptr, *ctx->pattern)); in SRE()
741 sre_lower_unicode(*ctx->ptr) == *ctx->pattern) in SRE()
743 ctx->pattern++; in SRE()
749 ctx->pattern, ctx->ptr, *ctx->pattern)); in SRE()
751 || char_loc_ignore(*ctx->pattern, *ctx->ptr)) in SRE()
753 ctx->pattern++; in SRE()
758 TRACE(("|%p|%p|IN_IGNORE\n", ctx->pattern, ctx->ptr)); in SRE()
760 || !SRE(charset)(state, ctx->pattern+1, in SRE()
763 ctx->pattern += ctx->pattern[0]; in SRE()
768 TRACE(("|%p|%p|IN_UNI_IGNORE\n", ctx->pattern, ctx->ptr)); in SRE()
770 || !SRE(charset)(state, ctx->pattern+1, in SRE()
773 ctx->pattern += ctx->pattern[0]; in SRE()
778 TRACE(("|%p|%p|IN_LOC_IGNORE\n", ctx->pattern, ctx->ptr)); in SRE()
780 || !SRE(charset_loc_ignore)(state, ctx->pattern+1, *ctx->ptr)) in SRE()
782 ctx->pattern += ctx->pattern[0]; in SRE()
790 TRACE(("|%p|%p|JUMP %d\n", ctx->pattern, in SRE()
791 ctx->ptr, ctx->pattern[0])); in SRE()
792 ctx->pattern += ctx->pattern[0]; in SRE()
798 TRACE(("|%p|%p|BRANCH\n", ctx->pattern, ctx->ptr)); in SRE()
803 for (; ctx->pattern[0]; ctx->pattern += ctx->pattern[0]) { in SRE()
804 if (ctx->pattern[1] == SRE_OP_LITERAL && in SRE()
806 (SRE_CODE) *ctx->ptr != ctx->pattern[2])) in SRE()
808 if (ctx->pattern[1] == SRE_OP_IN && in SRE()
810 !SRE(charset)(state, ctx->pattern + 3, in SRE()
814 DO_JUMP(JUMP_BRANCH, jump_branch, ctx->pattern+1); in SRE()
839 TRACE(("|%p|%p|REPEAT_ONE %d %d\n", ctx->pattern, ctx->ptr, in SRE()
840 ctx->pattern[1], ctx->pattern[2])); in SRE()
842 if ((Py_ssize_t) ctx->pattern[1] > end - ctx->ptr) in SRE()
847 ret = SRE(count)(state, ctx->pattern+3, ctx->pattern[2]); in SRE()
855 string. check if the rest of the pattern matches, in SRE()
858 if (ctx->count < (Py_ssize_t) ctx->pattern[1]) in SRE()
861 if (ctx->pattern[ctx->pattern[0]] == SRE_OP_SUCCESS && in SRE()
872 if (ctx->pattern[ctx->pattern[0]] == SRE_OP_LITERAL) { in SRE()
874 the rest of the pattern cannot possibly match */ in SRE()
875 ctx->u.chr = ctx->pattern[ctx->pattern[0]+1]; in SRE()
877 while (ctx->count >= (Py_ssize_t) ctx->pattern[1] && in SRE()
882 if (ctx->count < (Py_ssize_t) ctx->pattern[1]) in SRE()
886 ctx->pattern+ctx->pattern[0]); in SRE()
900 while (ctx->count >= (Py_ssize_t) ctx->pattern[1]) { in SRE()
903 ctx->pattern+ctx->pattern[0]); in SRE()
925 TRACE(("|%p|%p|MIN_REPEAT_ONE %d %d\n", ctx->pattern, ctx->ptr, in SRE()
926 ctx->pattern[1], ctx->pattern[2])); in SRE()
928 if ((Py_ssize_t) ctx->pattern[1] > end - ctx->ptr) in SRE()
933 if (ctx->pattern[1] == 0) in SRE()
936 /* count using pattern min as the maximum */ in SRE()
937 ret = SRE(count)(state, ctx->pattern+3, ctx->pattern[1]); in SRE()
940 if (ret < (Py_ssize_t) ctx->pattern[1]) in SRE()
948 if (ctx->pattern[ctx->pattern[0]] == SRE_OP_SUCCESS && in SRE()
960 while ((Py_ssize_t)ctx->pattern[2] == SRE_MAXREPEAT in SRE()
961 || ctx->count <= (Py_ssize_t)ctx->pattern[2]) { in SRE()
964 ctx->pattern+ctx->pattern[0]); in SRE()
970 ret = SRE(count)(state, ctx->pattern+3, 1); in SRE()
987 TRACE(("|%p|%p|REPEAT %d %d\n", ctx->pattern, ctx->ptr, in SRE()
988 ctx->pattern[1], ctx->pattern[2])); in SRE()
997 ctx->u.rep->pattern = ctx->pattern; in SRE()
1003 DO_JUMP(JUMP_REPEAT, jump_repeat, ctx->pattern+ctx->pattern[0]); in SRE()
1028 TRACE(("|%p|%p|MAX_UNTIL %" PY_FORMAT_SIZE_T "d\n", ctx->pattern, in SRE()
1031 if (ctx->count < (Py_ssize_t) ctx->u.rep->pattern[1]) { in SRE()
1035 ctx->u.rep->pattern+3); in SRE()
1045 if ((ctx->count < (Py_ssize_t) ctx->u.rep->pattern[2] || in SRE()
1046 ctx->u.rep->pattern[2] == SRE_MAXREPEAT) && in SRE()
1057 ctx->u.rep->pattern+3); in SRE()
1073 DO_JUMP(JUMP_MAX_UNTIL_3, jump_max_until_3, ctx->pattern); in SRE()
1091 TRACE(("|%p|%p|MIN_UNTIL %" PY_FORMAT_SIZE_T "d %p\n", ctx->pattern, in SRE()
1092 ctx->ptr, ctx->count, ctx->u.rep->pattern)); in SRE()
1094 if (ctx->count < (Py_ssize_t) ctx->u.rep->pattern[1]) { in SRE()
1098 ctx->u.rep->pattern+3); in SRE()
1112 DO_JUMP(JUMP_MIN_UNTIL_2, jump_min_until_2, ctx->pattern); in SRE()
1123 if ((ctx->count >= (Py_ssize_t) ctx->u.rep->pattern[2] in SRE()
1124 && ctx->u.rep->pattern[2] != SRE_MAXREPEAT) || in SRE()
1133 ctx->u.rep->pattern+3); in SRE()
1145 TRACE(("|%p|%p|GROUPREF %d\n", ctx->pattern, in SRE()
1146 ctx->ptr, ctx->pattern[0])); in SRE()
1147 i = ctx->pattern[0]; in SRE()
1165 ctx->pattern++; in SRE()
1170 TRACE(("|%p|%p|GROUPREF_IGNORE %d\n", ctx->pattern, in SRE()
1171 ctx->ptr, ctx->pattern[0])); in SRE()
1172 i = ctx->pattern[0]; in SRE()
1191 ctx->pattern++; in SRE()
1196 TRACE(("|%p|%p|GROUPREF_UNI_IGNORE %d\n", ctx->pattern, in SRE()
1197 ctx->ptr, ctx->pattern[0])); in SRE()
1198 i = ctx->pattern[0]; in SRE()
1217 ctx->pattern++; in SRE()
1222 TRACE(("|%p|%p|GROUPREF_LOC_IGNORE %d\n", ctx->pattern, in SRE()
1223 ctx->ptr, ctx->pattern[0])); in SRE()
1224 i = ctx->pattern[0]; in SRE()
1243 ctx->pattern++; in SRE()
1247 TRACE(("|%p|%p|GROUPREF_EXISTS %d\n", ctx->pattern, in SRE()
1248 ctx->ptr, ctx->pattern[0])); in SRE()
1250 i = ctx->pattern[0]; in SRE()
1254 ctx->pattern += ctx->pattern[1]; in SRE()
1260 ctx->pattern += ctx->pattern[1]; in SRE()
1265 ctx->pattern += 2; in SRE()
1270 /* <ASSERT> <skip> <back> <pattern> */ in SRE()
1271 TRACE(("|%p|%p|ASSERT %d\n", ctx->pattern, in SRE()
1272 ctx->ptr, ctx->pattern[1])); in SRE()
1273 if (ctx->ptr - (SRE_CHAR *)state->beginning < (Py_ssize_t)ctx->pattern[1]) in SRE()
1275 state->ptr = ctx->ptr - ctx->pattern[1]; in SRE()
1276 DO_JUMP0(JUMP_ASSERT, jump_assert, ctx->pattern+2); in SRE()
1278 ctx->pattern += ctx->pattern[0]; in SRE()
1283 /* <ASSERT_NOT> <skip> <back> <pattern> */ in SRE()
1284 TRACE(("|%p|%p|ASSERT_NOT %d\n", ctx->pattern, in SRE()
1285 ctx->ptr, ctx->pattern[1])); in SRE()
1286 if (ctx->ptr - (SRE_CHAR *)state->beginning >= (Py_ssize_t)ctx->pattern[1]) { in SRE()
1287 state->ptr = ctx->ptr - ctx->pattern[1]; in SRE()
1288 DO_JUMP0(JUMP_ASSERT_NOT, jump_assert_not, ctx->pattern+2); in SRE()
1294 ctx->pattern += ctx->pattern[0]; in SRE()
1299 TRACE(("|%p|%p|FAILURE\n", ctx->pattern, ctx->ptr)); in SRE()
1303 TRACE(("|%p|%p|UNKNOWN %d\n", ctx->pattern, ctx->ptr, in SRE()
1304 ctx->pattern[-1])); in SRE()
1319 TRACE(("|%p|%p|JUMP_MAX_UNTIL_2\n", ctx->pattern, ctx->ptr)); in SRE()
1322 TRACE(("|%p|%p|JUMP_MAX_UNTIL_3\n", ctx->pattern, ctx->ptr)); in SRE()
1325 TRACE(("|%p|%p|JUMP_MIN_UNTIL_2\n", ctx->pattern, ctx->ptr)); in SRE()
1328 TRACE(("|%p|%p|JUMP_MIN_UNTIL_3\n", ctx->pattern, ctx->ptr)); in SRE()
1331 TRACE(("|%p|%p|JUMP_BRANCH\n", ctx->pattern, ctx->ptr)); in SRE()
1334 TRACE(("|%p|%p|JUMP_MAX_UNTIL_1\n", ctx->pattern, ctx->ptr)); in SRE()
1337 TRACE(("|%p|%p|JUMP_MIN_UNTIL_1\n", ctx->pattern, ctx->ptr)); in SRE()
1340 TRACE(("|%p|%p|JUMP_REPEAT\n", ctx->pattern, ctx->ptr)); in SRE()
1343 TRACE(("|%p|%p|JUMP_REPEAT_ONE_1\n", ctx->pattern, ctx->ptr)); in SRE()
1346 TRACE(("|%p|%p|JUMP_REPEAT_ONE_2\n", ctx->pattern, ctx->ptr)); in SRE()
1349 TRACE(("|%p|%p|JUMP_MIN_REPEAT_ONE\n", ctx->pattern, ctx->ptr)); in SRE()
1352 TRACE(("|%p|%p|JUMP_ASSERT\n", ctx->pattern, ctx->ptr)); in SRE()
1355 TRACE(("|%p|%p|JUMP_ASSERT_NOT\n", ctx->pattern, ctx->ptr)); in SRE()
1358 TRACE(("|%p|%p|RETURN %" PY_FORMAT_SIZE_T "d\n", ctx->pattern, in SRE()
1371 SRE(search)(SRE_STATE* state, SRE_CODE* pattern) in SRE()
1386 if (pattern[0] == SRE_OP_INFO) { in SRE()
1390 flags = pattern[2]; in SRE()
1392 if (pattern[3] && end - ptr < (Py_ssize_t)pattern[3]) { in SRE()
1394 (unsigned int)(end - ptr), pattern[3])); in SRE()
1397 if (pattern[3] > 1) { in SRE()
1400 end -= pattern[3] - 1; in SRE()
1406 /* pattern starts with a known prefix */ in SRE()
1408 prefix_len = pattern[5]; in SRE()
1409 prefix_skip = pattern[6]; in SRE()
1410 prefix = pattern + 7; in SRE()
1413 /* pattern starts with a character from a known set */ in SRE()
1415 charset = pattern + 5; in SRE()
1417 pattern += 1 + pattern[1]; in SRE()
1425 /* pattern starts with a literal character */ in SRE()
1438 TRACE(("|%p|%p|SEARCH LITERAL\n", pattern, ptr)); in SRE()
1443 status = SRE(match)(state, pattern + 2*prefix_skip, 0); in SRE()
1453 /* pattern starts with a known prefix. use the overlap in SRE()
1484 TRACE(("|%p|%p|SEARCH SCAN\n", pattern, ptr)); in SRE()
1489 status = SRE(match)(state, pattern + 2*prefix_skip, 0); in SRE()
1504 /* pattern starts with a character from a known set */ in SRE()
1512 TRACE(("|%p|%p|SEARCH CHARSET\n", pattern, ptr)); in SRE()
1515 status = SRE(match)(state, pattern, 0); in SRE()
1524 TRACE(("|%p|%p|SEARCH\n", pattern, ptr)); in SRE()
1526 status = SRE(match)(state, pattern, 1); in SRE()
1531 TRACE(("|%p|%p|SEARCH\n", pattern, ptr)); in SRE()
1533 status = SRE(match)(state, pattern, 0); in SRE()