| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| |
| |
| |
| |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| #include "pcre2_internal.h" |
|
|
|
|
|
|
| #define NLBLOCK mb |
| #define PSSTART start_subject |
| #define PSEND end_subject |
|
|
| #define PUBLIC_DFA_MATCH_OPTIONS \ |
| (PCRE2_ANCHORED|PCRE2_ENDANCHORED|PCRE2_NOTBOL|PCRE2_NOTEOL|PCRE2_NOTEMPTY| \ |
| PCRE2_NOTEMPTY_ATSTART|PCRE2_NO_UTF_CHECK|PCRE2_PARTIAL_HARD| \ |
| PCRE2_PARTIAL_SOFT|PCRE2_DFA_SHORTEST|PCRE2_DFA_RESTART| \ |
| PCRE2_COPY_MATCHED_SUBJECT) |
|
|
|
|
| |
| |
| |
|
|
| |
| |
| |
| |
|
|
| #define OP_PROP_EXTRA 300 |
| #define OP_EXTUNI_EXTRA 320 |
| #define OP_ANYNL_EXTRA 340 |
| #define OP_HSPACE_EXTRA 360 |
| #define OP_VSPACE_EXTRA 380 |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| static const uint8_t coptable[] = { |
| 0, |
| 0, 0, 0, 0, 0, |
| 0, 0, 0, 0, 0, 0, |
| 0, 0, 0, |
| 0, 0, |
| 0, 0, 0, 0, 0, |
| 0, |
| 0, 0, 0, 0, 0, 0, |
| 1, |
| 1, |
| 1, |
| 1, |
| |
| 1, 1, 1, 1, 1, 1, |
| 1+IMM2_SIZE, 1+IMM2_SIZE, |
| 1+IMM2_SIZE, |
| 1, 1, 1, 1+IMM2_SIZE, |
| 1, 1, 1, 1, 1, 1, |
| 1+IMM2_SIZE, 1+IMM2_SIZE, |
| 1+IMM2_SIZE, |
| 1, 1, 1, 1+IMM2_SIZE, |
| |
| 1, 1, 1, 1, 1, 1, |
| 1+IMM2_SIZE, 1+IMM2_SIZE, |
| 1+IMM2_SIZE, |
| 1, 1, 1, 1+IMM2_SIZE, |
| 1, 1, 1, 1, 1, 1, |
| 1+IMM2_SIZE, 1+IMM2_SIZE, |
| 1+IMM2_SIZE, |
| 1, 1, 1, 1+IMM2_SIZE, |
| |
| 1, 1, 1, 1, 1, 1, |
| 1+IMM2_SIZE, 1+IMM2_SIZE, |
| 1+IMM2_SIZE, |
| 1, 1, 1, 1+IMM2_SIZE, |
| |
| 0, 0, 0, 0, 0, 0, |
| 0, 0, |
| 0, 0, 0, 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, 0, 0, 0, 0, |
| 0, 0, 0, 0, 0, |
| 0, 0, |
| 0, 0, |
| 0, 0, |
| 0, 0, 0, |
| 0, 0, 0, |
| 0, 0, 0, 0, |
| 0, 0, |
| 0, 0, 0, |
| 0, 0, 0, |
| 0, 0, |
| }; |
|
|
| |
| |
| |
| |
|
|
| static const uint8_t poptable[] = { |
| 0, |
| 0, 0, 0, 1, 1, |
| 1, 1, 1, 1, 1, 1, |
| 1, 1, 1, |
| 1, 1, |
| 1, 1, 1, 1, 1, |
| 1, |
| 0, 0, 0, 0, 0, 0, |
| 1, |
| 1, |
| 1, |
| 1, |
| |
| 1, 1, 1, 1, 1, 1, |
| 1, 1, 1, |
| 1, 1, 1, 1, |
| 1, 1, 1, 1, 1, 1, |
| 1, 1, 1, |
| 1, 1, 1, 1, |
| |
| 1, 1, 1, 1, 1, 1, |
| 1, 1, 1, |
| 1, 1, 1, 1, |
| 1, 1, 1, 1, 1, 1, |
| 1, 1, 1, |
| 1, 1, 1, 1, |
| |
| 1, 1, 1, 1, 1, 1, |
| 1, 1, 1, |
| 1, 1, 1, 1, |
| |
| 1, 1, 1, 1, 1, 1, |
| 1, 1, |
| 1, 1, 1, 1, |
| 1, |
| 1, |
| 1, |
| 1, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, |
| 0, 0, 0, 0, 0, |
| 0, 0, 0, 0, 0, |
| 0, 0, |
| 0, 0, |
| 0, 0, |
| 0, 0, 0, |
| 0, 0, 0, |
| 0, 0, 0, 0, |
| 0, 0, |
| 0, 0, 0, |
| 0, 0, 0, |
| 1, 1, |
| }; |
|
|
| |
| STATIC_ASSERT(sizeof(coptable) == OP_TABLE_LENGTH, coptable); |
| STATIC_ASSERT(sizeof(poptable) == OP_TABLE_LENGTH, poptable); |
|
|
| |
| |
|
|
| static const uint8_t toptable1[] = { |
| 0, 0, 0, 0, 0, 0, |
| ctype_digit, ctype_digit, |
| ctype_space, ctype_space, |
| ctype_word, ctype_word, |
| 0, 0 |
| }; |
|
|
| static const uint8_t toptable2[] = { |
| 0, 0, 0, 0, 0, 0, |
| ctype_digit, 0, |
| ctype_space, 0, |
| ctype_word, 0, |
| 1, 1 |
| }; |
|
|
|
|
| |
| |
| |
| |
|
|
| typedef struct stateblock { |
| int offset; |
| int count; |
| int data; |
| } stateblock; |
|
|
| #define INTS_PER_STATEBLOCK (int)(sizeof(stateblock)/sizeof(int)) |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #define OVEC_UNIT (sizeof(PCRE2_SIZE)/sizeof(int)) |
|
|
| #define RWS_BASE_SIZE (DFA_START_RWS_SIZE/sizeof(int)) |
| #define RWS_RSIZE 1000 |
| #define RWS_OVEC_RSIZE (1000*OVEC_UNIT) |
| #define RWS_OVEC_OSIZE (2*OVEC_UNIT) |
|
|
| |
|
|
| typedef struct RWS_anchor { |
| struct RWS_anchor *next; |
| uint32_t size; |
| uint32_t free; |
| } RWS_anchor; |
|
|
| #define RWS_ANCHOR_SIZE (sizeof(RWS_anchor)/sizeof(int)) |
|
|
|
|
|
|
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| static int |
| do_callout_dfa(PCRE2_SPTR code, PCRE2_SIZE *offsets, PCRE2_SPTR current_subject, |
| PCRE2_SPTR ptr, dfa_match_block *mb, PCRE2_SIZE extracode, |
| PCRE2_SIZE *lengthptr) |
| { |
| pcre2_callout_block *cb = mb->cb; |
|
|
| *lengthptr = (code[extracode] == OP_CALLOUT)? |
| (PCRE2_SIZE)PRIV(OP_lengths)[OP_CALLOUT] : |
| (PCRE2_SIZE)GET(code, 1 + 2*LINK_SIZE + extracode); |
|
|
| if (mb->callout == NULL) return 0; |
|
|
| |
| |
|
|
| cb->offset_vector = offsets; |
| cb->start_match = (PCRE2_SIZE)(current_subject - mb->start_subject); |
| cb->current_position = (PCRE2_SIZE)(ptr - mb->start_subject); |
| cb->pattern_position = GET(code, 1 + extracode); |
| cb->next_item_length = GET(code, 1 + LINK_SIZE + extracode); |
|
|
| if (code[extracode] == OP_CALLOUT) |
| { |
| cb->callout_number = code[1 + 2*LINK_SIZE + extracode]; |
| cb->callout_string_offset = 0; |
| cb->callout_string = NULL; |
| cb->callout_string_length = 0; |
| } |
| else |
| { |
| cb->callout_number = 0; |
| cb->callout_string_offset = GET(code, 1 + 3*LINK_SIZE + extracode); |
| cb->callout_string = code + (1 + 4*LINK_SIZE + extracode) + 1; |
| cb->callout_string_length = *lengthptr - (1 + 4*LINK_SIZE) - 2; |
| } |
|
|
| return (mb->callout)(cb, mb->callout_data); |
| } |
|
|
|
|
|
|
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| static int |
| more_workspace(RWS_anchor **rwsptr, unsigned int ovecsize, dfa_match_block *mb) |
| { |
| RWS_anchor *rws = *rwsptr; |
| RWS_anchor *new; |
|
|
| if (rws->next != NULL) |
| { |
| new = rws->next; |
| } |
|
|
| |
| |
| |
|
|
| else |
| { |
| uint32_t newsize = (rws->size >= UINT32_MAX/(sizeof(int)*2))? UINT32_MAX/sizeof(int) : rws->size * 2; |
| uint32_t newsizeK = newsize/(1024/sizeof(int)); |
|
|
| if (newsizeK + mb->heap_used > mb->heap_limit) |
| newsizeK = (uint32_t)(mb->heap_limit - mb->heap_used); |
| newsize = newsizeK*(1024/sizeof(int)); |
|
|
| if (newsize < RWS_RSIZE + ovecsize + RWS_ANCHOR_SIZE) |
| return PCRE2_ERROR_HEAPLIMIT; |
| new = mb->memctl.malloc(newsize*sizeof(int), mb->memctl.memory_data); |
| if (new == NULL) return PCRE2_ERROR_NOMEMORY; |
| mb->heap_used += newsizeK; |
| new->next = NULL; |
| new->size = newsize; |
| rws->next = new; |
| } |
|
|
| new->free = new->size - RWS_ANCHOR_SIZE; |
| *rwsptr = new; |
| return 0; |
| } |
|
|
|
|
|
|
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #define ADD_ACTIVE(x,y) \ |
| if (active_count++ < wscount) \ |
| { \ |
| next_active_state->offset = (x); \ |
| next_active_state->count = (y); \ |
| next_active_state++; \ |
| } \ |
| else return PCRE2_ERROR_DFA_WSSIZE |
|
|
| #define ADD_ACTIVE_DATA(x,y,z) \ |
| if (active_count++ < wscount) \ |
| { \ |
| next_active_state->offset = (x); \ |
| next_active_state->count = (y); \ |
| next_active_state->data = (z); \ |
| next_active_state++; \ |
| } \ |
| else return PCRE2_ERROR_DFA_WSSIZE |
|
|
| #define ADD_NEW(x,y) \ |
| if (new_count++ < wscount) \ |
| { \ |
| next_new_state->offset = (x); \ |
| next_new_state->count = (y); \ |
| next_new_state++; \ |
| } \ |
| else return PCRE2_ERROR_DFA_WSSIZE |
|
|
| #define ADD_NEW_DATA(x,y,z) \ |
| if (new_count++ < wscount) \ |
| { \ |
| next_new_state->offset = (x); \ |
| next_new_state->count = (y); \ |
| next_new_state->data = (z); \ |
| next_new_state++; \ |
| } \ |
| else return PCRE2_ERROR_DFA_WSSIZE |
|
|
| |
|
|
| static int |
| internal_dfa_match( |
| dfa_match_block *mb, |
| PCRE2_SPTR this_start_code, |
| PCRE2_SPTR current_subject, |
| PCRE2_SIZE start_offset, |
| PCRE2_SIZE *offsets, |
| uint32_t offsetcount, |
| int *workspace, |
| int wscount, |
| uint32_t rlevel, |
| int *RWS) |
| { |
| stateblock *active_states, *new_states, *temp_states; |
| stateblock *next_active_state, *next_new_state; |
| const uint8_t *ctypes, *lcc, *fcc; |
| PCRE2_SPTR ptr; |
| PCRE2_SPTR end_code; |
| dfa_recursion_info new_recursive; |
| int active_count, new_count, match_count; |
|
|
| |
| |
|
|
| PCRE2_SPTR start_subject = mb->start_subject; |
| PCRE2_SPTR end_subject = mb->end_subject; |
| PCRE2_SPTR start_code = mb->start_code; |
|
|
| #ifdef SUPPORT_UNICODE |
| BOOL utf = (mb->poptions & PCRE2_UTF) != 0; |
| BOOL utf_or_ucp = utf || (mb->poptions & PCRE2_UCP) != 0; |
| #else |
| BOOL utf = FALSE; |
| #endif |
|
|
| BOOL reset_could_continue = FALSE; |
|
|
| if (mb->match_call_count++ >= mb->match_limit) return PCRE2_ERROR_MATCHLIMIT; |
| if (rlevel++ > mb->match_limit_depth) return PCRE2_ERROR_DEPTHLIMIT; |
| offsetcount &= (uint32_t)(-2); |
|
|
| wscount -= 2; |
| wscount = (wscount - (wscount % (INTS_PER_STATEBLOCK * 2))) / |
| (2 * INTS_PER_STATEBLOCK); |
|
|
| ctypes = mb->tables + ctypes_offset; |
| lcc = mb->tables + lcc_offset; |
| fcc = mb->tables + fcc_offset; |
|
|
| match_count = PCRE2_ERROR_NOMATCH; |
|
|
| active_states = (stateblock *)(workspace + 2); |
| next_new_state = new_states = active_states + wscount; |
| new_count = 0; |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| if (*this_start_code == OP_ASSERTBACK || *this_start_code == OP_ASSERTBACK_NOT) |
| { |
| size_t max_back = 0; |
| size_t gone_back; |
|
|
| end_code = this_start_code; |
| do |
| { |
| size_t back = (size_t)GET2(end_code, 2+LINK_SIZE); |
| if (back > max_back) max_back = back; |
| end_code += GET(end_code, 1); |
| } |
| while (*end_code == OP_ALT); |
|
|
| |
| |
|
|
| #ifdef SUPPORT_UNICODE |
| |
|
|
| if (utf) |
| { |
| for (gone_back = 0; gone_back < max_back; gone_back++) |
| { |
| if (current_subject <= start_subject) break; |
| current_subject--; |
| ACROSSCHAR(current_subject > start_subject, current_subject, |
| current_subject--); |
| } |
| } |
| else |
| #endif |
|
|
| |
|
|
| { |
| size_t current_offset = (size_t)(current_subject - start_subject); |
| gone_back = (current_offset < max_back)? current_offset : max_back; |
| current_subject -= gone_back; |
| } |
|
|
| |
|
|
| if (current_subject < mb->start_used_ptr) |
| mb->start_used_ptr = current_subject; |
|
|
| |
| |
|
|
| end_code = this_start_code; |
| do |
| { |
| uint32_t revlen = (end_code[1+LINK_SIZE] == OP_REVERSE)? 1 + IMM2_SIZE : 0; |
| size_t back = (revlen == 0)? 0 : (size_t)GET2(end_code, 2+LINK_SIZE); |
| if (back <= gone_back) |
| { |
| int bstate = (int)(end_code - start_code + 1 + LINK_SIZE + revlen); |
| ADD_NEW_DATA(-bstate, 0, (int)(gone_back - back)); |
| } |
| end_code += GET(end_code, 1); |
| } |
| while (*end_code == OP_ALT); |
| } |
|
|
| |
| |
| |
| |
| |
|
|
| else |
| { |
| end_code = this_start_code; |
|
|
| |
|
|
| if (rlevel == 1 && (mb->moptions & PCRE2_DFA_RESTART) != 0) |
| { |
| do { end_code += GET(end_code, 1); } while (*end_code == OP_ALT); |
| new_count = workspace[1]; |
| if (!workspace[0]) |
| memcpy(new_states, active_states, (size_t)new_count * sizeof(stateblock)); |
| } |
|
|
| |
|
|
| else |
| { |
| int length = 1 + LINK_SIZE + |
| ((*this_start_code == OP_CBRA || *this_start_code == OP_SCBRA || |
| *this_start_code == OP_CBRAPOS || *this_start_code == OP_SCBRAPOS) |
| ? IMM2_SIZE:0); |
| do |
| { |
| ADD_NEW((int)(end_code - start_code + length), 0); |
| end_code += GET(end_code, 1); |
| length = 1 + LINK_SIZE; |
| } |
| while (*end_code == OP_ALT); |
| } |
| } |
|
|
| workspace[0] = 0; |
|
|
| |
|
|
| ptr = current_subject; |
| for (;;) |
| { |
| int i, j; |
| int clen, dlen; |
| uint32_t c, d; |
| BOOL partial_newline = FALSE; |
| BOOL could_continue = reset_could_continue; |
| reset_could_continue = FALSE; |
|
|
| if (ptr > mb->last_used_ptr) mb->last_used_ptr = ptr; |
|
|
| |
| |
|
|
| temp_states = active_states; |
| active_states = new_states; |
| new_states = temp_states; |
| active_count = new_count; |
| new_count = 0; |
|
|
| workspace[0] ^= 1; |
| workspace[1] = active_count; |
|
|
| |
|
|
| next_active_state = active_states + active_count; |
| next_new_state = new_states; |
|
|
| |
| |
| |
|
|
| if (ptr < end_subject) |
| { |
| clen = 1; |
| #ifdef SUPPORT_UNICODE |
| GETCHARLENTEST(c, ptr, clen); |
| #else |
| c = *ptr; |
| #endif |
| } |
| else |
| { |
| clen = 0; |
| c = NOTACHAR; |
| } |
|
|
| |
| |
| |
| |
|
|
| for (i = 0; i < active_count; i++) |
| { |
| stateblock *current_state = active_states + i; |
| BOOL caseless = FALSE; |
| PCRE2_SPTR code; |
| uint32_t codevalue; |
| int state_offset = current_state->offset; |
| int rrc; |
| int count; |
|
|
| |
| |
| |
| |
|
|
| if (state_offset < 0) |
| { |
| if (current_state->data > 0) |
| { |
| ADD_NEW_DATA(state_offset, current_state->count, |
| current_state->data - 1); |
| if (could_continue) reset_could_continue = TRUE; |
| continue; |
| } |
| else |
| { |
| current_state->offset = state_offset = -state_offset; |
| } |
| } |
|
|
| |
| |
| |
|
|
| for (j = 0; j < i; j++) |
| { |
| if (active_states[j].offset == state_offset && |
| active_states[j].count == current_state->count) |
| goto NEXT_ACTIVE_STATE; |
| } |
|
|
| |
|
|
| code = start_code + state_offset; |
| codevalue = *code; |
|
|
| |
| |
|
|
| if (clen == 0 && poptable[codevalue] != 0) |
| could_continue = TRUE; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| if (coptable[codevalue] > 0) |
| { |
| dlen = 1; |
| #ifdef SUPPORT_UNICODE |
| if (utf) { GETCHARLEN(d, (code + coptable[codevalue]), dlen); } else |
| #endif |
| d = code[coptable[codevalue]]; |
| if (codevalue >= OP_TYPESTAR) |
| { |
| switch(d) |
| { |
| case OP_ANYBYTE: return PCRE2_ERROR_DFA_UITEM; |
| case OP_NOTPROP: |
| case OP_PROP: codevalue += OP_PROP_EXTRA; break; |
| case OP_ANYNL: codevalue += OP_ANYNL_EXTRA; break; |
| case OP_EXTUNI: codevalue += OP_EXTUNI_EXTRA; break; |
| case OP_NOT_HSPACE: |
| case OP_HSPACE: codevalue += OP_HSPACE_EXTRA; break; |
| case OP_NOT_VSPACE: |
| case OP_VSPACE: codevalue += OP_VSPACE_EXTRA; break; |
| default: break; |
| } |
| } |
| } |
| else |
| { |
| dlen = 0; |
| d = NOTACHAR; |
| } |
|
|
|
|
| |
|
|
| switch (codevalue) |
| { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| case OP_KET: |
| case OP_KETRMIN: |
| case OP_KETRMAX: |
| case OP_KETRPOS: |
| if (code != end_code) |
| { |
| ADD_ACTIVE(state_offset + 1 + LINK_SIZE, 0); |
| if (codevalue != OP_KET) |
| { |
| ADD_ACTIVE(state_offset - (int)GET(code, 1), 0); |
| } |
| } |
| else |
| { |
| if (ptr > current_subject || |
| ((mb->moptions & PCRE2_NOTEMPTY) == 0 && |
| ((mb->moptions & PCRE2_NOTEMPTY_ATSTART) == 0 || |
| current_subject > start_subject + mb->start_offset))) |
| { |
| if (match_count < 0) match_count = (offsetcount >= 2)? 1 : 0; |
| else if (match_count > 0 && ++match_count * 2 > (int)offsetcount) |
| match_count = 0; |
| count = ((match_count == 0)? (int)offsetcount : match_count * 2) - 2; |
| if (count > 0) (void)memmove(offsets + 2, offsets, |
| (size_t)count * sizeof(PCRE2_SIZE)); |
| if (offsetcount >= 2) |
| { |
| offsets[0] = (PCRE2_SIZE)(current_subject - start_subject); |
| offsets[1] = (PCRE2_SIZE)(ptr - start_subject); |
| } |
| if ((mb->moptions & PCRE2_DFA_SHORTEST) != 0) return match_count; |
| } |
| } |
| break; |
|
|
| |
| |
| |
|
|
| |
| case OP_ALT: |
| do { code += GET(code, 1); } while (*code == OP_ALT); |
| ADD_ACTIVE((int)(code - start_code), 0); |
| break; |
|
|
| |
| case OP_BRA: |
| case OP_SBRA: |
| do |
| { |
| ADD_ACTIVE((int)(code - start_code + 1 + LINK_SIZE), 0); |
| code += GET(code, 1); |
| } |
| while (*code == OP_ALT); |
| break; |
|
|
| |
| case OP_CBRA: |
| case OP_SCBRA: |
| ADD_ACTIVE((int)(code - start_code + 1 + LINK_SIZE + IMM2_SIZE), 0); |
| code += GET(code, 1); |
| while (*code == OP_ALT) |
| { |
| ADD_ACTIVE((int)(code - start_code + 1 + LINK_SIZE), 0); |
| code += GET(code, 1); |
| } |
| break; |
|
|
| |
| case OP_BRAZERO: |
| case OP_BRAMINZERO: |
| ADD_ACTIVE(state_offset + 1, 0); |
| code += 1 + GET(code, 2); |
| while (*code == OP_ALT) code += GET(code, 1); |
| ADD_ACTIVE((int)(code - start_code + 1 + LINK_SIZE), 0); |
| break; |
|
|
| |
| case OP_SKIPZERO: |
| code += 1 + GET(code, 2); |
| while (*code == OP_ALT) code += GET(code, 1); |
| ADD_ACTIVE((int)(code - start_code + 1 + LINK_SIZE), 0); |
| break; |
|
|
| |
| case OP_CIRC: |
| if (ptr == start_subject && (mb->moptions & PCRE2_NOTBOL) == 0) |
| { ADD_ACTIVE(state_offset + 1, 0); } |
| break; |
|
|
| |
| case OP_CIRCM: |
| if ((ptr == start_subject && (mb->moptions & PCRE2_NOTBOL) == 0) || |
| ((ptr != end_subject || (mb->poptions & PCRE2_ALT_CIRCUMFLEX) != 0 ) |
| && WAS_NEWLINE(ptr))) |
| { ADD_ACTIVE(state_offset + 1, 0); } |
| break; |
|
|
| |
| case OP_EOD: |
| if (ptr >= end_subject) |
| { |
| if ((mb->moptions & PCRE2_PARTIAL_HARD) != 0) |
| return PCRE2_ERROR_PARTIAL; |
| else { ADD_ACTIVE(state_offset + 1, 0); } |
| } |
| break; |
|
|
| |
| case OP_SOD: |
| if (ptr == start_subject) { ADD_ACTIVE(state_offset + 1, 0); } |
| break; |
|
|
| |
| case OP_SOM: |
| if (ptr == start_subject + start_offset) { ADD_ACTIVE(state_offset + 1, 0); } |
| break; |
|
|
|
|
| |
| |
| |
| |
| |
|
|
| |
| case OP_ANY: |
| if (clen > 0 && !IS_NEWLINE(ptr)) |
| { |
| if (ptr + 1 >= mb->end_subject && |
| (mb->moptions & (PCRE2_PARTIAL_HARD)) != 0 && |
| NLBLOCK->nltype == NLTYPE_FIXED && |
| NLBLOCK->nllen == 2 && |
| c == NLBLOCK->nl[0]) |
| { |
| could_continue = partial_newline = TRUE; |
| } |
| else |
| { |
| ADD_NEW(state_offset + 1, 0); |
| } |
| } |
| break; |
|
|
| |
| case OP_ALLANY: |
| if (clen > 0) |
| { ADD_NEW(state_offset + 1, 0); } |
| break; |
|
|
| |
| case OP_EODN: |
| if (clen == 0 || (IS_NEWLINE(ptr) && ptr == end_subject - mb->nllen)) |
| { |
| if ((mb->moptions & PCRE2_PARTIAL_HARD) != 0) |
| return PCRE2_ERROR_PARTIAL; |
| ADD_ACTIVE(state_offset + 1, 0); |
| } |
| break; |
|
|
| |
| case OP_DOLL: |
| if ((mb->moptions & PCRE2_NOTEOL) == 0) |
| { |
| if (clen == 0 && (mb->moptions & PCRE2_PARTIAL_HARD) != 0) |
| could_continue = TRUE; |
| else if (clen == 0 || |
| ((mb->poptions & PCRE2_DOLLAR_ENDONLY) == 0 && IS_NEWLINE(ptr) && |
| (ptr == end_subject - mb->nllen) |
| )) |
| { ADD_ACTIVE(state_offset + 1, 0); } |
| else if (ptr + 1 >= mb->end_subject && |
| (mb->moptions & (PCRE2_PARTIAL_HARD|PCRE2_PARTIAL_SOFT)) != 0 && |
| NLBLOCK->nltype == NLTYPE_FIXED && |
| NLBLOCK->nllen == 2 && |
| c == NLBLOCK->nl[0]) |
| { |
| if ((mb->moptions & PCRE2_PARTIAL_HARD) != 0) |
| { |
| reset_could_continue = TRUE; |
| ADD_NEW_DATA(-(state_offset + 1), 0, 1); |
| } |
| else could_continue = partial_newline = TRUE; |
| } |
| } |
| break; |
|
|
| |
| case OP_DOLLM: |
| if ((mb->moptions & PCRE2_NOTEOL) == 0) |
| { |
| if (clen == 0 && (mb->moptions & PCRE2_PARTIAL_HARD) != 0) |
| could_continue = TRUE; |
| else if (clen == 0 || |
| ((mb->poptions & PCRE2_DOLLAR_ENDONLY) == 0 && IS_NEWLINE(ptr))) |
| { ADD_ACTIVE(state_offset + 1, 0); } |
| else if (ptr + 1 >= mb->end_subject && |
| (mb->moptions & (PCRE2_PARTIAL_HARD|PCRE2_PARTIAL_SOFT)) != 0 && |
| NLBLOCK->nltype == NLTYPE_FIXED && |
| NLBLOCK->nllen == 2 && |
| c == NLBLOCK->nl[0]) |
| { |
| if ((mb->moptions & PCRE2_PARTIAL_HARD) != 0) |
| { |
| reset_could_continue = TRUE; |
| ADD_NEW_DATA(-(state_offset + 1), 0, 1); |
| } |
| else could_continue = partial_newline = TRUE; |
| } |
| } |
| else if (IS_NEWLINE(ptr)) |
| { ADD_ACTIVE(state_offset + 1, 0); } |
| break; |
|
|
| |
|
|
| case OP_DIGIT: |
| case OP_WHITESPACE: |
| case OP_WORDCHAR: |
| if (clen > 0 && c < 256 && |
| ((ctypes[c] & toptable1[codevalue]) ^ toptable2[codevalue]) != 0) |
| { ADD_NEW(state_offset + 1, 0); } |
| break; |
|
|
| |
| case OP_NOT_DIGIT: |
| case OP_NOT_WHITESPACE: |
| case OP_NOT_WORDCHAR: |
| if (clen > 0 && (c >= 256 || |
| ((ctypes[c] & toptable1[codevalue]) ^ toptable2[codevalue]) != 0)) |
| { ADD_NEW(state_offset + 1, 0); } |
| break; |
|
|
| |
| case OP_WORD_BOUNDARY: |
| case OP_NOT_WORD_BOUNDARY: |
| case OP_NOT_UCP_WORD_BOUNDARY: |
| case OP_UCP_WORD_BOUNDARY: |
| { |
| int left_word, right_word; |
|
|
| if (ptr > start_subject) |
| { |
| PCRE2_SPTR temp = ptr - 1; |
| if (temp < mb->start_used_ptr) mb->start_used_ptr = temp; |
| #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 |
| if (utf) { BACKCHAR(temp); } |
| #endif |
| GETCHARTEST(d, temp); |
| #ifdef SUPPORT_UNICODE |
| if (codevalue == OP_UCP_WORD_BOUNDARY || |
| codevalue == OP_NOT_UCP_WORD_BOUNDARY) |
| { |
| int chartype = UCD_CHARTYPE(d); |
| int category = PRIV(ucp_gentype)[chartype]; |
| left_word = (category == ucp_L || category == ucp_N || |
| chartype == ucp_Mn || chartype == ucp_Pc); |
| } |
| else |
| #endif |
| left_word = d < 256 && (ctypes[d] & ctype_word) != 0; |
| } |
| else left_word = FALSE; |
|
|
| if (clen > 0) |
| { |
| if (ptr >= mb->last_used_ptr) |
| { |
| PCRE2_SPTR temp = ptr + 1; |
| #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 |
| if (utf) { FORWARDCHARTEST(temp, mb->end_subject); } |
| #endif |
| mb->last_used_ptr = temp; |
| } |
| #ifdef SUPPORT_UNICODE |
| if (codevalue == OP_UCP_WORD_BOUNDARY || |
| codevalue == OP_NOT_UCP_WORD_BOUNDARY) |
| { |
| int chartype = UCD_CHARTYPE(c); |
| int category = PRIV(ucp_gentype)[chartype]; |
| right_word = (category == ucp_L || category == ucp_N || |
| chartype == ucp_Mn || chartype == ucp_Pc); |
| } |
| else |
| #endif |
| right_word = c < 256 && (ctypes[c] & ctype_word) != 0; |
| } |
| else right_word = FALSE; |
|
|
| if ((left_word == right_word) == |
| (codevalue == OP_NOT_WORD_BOUNDARY || |
| codevalue == OP_NOT_UCP_WORD_BOUNDARY)) |
| { ADD_ACTIVE(state_offset + 1, 0); } |
| } |
| break; |
|
|
|
|
| |
| |
| |
| |
|
|
| #ifdef SUPPORT_UNICODE |
| case OP_PROP: |
| case OP_NOTPROP: |
| if (clen > 0) |
| { |
| BOOL OK; |
| int chartype; |
| const uint32_t *cp; |
| const ucd_record * prop = GET_UCD(c); |
| switch(code[1]) |
| { |
| case PT_LAMP: |
| chartype = prop->chartype; |
| OK = chartype == ucp_Lu || chartype == ucp_Ll || |
| chartype == ucp_Lt; |
| break; |
|
|
| case PT_GC: |
| OK = PRIV(ucp_gentype)[prop->chartype] == code[2]; |
| break; |
|
|
| case PT_PC: |
| OK = prop->chartype == code[2]; |
| break; |
|
|
| case PT_SC: |
| OK = prop->script == code[2]; |
| break; |
|
|
| case PT_SCX: |
| OK = (prop->script == code[2] || |
| MAPBIT(PRIV(ucd_script_sets) + UCD_SCRIPTX_PROP(prop), code[2]) != 0); |
| break; |
|
|
| |
|
|
| case PT_ALNUM: |
| chartype = prop->chartype; |
| OK = PRIV(ucp_gentype)[chartype] == ucp_L || |
| PRIV(ucp_gentype)[chartype] == ucp_N; |
| break; |
|
|
| |
| |
| |
|
|
| case PT_SPACE: |
| case PT_PXSPACE: |
| switch(c) |
| { |
| HSPACE_CASES: |
| VSPACE_CASES: |
| OK = TRUE; |
| break; |
|
|
| default: |
| OK = PRIV(ucp_gentype)[prop->chartype] == ucp_Z; |
| break; |
| } |
| break; |
|
|
| case PT_WORD: |
| chartype = prop->chartype; |
| OK = PRIV(ucp_gentype)[chartype] == ucp_L || |
| PRIV(ucp_gentype)[chartype] == ucp_N || |
| chartype == ucp_Mn || chartype == ucp_Pc; |
| break; |
|
|
| case PT_CLIST: |
| #if PCRE2_CODE_UNIT_WIDTH == 32 |
| if (c > MAX_UTF_CODE_POINT) |
| { |
| OK = FALSE; |
| break; |
| } |
| #endif |
| cp = PRIV(ucd_caseless_sets) + code[2]; |
| for (;;) |
| { |
| if (c < *cp) { OK = FALSE; break; } |
| if (c == *cp++) { OK = TRUE; break; } |
| } |
| break; |
|
|
| case PT_UCNC: |
| OK = c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT || |
| c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) || |
| c >= 0xe000; |
| break; |
|
|
| case PT_BIDICL: |
| OK = UCD_BIDICLASS(c) == code[2]; |
| break; |
|
|
| case PT_BOOL: |
| OK = MAPBIT(PRIV(ucd_boolprop_sets) + |
| UCD_BPROPS_PROP(prop), code[2]) != 0; |
| break; |
|
|
| |
|
|
| default: |
| OK = codevalue != OP_PROP; |
| break; |
| } |
|
|
| if (OK == (codevalue == OP_PROP)) { ADD_NEW(state_offset + 3, 0); } |
| } |
| break; |
| #endif |
|
|
|
|
|
|
| |
| |
| |
| |
| |
|
|
| case OP_TYPEPLUS: |
| case OP_TYPEMINPLUS: |
| case OP_TYPEPOSPLUS: |
| count = current_state->count; |
| if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); } |
| if (clen > 0) |
| { |
| if (d == OP_ANY && ptr + 1 >= mb->end_subject && |
| (mb->moptions & (PCRE2_PARTIAL_HARD)) != 0 && |
| NLBLOCK->nltype == NLTYPE_FIXED && |
| NLBLOCK->nllen == 2 && |
| c == NLBLOCK->nl[0]) |
| { |
| could_continue = partial_newline = TRUE; |
| } |
| else if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) || |
| (c < 256 && |
| (d != OP_ANY || !IS_NEWLINE(ptr)) && |
| ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0)) |
| { |
| if (count > 0 && codevalue == OP_TYPEPOSPLUS) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| count++; |
| ADD_NEW(state_offset, count); |
| } |
| } |
| break; |
|
|
| |
| case OP_TYPEQUERY: |
| case OP_TYPEMINQUERY: |
| case OP_TYPEPOSQUERY: |
| ADD_ACTIVE(state_offset + 2, 0); |
| if (clen > 0) |
| { |
| if (d == OP_ANY && ptr + 1 >= mb->end_subject && |
| (mb->moptions & (PCRE2_PARTIAL_HARD)) != 0 && |
| NLBLOCK->nltype == NLTYPE_FIXED && |
| NLBLOCK->nllen == 2 && |
| c == NLBLOCK->nl[0]) |
| { |
| could_continue = partial_newline = TRUE; |
| } |
| else if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) || |
| (c < 256 && |
| (d != OP_ANY || !IS_NEWLINE(ptr)) && |
| ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0)) |
| { |
| if (codevalue == OP_TYPEPOSQUERY) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| ADD_NEW(state_offset + 2, 0); |
| } |
| } |
| break; |
|
|
| |
| case OP_TYPESTAR: |
| case OP_TYPEMINSTAR: |
| case OP_TYPEPOSSTAR: |
| ADD_ACTIVE(state_offset + 2, 0); |
| if (clen > 0) |
| { |
| if (d == OP_ANY && ptr + 1 >= mb->end_subject && |
| (mb->moptions & (PCRE2_PARTIAL_HARD)) != 0 && |
| NLBLOCK->nltype == NLTYPE_FIXED && |
| NLBLOCK->nllen == 2 && |
| c == NLBLOCK->nl[0]) |
| { |
| could_continue = partial_newline = TRUE; |
| } |
| else if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) || |
| (c < 256 && |
| (d != OP_ANY || !IS_NEWLINE(ptr)) && |
| ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0)) |
| { |
| if (codevalue == OP_TYPEPOSSTAR) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| ADD_NEW(state_offset, 0); |
| } |
| } |
| break; |
|
|
| |
| case OP_TYPEEXACT: |
| count = current_state->count; |
| if (clen > 0) |
| { |
| if (d == OP_ANY && ptr + 1 >= mb->end_subject && |
| (mb->moptions & (PCRE2_PARTIAL_HARD)) != 0 && |
| NLBLOCK->nltype == NLTYPE_FIXED && |
| NLBLOCK->nllen == 2 && |
| c == NLBLOCK->nl[0]) |
| { |
| could_continue = partial_newline = TRUE; |
| } |
| else if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) || |
| (c < 256 && |
| (d != OP_ANY || !IS_NEWLINE(ptr)) && |
| ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0)) |
| { |
| if (++count >= (int)GET2(code, 1)) |
| { ADD_NEW(state_offset + 1 + IMM2_SIZE + 1, 0); } |
| else |
| { ADD_NEW(state_offset, count); } |
| } |
| } |
| break; |
|
|
| |
| case OP_TYPEUPTO: |
| case OP_TYPEMINUPTO: |
| case OP_TYPEPOSUPTO: |
| ADD_ACTIVE(state_offset + 2 + IMM2_SIZE, 0); |
| count = current_state->count; |
| if (clen > 0) |
| { |
| if (d == OP_ANY && ptr + 1 >= mb->end_subject && |
| (mb->moptions & (PCRE2_PARTIAL_HARD)) != 0 && |
| NLBLOCK->nltype == NLTYPE_FIXED && |
| NLBLOCK->nllen == 2 && |
| c == NLBLOCK->nl[0]) |
| { |
| could_continue = partial_newline = TRUE; |
| } |
| else if ((c >= 256 && d != OP_DIGIT && d != OP_WHITESPACE && d != OP_WORDCHAR) || |
| (c < 256 && |
| (d != OP_ANY || !IS_NEWLINE(ptr)) && |
| ((ctypes[c] & toptable1[d]) ^ toptable2[d]) != 0)) |
| { |
| if (codevalue == OP_TYPEPOSUPTO) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| if (++count >= (int)GET2(code, 1)) |
| { ADD_NEW(state_offset + 2 + IMM2_SIZE, 0); } |
| else |
| { ADD_NEW(state_offset, count); } |
| } |
| } |
| break; |
|
|
| |
| |
| |
| |
| |
|
|
| #ifdef SUPPORT_UNICODE |
| case OP_PROP_EXTRA + OP_TYPEPLUS: |
| case OP_PROP_EXTRA + OP_TYPEMINPLUS: |
| case OP_PROP_EXTRA + OP_TYPEPOSPLUS: |
| count = current_state->count; |
| if (count > 0) { ADD_ACTIVE(state_offset + 4, 0); } |
| if (clen > 0) |
| { |
| BOOL OK; |
| int chartype; |
| const uint32_t *cp; |
| const ucd_record * prop = GET_UCD(c); |
| switch(code[2]) |
| { |
| case PT_LAMP: |
| chartype = prop->chartype; |
| OK = chartype == ucp_Lu || chartype == ucp_Ll || chartype == ucp_Lt; |
| break; |
|
|
| case PT_GC: |
| OK = PRIV(ucp_gentype)[prop->chartype] == code[3]; |
| break; |
|
|
| case PT_PC: |
| OK = prop->chartype == code[3]; |
| break; |
|
|
| case PT_SC: |
| OK = prop->script == code[3]; |
| break; |
|
|
| case PT_SCX: |
| OK = (prop->script == code[3] || |
| MAPBIT(PRIV(ucd_script_sets) + UCD_SCRIPTX_PROP(prop), code[3]) != 0); |
| break; |
|
|
| |
|
|
| case PT_ALNUM: |
| chartype = prop->chartype; |
| OK = PRIV(ucp_gentype)[chartype] == ucp_L || |
| PRIV(ucp_gentype)[chartype] == ucp_N; |
| break; |
|
|
| |
| |
| |
|
|
| case PT_SPACE: |
| case PT_PXSPACE: |
| switch(c) |
| { |
| HSPACE_CASES: |
| VSPACE_CASES: |
| OK = TRUE; |
| break; |
|
|
| default: |
| OK = PRIV(ucp_gentype)[prop->chartype] == ucp_Z; |
| break; |
| } |
| break; |
|
|
| case PT_WORD: |
| chartype = prop->chartype; |
| OK = PRIV(ucp_gentype)[chartype] == ucp_L || |
| PRIV(ucp_gentype)[chartype] == ucp_N || |
| chartype == ucp_Mn || chartype == ucp_Pc; |
| break; |
|
|
| case PT_CLIST: |
| #if PCRE2_CODE_UNIT_WIDTH == 32 |
| if (c > MAX_UTF_CODE_POINT) |
| { |
| OK = FALSE; |
| break; |
| } |
| #endif |
| cp = PRIV(ucd_caseless_sets) + code[3]; |
| for (;;) |
| { |
| if (c < *cp) { OK = FALSE; break; } |
| if (c == *cp++) { OK = TRUE; break; } |
| } |
| break; |
|
|
| case PT_UCNC: |
| OK = c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT || |
| c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) || |
| c >= 0xe000; |
| break; |
|
|
| case PT_BIDICL: |
| OK = UCD_BIDICLASS(c) == code[3]; |
| break; |
|
|
| case PT_BOOL: |
| OK = MAPBIT(PRIV(ucd_boolprop_sets) + |
| UCD_BPROPS_PROP(prop), code[3]) != 0; |
| break; |
|
|
| |
|
|
| default: |
| OK = codevalue != OP_PROP; |
| break; |
| } |
|
|
| if (OK == (d == OP_PROP)) |
| { |
| if (count > 0 && codevalue == OP_PROP_EXTRA + OP_TYPEPOSPLUS) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| count++; |
| ADD_NEW(state_offset, count); |
| } |
| } |
| break; |
|
|
| |
| case OP_EXTUNI_EXTRA + OP_TYPEPLUS: |
| case OP_EXTUNI_EXTRA + OP_TYPEMINPLUS: |
| case OP_EXTUNI_EXTRA + OP_TYPEPOSPLUS: |
| count = current_state->count; |
| if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); } |
| if (clen > 0) |
| { |
| int ncount = 0; |
| if (count > 0 && codevalue == OP_EXTUNI_EXTRA + OP_TYPEPOSPLUS) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| (void)PRIV(extuni)(c, ptr + clen, mb->start_subject, end_subject, utf, |
| &ncount); |
| count++; |
| ADD_NEW_DATA(-state_offset, count, ncount); |
| } |
| break; |
| #endif |
|
|
| |
| case OP_ANYNL_EXTRA + OP_TYPEPLUS: |
| case OP_ANYNL_EXTRA + OP_TYPEMINPLUS: |
| case OP_ANYNL_EXTRA + OP_TYPEPOSPLUS: |
| count = current_state->count; |
| if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); } |
| if (clen > 0) |
| { |
| int ncount = 0; |
| switch (c) |
| { |
| case CHAR_VT: |
| case CHAR_FF: |
| case CHAR_NEL: |
| #ifndef EBCDIC |
| case 0x2028: |
| case 0x2029: |
| #endif |
| if (mb->bsr_convention == PCRE2_BSR_ANYCRLF) break; |
| goto ANYNL01; |
|
|
| case CHAR_CR: |
| if (ptr + 1 < end_subject && UCHAR21TEST(ptr + 1) == CHAR_LF) ncount = 1; |
| |
|
|
| ANYNL01: |
| case CHAR_LF: |
| if (count > 0 && codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSPLUS) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| count++; |
| ADD_NEW_DATA(-state_offset, count, ncount); |
| break; |
|
|
| default: |
| break; |
| } |
| } |
| break; |
|
|
| |
| case OP_VSPACE_EXTRA + OP_TYPEPLUS: |
| case OP_VSPACE_EXTRA + OP_TYPEMINPLUS: |
| case OP_VSPACE_EXTRA + OP_TYPEPOSPLUS: |
| count = current_state->count; |
| if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); } |
| if (clen > 0) |
| { |
| BOOL OK; |
| switch (c) |
| { |
| VSPACE_CASES: |
| OK = TRUE; |
| break; |
|
|
| default: |
| OK = FALSE; |
| break; |
| } |
|
|
| if (OK == (d == OP_VSPACE)) |
| { |
| if (count > 0 && codevalue == OP_VSPACE_EXTRA + OP_TYPEPOSPLUS) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| count++; |
| ADD_NEW_DATA(-state_offset, count, 0); |
| } |
| } |
| break; |
|
|
| |
| case OP_HSPACE_EXTRA + OP_TYPEPLUS: |
| case OP_HSPACE_EXTRA + OP_TYPEMINPLUS: |
| case OP_HSPACE_EXTRA + OP_TYPEPOSPLUS: |
| count = current_state->count; |
| if (count > 0) { ADD_ACTIVE(state_offset + 2, 0); } |
| if (clen > 0) |
| { |
| BOOL OK; |
| switch (c) |
| { |
| HSPACE_CASES: |
| OK = TRUE; |
| break; |
|
|
| default: |
| OK = FALSE; |
| break; |
| } |
|
|
| if (OK == (d == OP_HSPACE)) |
| { |
| if (count > 0 && codevalue == OP_HSPACE_EXTRA + OP_TYPEPOSPLUS) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| count++; |
| ADD_NEW_DATA(-state_offset, count, 0); |
| } |
| } |
| break; |
|
|
| |
| #ifdef SUPPORT_UNICODE |
| case OP_PROP_EXTRA + OP_TYPEQUERY: |
| case OP_PROP_EXTRA + OP_TYPEMINQUERY: |
| case OP_PROP_EXTRA + OP_TYPEPOSQUERY: |
| count = 4; |
| goto QS1; |
|
|
| case OP_PROP_EXTRA + OP_TYPESTAR: |
| case OP_PROP_EXTRA + OP_TYPEMINSTAR: |
| case OP_PROP_EXTRA + OP_TYPEPOSSTAR: |
| count = 0; |
|
|
| QS1: |
|
|
| ADD_ACTIVE(state_offset + 4, 0); |
| if (clen > 0) |
| { |
| BOOL OK; |
| int chartype; |
| const uint32_t *cp; |
| const ucd_record * prop = GET_UCD(c); |
| switch(code[2]) |
| { |
| case PT_LAMP: |
| chartype = prop->chartype; |
| OK = chartype == ucp_Lu || chartype == ucp_Ll || chartype == ucp_Lt; |
| break; |
|
|
| case PT_GC: |
| OK = PRIV(ucp_gentype)[prop->chartype] == code[3]; |
| break; |
|
|
| case PT_PC: |
| OK = prop->chartype == code[3]; |
| break; |
|
|
| case PT_SC: |
| OK = prop->script == code[3]; |
| break; |
|
|
| case PT_SCX: |
| OK = (prop->script == code[3] || |
| MAPBIT(PRIV(ucd_script_sets) + UCD_SCRIPTX_PROP(prop), code[3]) != 0); |
| break; |
|
|
| |
|
|
| case PT_ALNUM: |
| chartype = prop->chartype; |
| OK = PRIV(ucp_gentype)[chartype] == ucp_L || |
| PRIV(ucp_gentype)[chartype] == ucp_N; |
| break; |
|
|
| |
| |
| |
|
|
| case PT_SPACE: |
| case PT_PXSPACE: |
| switch(c) |
| { |
| HSPACE_CASES: |
| VSPACE_CASES: |
| OK = TRUE; |
| break; |
|
|
| default: |
| OK = PRIV(ucp_gentype)[prop->chartype] == ucp_Z; |
| break; |
| } |
| break; |
|
|
| case PT_WORD: |
| chartype = prop->chartype; |
| OK = PRIV(ucp_gentype)[chartype] == ucp_L || |
| PRIV(ucp_gentype)[chartype] == ucp_N || |
| chartype == ucp_Mn || chartype == ucp_Pc; |
| break; |
|
|
| case PT_CLIST: |
| #if PCRE2_CODE_UNIT_WIDTH == 32 |
| if (c > MAX_UTF_CODE_POINT) |
| { |
| OK = FALSE; |
| break; |
| } |
| #endif |
| cp = PRIV(ucd_caseless_sets) + code[3]; |
| for (;;) |
| { |
| if (c < *cp) { OK = FALSE; break; } |
| if (c == *cp++) { OK = TRUE; break; } |
| } |
| break; |
|
|
| case PT_UCNC: |
| OK = c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT || |
| c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) || |
| c >= 0xe000; |
| break; |
|
|
| case PT_BIDICL: |
| OK = UCD_BIDICLASS(c) == code[3]; |
| break; |
|
|
| case PT_BOOL: |
| OK = MAPBIT(PRIV(ucd_boolprop_sets) + |
| UCD_BPROPS_PROP(prop), code[3]) != 0; |
| break; |
|
|
| |
|
|
| default: |
| OK = codevalue != OP_PROP; |
| break; |
| } |
|
|
| if (OK == (d == OP_PROP)) |
| { |
| if (codevalue == OP_PROP_EXTRA + OP_TYPEPOSSTAR || |
| codevalue == OP_PROP_EXTRA + OP_TYPEPOSQUERY) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| ADD_NEW(state_offset + count, 0); |
| } |
| } |
| break; |
|
|
| |
| case OP_EXTUNI_EXTRA + OP_TYPEQUERY: |
| case OP_EXTUNI_EXTRA + OP_TYPEMINQUERY: |
| case OP_EXTUNI_EXTRA + OP_TYPEPOSQUERY: |
| count = 2; |
| goto QS2; |
|
|
| case OP_EXTUNI_EXTRA + OP_TYPESTAR: |
| case OP_EXTUNI_EXTRA + OP_TYPEMINSTAR: |
| case OP_EXTUNI_EXTRA + OP_TYPEPOSSTAR: |
| count = 0; |
|
|
| QS2: |
|
|
| ADD_ACTIVE(state_offset + 2, 0); |
| if (clen > 0) |
| { |
| int ncount = 0; |
| if (codevalue == OP_EXTUNI_EXTRA + OP_TYPEPOSSTAR || |
| codevalue == OP_EXTUNI_EXTRA + OP_TYPEPOSQUERY) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| (void)PRIV(extuni)(c, ptr + clen, mb->start_subject, end_subject, utf, |
| &ncount); |
| ADD_NEW_DATA(-(state_offset + count), 0, ncount); |
| } |
| break; |
| #endif |
|
|
| |
| case OP_ANYNL_EXTRA + OP_TYPEQUERY: |
| case OP_ANYNL_EXTRA + OP_TYPEMINQUERY: |
| case OP_ANYNL_EXTRA + OP_TYPEPOSQUERY: |
| count = 2; |
| goto QS3; |
|
|
| case OP_ANYNL_EXTRA + OP_TYPESTAR: |
| case OP_ANYNL_EXTRA + OP_TYPEMINSTAR: |
| case OP_ANYNL_EXTRA + OP_TYPEPOSSTAR: |
| count = 0; |
|
|
| QS3: |
| ADD_ACTIVE(state_offset + 2, 0); |
| if (clen > 0) |
| { |
| int ncount = 0; |
| switch (c) |
| { |
| case CHAR_VT: |
| case CHAR_FF: |
| case CHAR_NEL: |
| #ifndef EBCDIC |
| case 0x2028: |
| case 0x2029: |
| #endif |
| if (mb->bsr_convention == PCRE2_BSR_ANYCRLF) break; |
| goto ANYNL02; |
|
|
| case CHAR_CR: |
| if (ptr + 1 < end_subject && UCHAR21TEST(ptr + 1) == CHAR_LF) ncount = 1; |
| |
|
|
| ANYNL02: |
| case CHAR_LF: |
| if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSSTAR || |
| codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSQUERY) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| ADD_NEW_DATA(-(state_offset + (int)count), 0, ncount); |
| break; |
|
|
| default: |
| break; |
| } |
| } |
| break; |
|
|
| |
| case OP_VSPACE_EXTRA + OP_TYPEQUERY: |
| case OP_VSPACE_EXTRA + OP_TYPEMINQUERY: |
| case OP_VSPACE_EXTRA + OP_TYPEPOSQUERY: |
| count = 2; |
| goto QS4; |
|
|
| case OP_VSPACE_EXTRA + OP_TYPESTAR: |
| case OP_VSPACE_EXTRA + OP_TYPEMINSTAR: |
| case OP_VSPACE_EXTRA + OP_TYPEPOSSTAR: |
| count = 0; |
|
|
| QS4: |
| ADD_ACTIVE(state_offset + 2, 0); |
| if (clen > 0) |
| { |
| BOOL OK; |
| switch (c) |
| { |
| VSPACE_CASES: |
| OK = TRUE; |
| break; |
|
|
| default: |
| OK = FALSE; |
| break; |
| } |
| if (OK == (d == OP_VSPACE)) |
| { |
| if (codevalue == OP_VSPACE_EXTRA + OP_TYPEPOSSTAR || |
| codevalue == OP_VSPACE_EXTRA + OP_TYPEPOSQUERY) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| ADD_NEW_DATA(-(state_offset + (int)count), 0, 0); |
| } |
| } |
| break; |
|
|
| |
| case OP_HSPACE_EXTRA + OP_TYPEQUERY: |
| case OP_HSPACE_EXTRA + OP_TYPEMINQUERY: |
| case OP_HSPACE_EXTRA + OP_TYPEPOSQUERY: |
| count = 2; |
| goto QS5; |
|
|
| case OP_HSPACE_EXTRA + OP_TYPESTAR: |
| case OP_HSPACE_EXTRA + OP_TYPEMINSTAR: |
| case OP_HSPACE_EXTRA + OP_TYPEPOSSTAR: |
| count = 0; |
|
|
| QS5: |
| ADD_ACTIVE(state_offset + 2, 0); |
| if (clen > 0) |
| { |
| BOOL OK; |
| switch (c) |
| { |
| HSPACE_CASES: |
| OK = TRUE; |
| break; |
|
|
| default: |
| OK = FALSE; |
| break; |
| } |
|
|
| if (OK == (d == OP_HSPACE)) |
| { |
| if (codevalue == OP_HSPACE_EXTRA + OP_TYPEPOSSTAR || |
| codevalue == OP_HSPACE_EXTRA + OP_TYPEPOSQUERY) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| ADD_NEW_DATA(-(state_offset + (int)count), 0, 0); |
| } |
| } |
| break; |
|
|
| |
| #ifdef SUPPORT_UNICODE |
| case OP_PROP_EXTRA + OP_TYPEEXACT: |
| case OP_PROP_EXTRA + OP_TYPEUPTO: |
| case OP_PROP_EXTRA + OP_TYPEMINUPTO: |
| case OP_PROP_EXTRA + OP_TYPEPOSUPTO: |
| if (codevalue != OP_PROP_EXTRA + OP_TYPEEXACT) |
| { ADD_ACTIVE(state_offset + 1 + IMM2_SIZE + 3, 0); } |
| count = current_state->count; |
| if (clen > 0) |
| { |
| BOOL OK; |
| int chartype; |
| const uint32_t *cp; |
| const ucd_record * prop = GET_UCD(c); |
| switch(code[1 + IMM2_SIZE + 1]) |
| { |
| case PT_LAMP: |
| chartype = prop->chartype; |
| OK = chartype == ucp_Lu || chartype == ucp_Ll || chartype == ucp_Lt; |
| break; |
|
|
| case PT_GC: |
| OK = PRIV(ucp_gentype)[prop->chartype] == code[1 + IMM2_SIZE + 2]; |
| break; |
|
|
| case PT_PC: |
| OK = prop->chartype == code[1 + IMM2_SIZE + 2]; |
| break; |
|
|
| case PT_SC: |
| OK = prop->script == code[1 + IMM2_SIZE + 2]; |
| break; |
|
|
| case PT_SCX: |
| OK = (prop->script == code[1 + IMM2_SIZE + 2] || |
| MAPBIT(PRIV(ucd_script_sets) + UCD_SCRIPTX_PROP(prop), |
| code[1 + IMM2_SIZE + 2]) != 0); |
| break; |
|
|
| |
|
|
| case PT_ALNUM: |
| chartype = prop->chartype; |
| OK = PRIV(ucp_gentype)[chartype] == ucp_L || |
| PRIV(ucp_gentype)[chartype] == ucp_N; |
| break; |
|
|
| |
| |
| |
|
|
| case PT_SPACE: |
| case PT_PXSPACE: |
| switch(c) |
| { |
| HSPACE_CASES: |
| VSPACE_CASES: |
| OK = TRUE; |
| break; |
|
|
| default: |
| OK = PRIV(ucp_gentype)[prop->chartype] == ucp_Z; |
| break; |
| } |
| break; |
|
|
| case PT_WORD: |
| chartype = prop->chartype; |
| OK = PRIV(ucp_gentype)[chartype] == ucp_L || |
| PRIV(ucp_gentype)[chartype] == ucp_N || |
| chartype == ucp_Mn || chartype == ucp_Pc; |
| break; |
|
|
| case PT_CLIST: |
| #if PCRE2_CODE_UNIT_WIDTH == 32 |
| if (c > MAX_UTF_CODE_POINT) |
| { |
| OK = FALSE; |
| break; |
| } |
| #endif |
| cp = PRIV(ucd_caseless_sets) + code[1 + IMM2_SIZE + 2]; |
| for (;;) |
| { |
| if (c < *cp) { OK = FALSE; break; } |
| if (c == *cp++) { OK = TRUE; break; } |
| } |
| break; |
|
|
| case PT_UCNC: |
| OK = c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT || |
| c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) || |
| c >= 0xe000; |
| break; |
|
|
| case PT_BIDICL: |
| OK = UCD_BIDICLASS(c) == code[1 + IMM2_SIZE + 2]; |
| break; |
|
|
| case PT_BOOL: |
| OK = MAPBIT(PRIV(ucd_boolprop_sets) + |
| UCD_BPROPS_PROP(prop), code[1 + IMM2_SIZE + 2]) != 0; |
| break; |
|
|
| |
|
|
| default: |
| OK = codevalue != OP_PROP; |
| break; |
| } |
|
|
| if (OK == (d == OP_PROP)) |
| { |
| if (codevalue == OP_PROP_EXTRA + OP_TYPEPOSUPTO) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| if (++count >= (int)GET2(code, 1)) |
| { ADD_NEW(state_offset + 1 + IMM2_SIZE + 3, 0); } |
| else |
| { ADD_NEW(state_offset, count); } |
| } |
| } |
| break; |
|
|
| |
| case OP_EXTUNI_EXTRA + OP_TYPEEXACT: |
| case OP_EXTUNI_EXTRA + OP_TYPEUPTO: |
| case OP_EXTUNI_EXTRA + OP_TYPEMINUPTO: |
| case OP_EXTUNI_EXTRA + OP_TYPEPOSUPTO: |
| if (codevalue != OP_EXTUNI_EXTRA + OP_TYPEEXACT) |
| { ADD_ACTIVE(state_offset + 2 + IMM2_SIZE, 0); } |
| count = current_state->count; |
| if (clen > 0) |
| { |
| PCRE2_SPTR nptr; |
| int ncount = 0; |
| if (codevalue == OP_EXTUNI_EXTRA + OP_TYPEPOSUPTO) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| nptr = PRIV(extuni)(c, ptr + clen, mb->start_subject, end_subject, utf, |
| &ncount); |
| if (nptr >= end_subject && (mb->moptions & PCRE2_PARTIAL_HARD) != 0) |
| reset_could_continue = TRUE; |
| if (++count >= (int)GET2(code, 1)) |
| { ADD_NEW_DATA(-(state_offset + 2 + IMM2_SIZE), 0, ncount); } |
| else |
| { ADD_NEW_DATA(-state_offset, count, ncount); } |
| } |
| break; |
| #endif |
|
|
| |
| case OP_ANYNL_EXTRA + OP_TYPEEXACT: |
| case OP_ANYNL_EXTRA + OP_TYPEUPTO: |
| case OP_ANYNL_EXTRA + OP_TYPEMINUPTO: |
| case OP_ANYNL_EXTRA + OP_TYPEPOSUPTO: |
| if (codevalue != OP_ANYNL_EXTRA + OP_TYPEEXACT) |
| { ADD_ACTIVE(state_offset + 2 + IMM2_SIZE, 0); } |
| count = current_state->count; |
| if (clen > 0) |
| { |
| int ncount = 0; |
| switch (c) |
| { |
| case CHAR_VT: |
| case CHAR_FF: |
| case CHAR_NEL: |
| #ifndef EBCDIC |
| case 0x2028: |
| case 0x2029: |
| #endif |
| if (mb->bsr_convention == PCRE2_BSR_ANYCRLF) break; |
| goto ANYNL03; |
|
|
| case CHAR_CR: |
| if (ptr + 1 < end_subject && UCHAR21TEST(ptr + 1) == CHAR_LF) ncount = 1; |
| |
|
|
| ANYNL03: |
| case CHAR_LF: |
| if (codevalue == OP_ANYNL_EXTRA + OP_TYPEPOSUPTO) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| if (++count >= (int)GET2(code, 1)) |
| { ADD_NEW_DATA(-(state_offset + 2 + IMM2_SIZE), 0, ncount); } |
| else |
| { ADD_NEW_DATA(-state_offset, count, ncount); } |
| break; |
|
|
| default: |
| break; |
| } |
| } |
| break; |
|
|
| |
| case OP_VSPACE_EXTRA + OP_TYPEEXACT: |
| case OP_VSPACE_EXTRA + OP_TYPEUPTO: |
| case OP_VSPACE_EXTRA + OP_TYPEMINUPTO: |
| case OP_VSPACE_EXTRA + OP_TYPEPOSUPTO: |
| if (codevalue != OP_VSPACE_EXTRA + OP_TYPEEXACT) |
| { ADD_ACTIVE(state_offset + 2 + IMM2_SIZE, 0); } |
| count = current_state->count; |
| if (clen > 0) |
| { |
| BOOL OK; |
| switch (c) |
| { |
| VSPACE_CASES: |
| OK = TRUE; |
| break; |
|
|
| default: |
| OK = FALSE; |
| } |
|
|
| if (OK == (d == OP_VSPACE)) |
| { |
| if (codevalue == OP_VSPACE_EXTRA + OP_TYPEPOSUPTO) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| if (++count >= (int)GET2(code, 1)) |
| { ADD_NEW_DATA(-(state_offset + 2 + IMM2_SIZE), 0, 0); } |
| else |
| { ADD_NEW_DATA(-state_offset, count, 0); } |
| } |
| } |
| break; |
|
|
| |
| case OP_HSPACE_EXTRA + OP_TYPEEXACT: |
| case OP_HSPACE_EXTRA + OP_TYPEUPTO: |
| case OP_HSPACE_EXTRA + OP_TYPEMINUPTO: |
| case OP_HSPACE_EXTRA + OP_TYPEPOSUPTO: |
| if (codevalue != OP_HSPACE_EXTRA + OP_TYPEEXACT) |
| { ADD_ACTIVE(state_offset + 2 + IMM2_SIZE, 0); } |
| count = current_state->count; |
| if (clen > 0) |
| { |
| BOOL OK; |
| switch (c) |
| { |
| HSPACE_CASES: |
| OK = TRUE; |
| break; |
|
|
| default: |
| OK = FALSE; |
| break; |
| } |
|
|
| if (OK == (d == OP_HSPACE)) |
| { |
| if (codevalue == OP_HSPACE_EXTRA + OP_TYPEPOSUPTO) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| if (++count >= (int)GET2(code, 1)) |
| { ADD_NEW_DATA(-(state_offset + 2 + IMM2_SIZE), 0, 0); } |
| else |
| { ADD_NEW_DATA(-state_offset, count, 0); } |
| } |
| } |
| break; |
|
|
| |
| |
| |
| |
| |
|
|
| |
| case OP_CHAR: |
| if (clen > 0 && c == d) { ADD_NEW(state_offset + dlen + 1, 0); } |
| break; |
|
|
| |
| case OP_CHARI: |
| if (clen == 0) break; |
|
|
| #ifdef SUPPORT_UNICODE |
| if (utf_or_ucp) |
| { |
| if (c == d) { ADD_NEW(state_offset + dlen + 1, 0); } else |
| { |
| unsigned int othercase; |
| if (c < 128) |
| othercase = fcc[c]; |
| else |
| othercase = UCD_OTHERCASE(c); |
| if (d == othercase) { ADD_NEW(state_offset + dlen + 1, 0); } |
| } |
| } |
| else |
| #endif |
| |
| { |
| if (TABLE_GET(c, lcc, c) == TABLE_GET(d, lcc, d)) |
| { ADD_NEW(state_offset + 2, 0); } |
| } |
| break; |
|
|
|
|
| #ifdef SUPPORT_UNICODE |
| |
| |
| |
| |
|
|
| case OP_EXTUNI: |
| if (clen > 0) |
| { |
| int ncount = 0; |
| PCRE2_SPTR nptr = PRIV(extuni)(c, ptr + clen, mb->start_subject, |
| end_subject, utf, &ncount); |
| if (nptr >= end_subject && (mb->moptions & PCRE2_PARTIAL_HARD) != 0) |
| reset_could_continue = TRUE; |
| ADD_NEW_DATA(-(state_offset + 1), 0, ncount); |
| } |
| break; |
| #endif |
|
|
| |
| |
| |
| |
|
|
| case OP_ANYNL: |
| if (clen > 0) switch(c) |
| { |
| case CHAR_VT: |
| case CHAR_FF: |
| case CHAR_NEL: |
| #ifndef EBCDIC |
| case 0x2028: |
| case 0x2029: |
| #endif |
| if (mb->bsr_convention == PCRE2_BSR_ANYCRLF) break; |
| PCRE2_FALLTHROUGH |
|
|
| case CHAR_LF: |
| ADD_NEW(state_offset + 1, 0); |
| break; |
|
|
| case CHAR_CR: |
| if (ptr + 1 >= end_subject) |
| { |
| ADD_NEW(state_offset + 1, 0); |
| if ((mb->moptions & PCRE2_PARTIAL_HARD) != 0) |
| reset_could_continue = TRUE; |
| } |
| else if (UCHAR21TEST(ptr + 1) == CHAR_LF) |
| { |
| ADD_NEW_DATA(-(state_offset + 1), 0, 1); |
| } |
| else |
| { |
| ADD_NEW(state_offset + 1, 0); |
| } |
| break; |
| } |
| break; |
|
|
| |
| case OP_NOT_VSPACE: |
| if (clen > 0) switch(c) |
| { |
| VSPACE_CASES: |
| break; |
|
|
| default: |
| ADD_NEW(state_offset + 1, 0); |
| break; |
| } |
| break; |
|
|
| |
| case OP_VSPACE: |
| if (clen > 0) switch(c) |
| { |
| VSPACE_CASES: |
| ADD_NEW(state_offset + 1, 0); |
| break; |
|
|
| default: |
| break; |
| } |
| break; |
|
|
| |
| case OP_NOT_HSPACE: |
| if (clen > 0) switch(c) |
| { |
| HSPACE_CASES: |
| break; |
|
|
| default: |
| ADD_NEW(state_offset + 1, 0); |
| break; |
| } |
| break; |
|
|
| |
| case OP_HSPACE: |
| if (clen > 0) switch(c) |
| { |
| HSPACE_CASES: |
| ADD_NEW(state_offset + 1, 0); |
| break; |
|
|
| default: |
| break; |
| } |
| break; |
|
|
| |
| |
|
|
| case OP_NOT: |
| if (clen > 0 && c != d) { ADD_NEW(state_offset + dlen + 1, 0); } |
| break; |
|
|
| |
| |
|
|
| case OP_NOTI: |
| if (clen > 0) |
| { |
| uint32_t otherd; |
| #ifdef SUPPORT_UNICODE |
| if (utf_or_ucp && d >= 128) |
| otherd = UCD_OTHERCASE(d); |
| else |
| #endif |
| otherd = TABLE_GET(d, fcc, d); |
| if (c != d && c != otherd) |
| { ADD_NEW(state_offset + dlen + 1, 0); } |
| } |
| break; |
|
|
| |
| case OP_PLUSI: |
| case OP_MINPLUSI: |
| case OP_POSPLUSI: |
| case OP_NOTPLUSI: |
| case OP_NOTMINPLUSI: |
| case OP_NOTPOSPLUSI: |
| caseless = TRUE; |
| codevalue -= OP_STARI - OP_STAR; |
|
|
| PCRE2_FALLTHROUGH |
| case OP_PLUS: |
| case OP_MINPLUS: |
| case OP_POSPLUS: |
| case OP_NOTPLUS: |
| case OP_NOTMINPLUS: |
| case OP_NOTPOSPLUS: |
| count = current_state->count; |
| if (count > 0) { ADD_ACTIVE(state_offset + dlen + 1, 0); } |
| if (clen > 0) |
| { |
| uint32_t otherd = NOTACHAR; |
| if (caseless) |
| { |
| #ifdef SUPPORT_UNICODE |
| if (utf_or_ucp && d >= 128) |
| otherd = UCD_OTHERCASE(d); |
| else |
| #endif |
| otherd = TABLE_GET(d, fcc, d); |
| } |
| if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR)) |
| { |
| if (count > 0 && |
| (codevalue == OP_POSPLUS || codevalue == OP_NOTPOSPLUS)) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| count++; |
| ADD_NEW(state_offset, count); |
| } |
| } |
| break; |
|
|
| |
| case OP_QUERYI: |
| case OP_MINQUERYI: |
| case OP_POSQUERYI: |
| case OP_NOTQUERYI: |
| case OP_NOTMINQUERYI: |
| case OP_NOTPOSQUERYI: |
| caseless = TRUE; |
| codevalue -= OP_STARI - OP_STAR; |
| PCRE2_FALLTHROUGH |
| case OP_QUERY: |
| case OP_MINQUERY: |
| case OP_POSQUERY: |
| case OP_NOTQUERY: |
| case OP_NOTMINQUERY: |
| case OP_NOTPOSQUERY: |
| ADD_ACTIVE(state_offset + dlen + 1, 0); |
| if (clen > 0) |
| { |
| uint32_t otherd = NOTACHAR; |
| if (caseless) |
| { |
| #ifdef SUPPORT_UNICODE |
| if (utf_or_ucp && d >= 128) |
| otherd = UCD_OTHERCASE(d); |
| else |
| #endif |
| otherd = TABLE_GET(d, fcc, d); |
| } |
| if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR)) |
| { |
| if (codevalue == OP_POSQUERY || codevalue == OP_NOTPOSQUERY) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| ADD_NEW(state_offset + dlen + 1, 0); |
| } |
| } |
| break; |
|
|
| |
| case OP_STARI: |
| case OP_MINSTARI: |
| case OP_POSSTARI: |
| case OP_NOTSTARI: |
| case OP_NOTMINSTARI: |
| case OP_NOTPOSSTARI: |
| caseless = TRUE; |
| codevalue -= OP_STARI - OP_STAR; |
| PCRE2_FALLTHROUGH |
| case OP_STAR: |
| case OP_MINSTAR: |
| case OP_POSSTAR: |
| case OP_NOTSTAR: |
| case OP_NOTMINSTAR: |
| case OP_NOTPOSSTAR: |
| ADD_ACTIVE(state_offset + dlen + 1, 0); |
| if (clen > 0) |
| { |
| uint32_t otherd = NOTACHAR; |
| if (caseless) |
| { |
| #ifdef SUPPORT_UNICODE |
| if (utf_or_ucp && d >= 128) |
| otherd = UCD_OTHERCASE(d); |
| else |
| #endif |
| otherd = TABLE_GET(d, fcc, d); |
| } |
| if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR)) |
| { |
| if (codevalue == OP_POSSTAR || codevalue == OP_NOTPOSSTAR) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| ADD_NEW(state_offset, 0); |
| } |
| } |
| break; |
|
|
| |
| case OP_EXACTI: |
| case OP_NOTEXACTI: |
| caseless = TRUE; |
| codevalue -= OP_STARI - OP_STAR; |
| PCRE2_FALLTHROUGH |
| case OP_EXACT: |
| case OP_NOTEXACT: |
| count = current_state->count; |
| if (clen > 0) |
| { |
| uint32_t otherd = NOTACHAR; |
| if (caseless) |
| { |
| #ifdef SUPPORT_UNICODE |
| if (utf_or_ucp && d >= 128) |
| otherd = UCD_OTHERCASE(d); |
| else |
| #endif |
| otherd = TABLE_GET(d, fcc, d); |
| } |
| if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR)) |
| { |
| if (++count >= (int)GET2(code, 1)) |
| { ADD_NEW(state_offset + dlen + 1 + IMM2_SIZE, 0); } |
| else |
| { ADD_NEW(state_offset, count); } |
| } |
| } |
| break; |
|
|
| |
| case OP_UPTOI: |
| case OP_MINUPTOI: |
| case OP_POSUPTOI: |
| case OP_NOTUPTOI: |
| case OP_NOTMINUPTOI: |
| case OP_NOTPOSUPTOI: |
| caseless = TRUE; |
| codevalue -= OP_STARI - OP_STAR; |
| PCRE2_FALLTHROUGH |
| case OP_UPTO: |
| case OP_MINUPTO: |
| case OP_POSUPTO: |
| case OP_NOTUPTO: |
| case OP_NOTMINUPTO: |
| case OP_NOTPOSUPTO: |
| ADD_ACTIVE(state_offset + dlen + 1 + IMM2_SIZE, 0); |
| count = current_state->count; |
| if (clen > 0) |
| { |
| uint32_t otherd = NOTACHAR; |
| if (caseless) |
| { |
| #ifdef SUPPORT_UNICODE |
| if (utf_or_ucp && d >= 128) |
| otherd = UCD_OTHERCASE(d); |
| else |
| #endif |
| otherd = TABLE_GET(d, fcc, d); |
| } |
| if ((c == d || c == otherd) == (codevalue < OP_NOTSTAR)) |
| { |
| if (codevalue == OP_POSUPTO || codevalue == OP_NOTPOSUPTO) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| if (++count >= (int)GET2(code, 1)) |
| { ADD_NEW(state_offset + dlen + 1 + IMM2_SIZE, 0); } |
| else |
| { ADD_NEW(state_offset, count); } |
| } |
| } |
| break; |
|
|
|
|
| |
| |
|
|
| case OP_CLASS: |
| case OP_NCLASS: |
| #ifdef SUPPORT_WIDE_CHARS |
| case OP_XCLASS: |
| case OP_ECLASS: |
| #endif |
| { |
| BOOL isinclass = FALSE; |
| int next_state_offset; |
| PCRE2_SPTR ecode; |
|
|
| #ifdef SUPPORT_WIDE_CHARS |
| |
| |
| |
|
|
| if (codevalue == OP_XCLASS) |
| { |
| ecode = code + GET(code, 1); |
| if (clen > 0) |
| isinclass = PRIV(xclass)(c, code + 1 + LINK_SIZE, |
| (const uint8_t*)mb->start_code, utf); |
| } |
|
|
| |
| |
|
|
| else if (codevalue == OP_ECLASS) |
| { |
| ecode = code + GET(code, 1); |
| if (clen > 0) |
| isinclass = PRIV(eclass)(c, code + 1 + LINK_SIZE, ecode, |
| (const uint8_t*)mb->start_code, utf); |
| } |
|
|
| else |
| #endif |
|
|
| |
| |
|
|
| { |
| ecode = code + 1 + (32 / sizeof(PCRE2_UCHAR)); |
| if (clen > 0) |
| { |
| isinclass = (c > 255)? (codevalue == OP_NCLASS) : |
| ((((const uint8_t *)(code + 1))[c/8] & (1u << (c&7))) != 0); |
| } |
| } |
|
|
| |
| |
| |
|
|
| next_state_offset = (int)(ecode - start_code); |
|
|
| switch (*ecode) |
| { |
| case OP_CRSTAR: |
| case OP_CRMINSTAR: |
| case OP_CRPOSSTAR: |
| ADD_ACTIVE(next_state_offset + 1, 0); |
| if (isinclass) |
| { |
| if (*ecode == OP_CRPOSSTAR) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| ADD_NEW(state_offset, 0); |
| } |
| break; |
|
|
| case OP_CRPLUS: |
| case OP_CRMINPLUS: |
| case OP_CRPOSPLUS: |
| count = current_state->count; |
| if (count > 0) { ADD_ACTIVE(next_state_offset + 1, 0); } |
| if (isinclass) |
| { |
| if (count > 0 && *ecode == OP_CRPOSPLUS) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| count++; |
| ADD_NEW(state_offset, count); |
| } |
| break; |
|
|
| case OP_CRQUERY: |
| case OP_CRMINQUERY: |
| case OP_CRPOSQUERY: |
| ADD_ACTIVE(next_state_offset + 1, 0); |
| if (isinclass) |
| { |
| if (*ecode == OP_CRPOSQUERY) |
| { |
| active_count--; |
| next_active_state--; |
| } |
| ADD_NEW(next_state_offset + 1, 0); |
| } |
| break; |
|
|
| case OP_CRRANGE: |
| case OP_CRMINRANGE: |
| case OP_CRPOSRANGE: |
| count = current_state->count; |
| if (count >= (int)GET2(ecode, 1)) |
| { ADD_ACTIVE(next_state_offset + 1 + 2 * IMM2_SIZE, 0); } |
| if (isinclass) |
| { |
| int max = (int)GET2(ecode, 1 + IMM2_SIZE); |
|
|
| if (*ecode == OP_CRPOSRANGE && count >= (int)GET2(ecode, 1)) |
| { |
| active_count--; |
| next_active_state--; |
| } |
|
|
| if (++count >= max && max != 0) |
| { ADD_NEW(next_state_offset + 1 + 2 * IMM2_SIZE, 0); } |
| else |
| { ADD_NEW(state_offset, count); } |
| } |
| break; |
|
|
| default: |
| if (isinclass) { ADD_NEW(next_state_offset, 0); } |
| break; |
| } |
| } |
| break; |
|
|
| |
| |
| |
| |
| |
|
|
| case OP_FAIL: |
| break; |
|
|
| case OP_ASSERT: |
| case OP_ASSERT_NOT: |
| case OP_ASSERTBACK: |
| case OP_ASSERTBACK_NOT: |
| { |
| int rc; |
| int *local_workspace; |
| PCRE2_SIZE *local_offsets; |
| PCRE2_SPTR endasscode = code + GET(code, 1); |
| RWS_anchor *rws = (RWS_anchor *)RWS; |
|
|
| if (rws->free < RWS_RSIZE + RWS_OVEC_OSIZE) |
| { |
| rc = more_workspace(&rws, RWS_OVEC_OSIZE, mb); |
| if (rc != 0) return rc; |
| RWS = (int *)rws; |
| } |
|
|
| local_offsets = (PCRE2_SIZE *)(RWS + rws->size - rws->free); |
| local_workspace = ((int *)local_offsets) + RWS_OVEC_OSIZE; |
| rws->free -= RWS_RSIZE + RWS_OVEC_OSIZE; |
|
|
| while (*endasscode == OP_ALT) endasscode += GET(endasscode, 1); |
|
|
| rc = internal_dfa_match( |
| mb, |
| code, |
| ptr, |
| (PCRE2_SIZE)(ptr - start_subject), |
| local_offsets, |
| RWS_OVEC_OSIZE/OVEC_UNIT, |
| local_workspace, |
| RWS_RSIZE, |
| rlevel, |
| RWS); |
|
|
| rws->free += RWS_RSIZE + RWS_OVEC_OSIZE; |
|
|
| if (rc < 0 && rc != PCRE2_ERROR_NOMATCH) return rc; |
| if ((rc >= 0) == (codevalue == OP_ASSERT || codevalue == OP_ASSERTBACK)) |
| { ADD_ACTIVE((int)(endasscode + LINK_SIZE + 1 - start_code), 0); } |
| } |
| break; |
|
|
| |
| case OP_COND: |
| case OP_SCOND: |
| { |
| int codelink = (int)GET(code, 1); |
| PCRE2_UCHAR condcode; |
|
|
| |
| |
| |
|
|
| if (code[LINK_SIZE + 1] == OP_CALLOUT |
| || code[LINK_SIZE + 1] == OP_CALLOUT_STR) |
| { |
| PCRE2_SIZE callout_length; |
| rrc = do_callout_dfa(code, offsets, current_subject, ptr, mb, |
| 1 + LINK_SIZE, &callout_length); |
| if (rrc < 0) return rrc; |
| if (rrc > 0) break; |
| code += callout_length; |
| } |
|
|
| condcode = code[LINK_SIZE+1]; |
|
|
| |
| |
|
|
| if (condcode == OP_CREF || condcode == OP_DNCREF || |
| condcode == OP_DNRREF) |
| return PCRE2_ERROR_DFA_UCOND; |
|
|
| |
| |
|
|
| if (condcode == OP_FALSE || condcode == OP_FAIL) |
| { ADD_ACTIVE(state_offset + codelink + LINK_SIZE + 1, 0); } |
|
|
| |
|
|
| else if (condcode == OP_TRUE) |
| { ADD_ACTIVE(state_offset + LINK_SIZE + 2, 0); } |
|
|
| |
| |
| |
|
|
| else if (condcode == OP_RREF) |
| { |
| unsigned int value = GET2(code, LINK_SIZE + 2); |
| if (value != RREF_ANY) return PCRE2_ERROR_DFA_UCOND; |
| if (mb->recursive != NULL) |
| { ADD_ACTIVE(state_offset + LINK_SIZE + 2 + IMM2_SIZE, 0); } |
| else { ADD_ACTIVE(state_offset + codelink + LINK_SIZE + 1, 0); } |
| } |
|
|
| |
|
|
| else |
| { |
| int rc; |
| int *local_workspace; |
| PCRE2_SIZE *local_offsets; |
| PCRE2_SPTR asscode = code + LINK_SIZE + 1; |
| PCRE2_SPTR endasscode = asscode + GET(asscode, 1); |
| RWS_anchor *rws = (RWS_anchor *)RWS; |
|
|
| if (rws->free < RWS_RSIZE + RWS_OVEC_OSIZE) |
| { |
| rc = more_workspace(&rws, RWS_OVEC_OSIZE, mb); |
| if (rc != 0) return rc; |
| RWS = (int *)rws; |
| } |
|
|
| local_offsets = (PCRE2_SIZE *)(RWS + rws->size - rws->free); |
| local_workspace = ((int *)local_offsets) + RWS_OVEC_OSIZE; |
| rws->free -= RWS_RSIZE + RWS_OVEC_OSIZE; |
|
|
| while (*endasscode == OP_ALT) endasscode += GET(endasscode, 1); |
|
|
| rc = internal_dfa_match( |
| mb, |
| asscode, |
| ptr, |
| (PCRE2_SIZE)(ptr - start_subject), |
| local_offsets, |
| RWS_OVEC_OSIZE/OVEC_UNIT, |
| local_workspace, |
| RWS_RSIZE, |
| rlevel, |
| RWS); |
|
|
| rws->free += RWS_RSIZE + RWS_OVEC_OSIZE; |
|
|
| if (rc < 0 && rc != PCRE2_ERROR_NOMATCH) return rc; |
| if ((rc >= 0) == |
| (condcode == OP_ASSERT || condcode == OP_ASSERTBACK)) |
| { ADD_ACTIVE((int)(endasscode + LINK_SIZE + 1 - start_code), 0); } |
| else |
| { ADD_ACTIVE(state_offset + codelink + LINK_SIZE + 1, 0); } |
| } |
| } |
| break; |
|
|
| |
| case OP_RECURSE: |
| { |
| int rc; |
| int *local_workspace; |
| PCRE2_SIZE *local_offsets; |
| RWS_anchor *rws = (RWS_anchor *)RWS; |
| PCRE2_SPTR callpat = start_code + GET(code, 1); |
| uint32_t recno = (callpat == mb->start_code)? 0 : |
| GET2(callpat, 1 + LINK_SIZE); |
|
|
| |
| if (code[1 + LINK_SIZE] == OP_CREF) return PCRE2_ERROR_DFA_UITEM; |
|
|
| if (rws->free < RWS_RSIZE + RWS_OVEC_RSIZE) |
| { |
| rc = more_workspace(&rws, RWS_OVEC_RSIZE, mb); |
| if (rc != 0) return rc; |
| RWS = (int *)rws; |
| } |
|
|
| local_offsets = (PCRE2_SIZE *)(RWS + rws->size - rws->free); |
| local_workspace = ((int *)local_offsets) + RWS_OVEC_RSIZE; |
| rws->free -= RWS_RSIZE + RWS_OVEC_RSIZE; |
|
|
| |
| |
| |
|
|
| for (dfa_recursion_info *ri = mb->recursive; |
| ri != NULL; |
| ri = ri->prevrec) |
| { |
| if (recno == ri->group_num && ptr == ri->subject_position && |
| mb->last_used_ptr == ri->last_used_ptr) |
| return PCRE2_ERROR_RECURSELOOP; |
| } |
|
|
| |
| |
|
|
| new_recursive.group_num = recno; |
| new_recursive.subject_position = ptr; |
| new_recursive.last_used_ptr = mb->last_used_ptr; |
| new_recursive.prevrec = mb->recursive; |
| mb->recursive = &new_recursive; |
|
|
| rc = internal_dfa_match( |
| mb, |
| callpat, |
| ptr, |
| (PCRE2_SIZE)(ptr - start_subject), |
| local_offsets, |
| RWS_OVEC_RSIZE/OVEC_UNIT, |
| local_workspace, |
| RWS_RSIZE, |
| rlevel, |
| RWS); |
|
|
| rws->free += RWS_RSIZE + RWS_OVEC_RSIZE; |
| mb->recursive = new_recursive.prevrec; |
|
|
| |
|
|
| if (rc == 0) return PCRE2_ERROR_DFA_RECURSE; |
|
|
| |
| |
| |
|
|
| if (rc > 0) |
| { |
| for (rc = rc*2 - 2; rc >= 0; rc -= 2) |
| { |
| PCRE2_SIZE charcount = local_offsets[rc+1] - local_offsets[rc]; |
| #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 |
| if (utf) |
| { |
| PCRE2_SPTR p = start_subject + local_offsets[rc]; |
| PCRE2_SPTR pp = start_subject + local_offsets[rc+1]; |
| while (p < pp) if (NOT_FIRSTCU(*p++)) charcount--; |
| } |
| #endif |
| if (charcount > 0) |
| { |
| ADD_NEW_DATA(-(state_offset + LINK_SIZE + 1), 0, |
| (int)(charcount - 1)); |
| } |
| else |
| { |
| ADD_ACTIVE(state_offset + LINK_SIZE + 1, 0); |
| } |
| } |
| } |
| else if (rc != PCRE2_ERROR_NOMATCH) return rc; |
| } |
| break; |
|
|
| |
| case OP_BRAPOS: |
| case OP_SBRAPOS: |
| case OP_CBRAPOS: |
| case OP_SCBRAPOS: |
| case OP_BRAPOSZERO: |
| { |
| int rc; |
| int *local_workspace; |
| PCRE2_SIZE *local_offsets; |
| PCRE2_SIZE charcount, matched_count; |
| PCRE2_SPTR local_ptr = ptr; |
| RWS_anchor *rws = (RWS_anchor *)RWS; |
| BOOL allow_zero; |
|
|
| if (rws->free < RWS_RSIZE + RWS_OVEC_OSIZE) |
| { |
| rc = more_workspace(&rws, RWS_OVEC_OSIZE, mb); |
| if (rc != 0) return rc; |
| RWS = (int *)rws; |
| } |
|
|
| local_offsets = (PCRE2_SIZE *)(RWS + rws->size - rws->free); |
| local_workspace = ((int *)local_offsets) + RWS_OVEC_OSIZE; |
| rws->free -= RWS_RSIZE + RWS_OVEC_OSIZE; |
|
|
| if (codevalue == OP_BRAPOSZERO) |
| { |
| allow_zero = TRUE; |
| ++code; |
| } |
| else allow_zero = FALSE; |
|
|
| |
| |
|
|
| for (matched_count = 0;; matched_count++) |
| { |
| rc = internal_dfa_match( |
| mb, |
| code, |
| local_ptr, |
| (PCRE2_SIZE)(ptr - start_subject), |
| local_offsets, |
| RWS_OVEC_OSIZE/OVEC_UNIT, |
| local_workspace, |
| RWS_RSIZE, |
| rlevel, |
| RWS); |
|
|
| |
|
|
| if (rc < 0) |
| { |
| if (rc != PCRE2_ERROR_NOMATCH) return rc; |
| break; |
| } |
|
|
| |
|
|
| charcount = local_offsets[1] - local_offsets[0]; |
| if (charcount == 0) break; |
| local_ptr += charcount; |
| } |
|
|
| rws->free += RWS_RSIZE + RWS_OVEC_OSIZE; |
|
|
| |
| |
| |
|
|
| if (matched_count > 0 || allow_zero) |
| { |
| PCRE2_SPTR end_subpattern = code; |
| int next_state_offset; |
|
|
| do { end_subpattern += GET(end_subpattern, 1); } |
| while (*end_subpattern == OP_ALT); |
| next_state_offset = |
| (int)(end_subpattern - start_code + LINK_SIZE + 1); |
|
|
| |
| |
| |
| |
|
|
| if (i + 1 >= active_count && new_count == 0) |
| { |
| ptr = local_ptr; |
| clen = 0; |
| ADD_NEW(next_state_offset, 0); |
| } |
| else |
| { |
| PCRE2_SPTR p = ptr; |
| PCRE2_SPTR pp = local_ptr; |
| charcount = (PCRE2_SIZE)(pp - p); |
| #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 |
| if (utf) while (p < pp) if (NOT_FIRSTCU(*p++)) charcount--; |
| #endif |
| ADD_NEW_DATA(-next_state_offset, 0, (int)(charcount - 1)); |
| } |
| } |
| } |
| break; |
|
|
| |
| case OP_ONCE: |
| { |
| int rc; |
| int *local_workspace; |
| PCRE2_SIZE *local_offsets; |
| RWS_anchor *rws = (RWS_anchor *)RWS; |
|
|
| if (rws->free < RWS_RSIZE + RWS_OVEC_OSIZE) |
| { |
| rc = more_workspace(&rws, RWS_OVEC_OSIZE, mb); |
| if (rc != 0) return rc; |
| RWS = (int *)rws; |
| } |
|
|
| local_offsets = (PCRE2_SIZE *)(RWS + rws->size - rws->free); |
| local_workspace = ((int *)local_offsets) + RWS_OVEC_OSIZE; |
| rws->free -= RWS_RSIZE + RWS_OVEC_OSIZE; |
|
|
| rc = internal_dfa_match( |
| mb, |
| code, |
| ptr, |
| (PCRE2_SIZE)(ptr - start_subject), |
| local_offsets, |
| RWS_OVEC_OSIZE/OVEC_UNIT, |
| local_workspace, |
| RWS_RSIZE, |
| rlevel, |
| RWS); |
|
|
| rws->free += RWS_RSIZE + RWS_OVEC_OSIZE; |
|
|
| if (rc >= 0) |
| { |
| PCRE2_SPTR end_subpattern = code; |
| PCRE2_SIZE charcount = local_offsets[1] - local_offsets[0]; |
| int next_state_offset, repeat_state_offset; |
|
|
| do { end_subpattern += GET(end_subpattern, 1); } |
| while (*end_subpattern == OP_ALT); |
| next_state_offset = |
| (int)(end_subpattern - start_code + LINK_SIZE + 1); |
|
|
| |
| |
| |
|
|
| repeat_state_offset = (*end_subpattern == OP_KETRMAX || |
| *end_subpattern == OP_KETRMIN)? |
| (int)(end_subpattern - start_code - GET(end_subpattern, 1)) : -1; |
|
|
| |
| |
| |
| |
|
|
| if (charcount == 0) |
| { |
| ADD_ACTIVE(next_state_offset, 0); |
| } |
|
|
| |
| |
| |
| |
|
|
| else if (i + 1 >= active_count && new_count == 0) |
| { |
| ptr += charcount; |
| clen = 0; |
| ADD_NEW(next_state_offset, 0); |
|
|
| |
| |
| |
| |
|
|
| if (repeat_state_offset >= 0) |
| { |
| next_active_state = active_states; |
| active_count = 0; |
| i = -1; |
| ADD_ACTIVE(repeat_state_offset, 0); |
| } |
| } |
| else |
| { |
| #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 |
| if (utf) |
| { |
| PCRE2_SPTR p = start_subject + local_offsets[0]; |
| PCRE2_SPTR pp = start_subject + local_offsets[1]; |
| while (p < pp) if (NOT_FIRSTCU(*p++)) charcount--; |
| } |
| #endif |
| ADD_NEW_DATA(-next_state_offset, 0, (int)(charcount - 1)); |
| if (repeat_state_offset >= 0) |
| { ADD_NEW_DATA(-repeat_state_offset, 0, (int)(charcount - 1)); } |
| } |
| } |
| else if (rc != PCRE2_ERROR_NOMATCH) return rc; |
| } |
| break; |
|
|
|
|
| |
| |
|
|
| case OP_CALLOUT: |
| case OP_CALLOUT_STR: |
| { |
| PCRE2_SIZE callout_length; |
| rrc = do_callout_dfa(code, offsets, current_subject, ptr, mb, 0, |
| &callout_length); |
| if (rrc < 0) return rrc; |
| if (rrc == 0) |
| { ADD_ACTIVE(state_offset + (int)callout_length, 0); } |
| } |
| break; |
|
|
|
|
| |
| default: |
| return PCRE2_ERROR_DFA_UITEM; |
| } |
|
|
| NEXT_ACTIVE_STATE: continue; |
|
|
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| if (new_count <= 0) |
| { |
| if (could_continue && |
| ( |
| (mb->moptions & PCRE2_PARTIAL_HARD) != 0 |
| || |
| ((mb->moptions & PCRE2_PARTIAL_SOFT) != 0 && |
| match_count < 0) |
| ) && |
| ( |
| partial_newline || |
| ( |
| ptr >= end_subject && |
| ( |
| ptr > mb->start_used_ptr || |
| mb->allowemptypartial |
| ) |
| ) |
| )) |
| match_count = PCRE2_ERROR_PARTIAL; |
| break; |
| } |
|
|
| |
|
|
| ptr += clen; |
| } |
|
|
| |
| |
|
|
| if (match_count >= 0 && |
| ((mb->moptions | mb->poptions) & PCRE2_ENDANCHORED) != 0 && |
| ptr < end_subject) |
| match_count = PCRE2_ERROR_NOMATCH; |
|
|
| return match_count; |
| } |
|
|
|
|
|
|
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION |
| pcre2_dfa_match(const pcre2_code *code, PCRE2_SPTR subject, PCRE2_SIZE length, |
| PCRE2_SIZE start_offset, uint32_t options, pcre2_match_data *match_data, |
| pcre2_match_context *mcontext, int *workspace, PCRE2_SIZE wscount) |
| { |
| int rc; |
|
|
| const pcre2_real_code *re = (const pcre2_real_code *)code; |
| uint32_t original_options = options; |
|
|
| PCRE2_UCHAR null_str[1] = { 0xcd }; |
| PCRE2_SPTR original_subject = subject; |
| PCRE2_SPTR start_match; |
| PCRE2_SPTR end_subject; |
| PCRE2_SPTR bumpalong_limit; |
| PCRE2_SPTR req_cu_ptr; |
|
|
| BOOL utf, anchored, startline, firstline; |
| BOOL has_first_cu = FALSE; |
| BOOL has_req_cu = FALSE; |
|
|
| #if PCRE2_CODE_UNIT_WIDTH == 8 |
| PCRE2_SPTR memchr_found_first_cu = NULL; |
| PCRE2_SPTR memchr_found_first_cu2 = NULL; |
| #endif |
|
|
| PCRE2_UCHAR first_cu = 0; |
| PCRE2_UCHAR first_cu2 = 0; |
| PCRE2_UCHAR req_cu = 0; |
| PCRE2_UCHAR req_cu2 = 0; |
|
|
| const uint8_t *start_bits = NULL; |
|
|
| |
| |
|
|
| pcre2_callout_block cb; |
| dfa_match_block actual_match_block; |
| dfa_match_block *mb = &actual_match_block; |
|
|
| |
| |
| |
| |
|
|
| int base_recursion_workspace[RWS_BASE_SIZE]; |
| RWS_anchor *rws = (RWS_anchor *)base_recursion_workspace; |
| rws->next = NULL; |
| rws->size = RWS_BASE_SIZE; |
| rws->free = RWS_BASE_SIZE - RWS_ANCHOR_SIZE; |
|
|
| |
|
|
| if (subject == NULL && length == 0) subject = null_str; |
|
|
| |
|
|
| if (match_data == NULL) return PCRE2_ERROR_NULL; |
| if (re == NULL || subject == NULL || workspace == NULL) |
| { rc = PCRE2_ERROR_NULL; goto EXIT; } |
| if ((options & ~PUBLIC_DFA_MATCH_OPTIONS) != 0) |
| { rc = PCRE2_ERROR_BADOPTION; goto EXIT; } |
|
|
| if (length == PCRE2_ZERO_TERMINATED) |
| { |
| length = PRIV(strlen)(subject); |
| } |
|
|
| if (wscount < 20) { rc = PCRE2_ERROR_DFA_WSSIZE; goto EXIT; } |
| if (start_offset > length) { rc = PCRE2_ERROR_BADOFFSET; goto EXIT; } |
|
|
| |
| |
|
|
| if ((options & (PCRE2_PARTIAL_HARD|PCRE2_PARTIAL_SOFT)) != 0 && |
| ((re->overall_options | options) & PCRE2_ENDANCHORED) != 0) |
| { rc = PCRE2_ERROR_BADOPTION; goto EXIT; } |
|
|
| |
|
|
| if ((re->overall_options & PCRE2_MATCH_INVALID_UTF) != 0) |
| { rc = PCRE2_ERROR_DFA_UINVALID_UTF; goto EXIT; } |
|
|
| |
| |
|
|
| if (re->magic_number != MAGIC_NUMBER) |
| { rc = PCRE2_ERROR_BADMAGIC; goto EXIT; } |
|
|
| |
|
|
| if ((re->flags & PCRE2_MODE_MASK) != PCRE2_CODE_UNIT_WIDTH/8) |
| { rc = PCRE2_ERROR_BADMODE; goto EXIT; } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #define FF (PCRE2_NOTEMPTY_SET|PCRE2_NE_ATST_SET) |
| #define OO (PCRE2_NOTEMPTY|PCRE2_NOTEMPTY_ATSTART) |
| options |= (re->flags & FF) / ((FF & (~FF+1)) / (OO & (~OO+1))); |
| #undef FF |
| #undef OO |
|
|
| |
| |
|
|
| if ((options & PCRE2_DFA_RESTART) != 0) |
| { |
| if ((workspace[0] & (-2)) != 0 || workspace[1] < 1 || |
| workspace[1] > (int)((wscount - 2)/INTS_PER_STATEBLOCK)) |
| { rc = PCRE2_ERROR_DFA_BADRESTART; goto EXIT; } |
| } |
|
|
| |
|
|
| utf = (re->overall_options & PCRE2_UTF) != 0; |
| start_match = subject + start_offset; |
| end_subject = subject + length; |
| req_cu_ptr = start_match - 1; |
| anchored = (options & (PCRE2_ANCHORED|PCRE2_DFA_RESTART)) != 0 || |
| (re->overall_options & PCRE2_ANCHORED) != 0; |
|
|
| |
| |
|
|
| startline = (re->flags & PCRE2_STARTLINE) != 0; |
| firstline = !anchored && (re->overall_options & PCRE2_FIRSTLINE) != 0; |
| bumpalong_limit = end_subject; |
|
|
| |
| |
|
|
| mb->cb = &cb; |
| cb.version = 2; |
| cb.subject = subject; |
| cb.subject_length = (PCRE2_SIZE)(end_subject - subject); |
| cb.callout_flags = 0; |
| cb.capture_top = 1; |
| cb.capture_last = 0; |
| cb.mark = NULL; |
|
|
| |
| |
| |
|
|
| if (mcontext == NULL) |
| { |
| mb->callout = NULL; |
| mb->memctl = re->memctl; |
| mb->match_limit = PRIV(default_match_context).match_limit; |
| mb->match_limit_depth = PRIV(default_match_context).depth_limit; |
| mb->heap_limit = PRIV(default_match_context).heap_limit; |
| } |
| else |
| { |
| if (mcontext->offset_limit != PCRE2_UNSET) |
| { |
| if ((re->overall_options & PCRE2_USE_OFFSET_LIMIT) == 0) |
| { rc = PCRE2_ERROR_BADOFFSETLIMIT; goto EXIT; } |
| bumpalong_limit = subject + mcontext->offset_limit; |
| } |
| mb->callout = mcontext->callout; |
| mb->callout_data = mcontext->callout_data; |
| mb->memctl = mcontext->memctl; |
| mb->match_limit = mcontext->match_limit; |
| mb->match_limit_depth = mcontext->depth_limit; |
| mb->heap_limit = mcontext->heap_limit; |
| } |
|
|
| if (mb->match_limit > re->limit_match) |
| mb->match_limit = re->limit_match; |
|
|
| if (mb->match_limit_depth > re->limit_depth) |
| mb->match_limit_depth = re->limit_depth; |
|
|
| if (mb->heap_limit > re->limit_heap) |
| mb->heap_limit = re->limit_heap; |
|
|
| mb->start_code = (PCRE2_SPTR)((const uint8_t *)re + re->code_start); |
| mb->tables = re->tables; |
| mb->start_subject = subject; |
| mb->end_subject = end_subject; |
| mb->start_offset = start_offset; |
| mb->allowemptypartial = (re->max_lookbehind > 0) || |
| (re->flags & PCRE2_MATCH_EMPTY) != 0; |
| mb->moptions = options; |
| mb->poptions = re->overall_options; |
| mb->match_call_count = 0; |
| mb->heap_used = 0; |
|
|
| |
|
|
| mb->bsr_convention = re->bsr_convention; |
| mb->nltype = NLTYPE_FIXED; |
| switch(re->newline_convention) |
| { |
| case PCRE2_NEWLINE_CR: |
| mb->nllen = 1; |
| mb->nl[0] = CHAR_CR; |
| break; |
|
|
| case PCRE2_NEWLINE_LF: |
| mb->nllen = 1; |
| mb->nl[0] = CHAR_NL; |
| break; |
|
|
| case PCRE2_NEWLINE_NUL: |
| mb->nllen = 1; |
| mb->nl[0] = CHAR_NUL; |
| break; |
|
|
| case PCRE2_NEWLINE_CRLF: |
| mb->nllen = 2; |
| mb->nl[0] = CHAR_CR; |
| mb->nl[1] = CHAR_NL; |
| break; |
|
|
| case PCRE2_NEWLINE_ANY: |
| mb->nltype = NLTYPE_ANY; |
| break; |
|
|
| case PCRE2_NEWLINE_ANYCRLF: |
| mb->nltype = NLTYPE_ANYCRLF; |
| break; |
|
|
| |
| default: |
| PCRE2_DEBUG_UNREACHABLE(); |
| rc = PCRE2_ERROR_INTERNAL; |
| goto EXIT; |
| |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| #ifdef SUPPORT_UNICODE |
| if (utf && (options & PCRE2_NO_UTF_CHECK) == 0) |
| { |
| PCRE2_SPTR check_subject = start_match; |
|
|
| if (start_offset > 0) |
| { |
| #if PCRE2_CODE_UNIT_WIDTH != 32 |
| unsigned int i; |
| if (start_match < end_subject && NOT_FIRSTCU(*start_match)) |
| { rc = PCRE2_ERROR_BADUTFOFFSET; goto EXIT; } |
| for (i = re->max_lookbehind; i > 0 && check_subject > subject; i--) |
| { |
| check_subject--; |
| while (check_subject > subject && |
| #if PCRE2_CODE_UNIT_WIDTH == 8 |
| (*check_subject & 0xc0) == 0x80) |
| #else |
| (*check_subject & 0xfc00) == 0xdc00) |
| #endif |
| check_subject--; |
| } |
| #else |
| check_subject -= re->max_lookbehind; |
| if (check_subject < subject) check_subject = subject; |
| #endif |
| } |
|
|
| |
| |
|
|
| rc = PRIV(valid_utf)(check_subject, |
| length - (PCRE2_SIZE)(check_subject - subject), &(match_data->startchar)); |
| if (rc != 0) |
| { |
| match_data->startchar += (PCRE2_SIZE)(check_subject - subject); |
| goto EXIT; |
| } |
| } |
| #endif |
|
|
| |
| |
|
|
| if ((re->flags & PCRE2_FIRSTSET) != 0) |
| { |
| has_first_cu = TRUE; |
| first_cu = first_cu2 = (PCRE2_UCHAR)(re->first_codeunit); |
| if ((re->flags & PCRE2_FIRSTCASELESS) != 0) |
| { |
| first_cu2 = TABLE_GET(first_cu, mb->tables + fcc_offset, first_cu); |
| #ifdef SUPPORT_UNICODE |
| #if PCRE2_CODE_UNIT_WIDTH == 8 |
| if (first_cu > 127 && !utf && (re->overall_options & PCRE2_UCP) != 0) |
| first_cu2 = (PCRE2_UCHAR)UCD_OTHERCASE(first_cu); |
| #else |
| if (first_cu > 127 && (utf || (re->overall_options & PCRE2_UCP) != 0)) |
| first_cu2 = (PCRE2_UCHAR)UCD_OTHERCASE(first_cu); |
| #endif |
| #endif |
| } |
| } |
| else |
| if (!startline && (re->flags & PCRE2_FIRSTMAPSET) != 0) |
| start_bits = re->start_bitmap; |
|
|
| |
|
|
| if ((re->flags & PCRE2_LASTSET) != 0) |
| { |
| has_req_cu = TRUE; |
| req_cu = req_cu2 = (PCRE2_UCHAR)(re->last_codeunit); |
| if ((re->flags & PCRE2_LASTCASELESS) != 0) |
| { |
| req_cu2 = TABLE_GET(req_cu, mb->tables + fcc_offset, req_cu); |
| #ifdef SUPPORT_UNICODE |
| #if PCRE2_CODE_UNIT_WIDTH == 8 |
| if (req_cu > 127 && !utf && (re->overall_options & PCRE2_UCP) != 0) |
| req_cu2 = (PCRE2_UCHAR)UCD_OTHERCASE(req_cu); |
| #else |
| if (req_cu > 127 && (utf || (re->overall_options & PCRE2_UCP) != 0)) |
| req_cu2 = (PCRE2_UCHAR)UCD_OTHERCASE(req_cu); |
| #endif |
| #endif |
| } |
| } |
|
|
| |
| |
|
|
| if ((match_data->flags & PCRE2_MD_COPIED_SUBJECT) != 0) |
| { |
| match_data->memctl.free((void *)match_data->subject, |
| match_data->memctl.memory_data); |
| match_data->flags &= ~PCRE2_MD_COPIED_SUBJECT; |
| } |
|
|
| |
|
|
| match_data->code = re; |
| match_data->subject = NULL; |
| match_data->mark = NULL; |
| match_data->matchedby = PCRE2_MATCHEDBY_DFA_INTERPRETER; |
| match_data->options = original_options; |
|
|
| |
| |
| |
|
|
| for (;;) |
| { |
| |
|
|
| |
| |
| |
| |
| |
|
|
| if ((re->optimization_flags & PCRE2_OPTIM_START_OPTIMIZE) != 0 && |
| (options & PCRE2_DFA_RESTART) == 0) |
| { |
| |
| |
| |
| |
| |
| |
| |
|
|
| if (firstline) |
| { |
| PCRE2_SPTR t = start_match; |
| #ifdef SUPPORT_UNICODE |
| if (utf) |
| { |
| while (t < end_subject && !IS_NEWLINE(t)) |
| { |
| t++; |
| ACROSSCHAR(t < end_subject, t, t++); |
| } |
| } |
| else |
| #endif |
| while (t < end_subject && !IS_NEWLINE(t)) t++; |
| end_subject = t; |
| } |
|
|
| |
| |
| |
|
|
| if (anchored) |
| { |
| if (has_first_cu || start_bits != NULL) |
| { |
| BOOL ok = start_match < end_subject; |
| if (ok) |
| { |
| PCRE2_UCHAR c = UCHAR21TEST(start_match); |
| ok = has_first_cu && (c == first_cu || c == first_cu2); |
| if (!ok && start_bits != NULL) |
| { |
| #if PCRE2_CODE_UNIT_WIDTH != 8 |
| if (c > 255) c = 255; |
| #endif |
| ok = (start_bits[c/8] & (1u << (c&7))) != 0; |
| } |
| } |
| if (!ok) break; |
| } |
| } |
|
|
| |
|
|
| else |
| { |
| if (has_first_cu) |
| { |
| if (first_cu != first_cu2) |
| { |
| |
| |
|
|
| #if PCRE2_CODE_UNIT_WIDTH != 8 |
| PCRE2_UCHAR smc; |
| while (start_match < end_subject && |
| (smc = UCHAR21TEST(start_match)) != first_cu && |
| smc != first_cu2) |
| start_match++; |
| #else |
| |
| |
| |
| |
| |
| |
|
|
| PCRE2_SPTR pp1 = NULL; |
| PCRE2_SPTR pp2 = NULL; |
| PCRE2_SIZE searchlength = end_subject - start_match; |
|
|
| |
| |
| |
|
|
| if (memchr_found_first_cu == NULL || |
| start_match > memchr_found_first_cu) |
| { |
| pp1 = memchr(start_match, first_cu, searchlength); |
| memchr_found_first_cu = (pp1 == NULL)? end_subject : pp1; |
| } |
|
|
| |
| |
|
|
| else pp1 = (memchr_found_first_cu == end_subject)? NULL : |
| memchr_found_first_cu; |
|
|
| |
|
|
| if (memchr_found_first_cu2 == NULL || |
| start_match > memchr_found_first_cu2) |
| { |
| pp2 = memchr(start_match, first_cu2, searchlength); |
| memchr_found_first_cu2 = (pp2 == NULL)? end_subject : pp2; |
| } |
|
|
| else pp2 = (memchr_found_first_cu2 == end_subject)? NULL : |
| memchr_found_first_cu2; |
|
|
| |
| |
|
|
| if (pp1 == NULL) |
| start_match = (pp2 == NULL)? end_subject : pp2; |
| else |
| start_match = (pp2 == NULL || pp1 < pp2)? pp1 : pp2; |
|
|
| #endif |
| } |
|
|
| |
|
|
| else |
| { |
| #if PCRE2_CODE_UNIT_WIDTH != 8 |
| while (start_match < end_subject && UCHAR21TEST(start_match) != |
| first_cu) |
| start_match++; |
| #else |
| start_match = memchr(start_match, first_cu, end_subject - start_match); |
| if (start_match == NULL) start_match = end_subject; |
| #endif |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| if ((mb->moptions & (PCRE2_PARTIAL_HARD|PCRE2_PARTIAL_SOFT)) == 0 && |
| start_match >= mb->end_subject) |
| break; |
| } |
|
|
| |
| |
|
|
| else if (startline) |
| { |
| if (start_match > mb->start_subject + start_offset) |
| { |
| #ifdef SUPPORT_UNICODE |
| if (utf) |
| { |
| while (start_match < end_subject && !WAS_NEWLINE(start_match)) |
| { |
| start_match++; |
| ACROSSCHAR(start_match < end_subject, start_match, start_match++); |
| } |
| } |
| else |
| #endif |
| while (start_match < end_subject && !WAS_NEWLINE(start_match)) |
| start_match++; |
|
|
| |
| |
| |
|
|
| if (start_match[-1] == CHAR_CR && |
| (mb->nltype == NLTYPE_ANY || mb->nltype == NLTYPE_ANYCRLF) && |
| start_match < end_subject && |
| UCHAR21TEST(start_match) == CHAR_NL) |
| start_match++; |
| } |
| } |
|
|
| |
| |
| |
| |
|
|
| else if (start_bits != NULL) |
| { |
| while (start_match < end_subject) |
| { |
| uint32_t c = UCHAR21TEST(start_match); |
| #if PCRE2_CODE_UNIT_WIDTH != 8 |
| if (c > 255) c = 255; |
| #endif |
| if ((start_bits[c/8] & (1u << (c&7))) != 0) break; |
| start_match++; |
| } |
|
|
| |
|
|
| if ((mb->moptions & (PCRE2_PARTIAL_HARD|PCRE2_PARTIAL_SOFT)) == 0 && |
| start_match >= mb->end_subject) |
| break; |
| } |
| } |
|
|
| |
|
|
| end_subject = mb->end_subject; |
|
|
| |
|
|
| if ((mb->moptions & (PCRE2_PARTIAL_HARD|PCRE2_PARTIAL_SOFT)) == 0) |
| { |
| PCRE2_SPTR p; |
|
|
| |
| |
| |
| |
|
|
| if (end_subject - start_match < re->minlength) goto NOMATCH_EXIT; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| p = start_match + (has_first_cu? 1:0); |
| if (has_req_cu && p > req_cu_ptr) |
| { |
| PCRE2_SIZE check_length = end_subject - start_match; |
|
|
| if (check_length < REQ_CU_MAX || |
| (!anchored && check_length < REQ_CU_MAX * 1000)) |
| { |
| if (req_cu != req_cu2) |
| { |
| #if PCRE2_CODE_UNIT_WIDTH != 8 |
| while (p < end_subject) |
| { |
| uint32_t pp = UCHAR21INCTEST(p); |
| if (pp == req_cu || pp == req_cu2) { p--; break; } |
| } |
| #else |
| PCRE2_SPTR pp = p; |
| p = memchr(pp, req_cu, end_subject - pp); |
| if (p == NULL) |
| { |
| p = memchr(pp, req_cu2, end_subject - pp); |
| if (p == NULL) p = end_subject; |
| } |
| #endif |
| } |
|
|
| |
|
|
| else |
| { |
| #if PCRE2_CODE_UNIT_WIDTH != 8 |
| while (p < end_subject) |
| { |
| if (UCHAR21INCTEST(p) == req_cu) { p--; break; } |
| } |
|
|
| #else |
| p = memchr(p, req_cu, end_subject - p); |
| if (p == NULL) p = end_subject; |
| #endif |
| } |
|
|
| |
| |
|
|
| if (p >= end_subject) break; |
|
|
| |
| |
| |
|
|
| req_cu_ptr = p; |
| } |
| } |
| } |
| } |
|
|
| |
|
|
| |
|
|
| if (start_match > bumpalong_limit) break; |
|
|
| |
|
|
| mb->start_used_ptr = start_match; |
| mb->last_used_ptr = start_match; |
| mb->recursive = NULL; |
|
|
| rc = internal_dfa_match( |
| mb, |
| mb->start_code, |
| start_match, |
| start_offset, |
| match_data->ovector, |
| (uint32_t)match_data->oveccount * 2, |
| workspace, |
| (int)wscount, |
| 0, |
| base_recursion_workspace); |
|
|
| |
| |
|
|
| if (rc != PCRE2_ERROR_NOMATCH || anchored) |
| { |
| if (rc == PCRE2_ERROR_NOMATCH) goto NOMATCH_EXIT; |
|
|
| if (rc == PCRE2_ERROR_PARTIAL && match_data->oveccount > 0) |
| { |
| match_data->ovector[0] = (PCRE2_SIZE)(start_match - subject); |
| match_data->ovector[1] = (PCRE2_SIZE)(end_subject - subject); |
| } |
|
|
| if (rc >= 0 || rc == PCRE2_ERROR_PARTIAL) |
| { |
| match_data->subject_length = length; |
| match_data->start_offset = start_offset; |
| match_data->leftchar = (PCRE2_SIZE)(mb->start_used_ptr - subject); |
| match_data->rightchar = (PCRE2_SIZE)(mb->last_used_ptr - subject); |
| match_data->startchar = (PCRE2_SIZE)(start_match - subject); |
| } |
|
|
| if (rc >= 0 && (options & PCRE2_COPY_MATCHED_SUBJECT) != 0) |
| { |
| if (length != 0) |
| { |
| match_data->subject = match_data->memctl.malloc(CU2BYTES(length), |
| match_data->memctl.memory_data); |
| if (match_data->subject == NULL) |
| { rc = PCRE2_ERROR_NOMEMORY; goto EXIT; } |
| memcpy((void *)match_data->subject, subject, CU2BYTES(length)); |
| } |
| else |
| match_data->subject = NULL; |
| match_data->flags |= PCRE2_MD_COPIED_SUBJECT; |
| } |
| else if (rc >= 0 || rc == PCRE2_ERROR_PARTIAL) |
| { |
| match_data->subject = original_subject; |
| } |
| goto EXIT; |
| } |
|
|
| |
| |
|
|
| if (firstline && IS_NEWLINE(start_match)) break; |
| start_match++; |
| #ifdef SUPPORT_UNICODE |
| if (utf) |
| { |
| ACROSSCHAR(start_match < end_subject, start_match, start_match++); |
| } |
| #endif |
| if (start_match > end_subject) break; |
|
|
| |
| |
| |
|
|
| if (UCHAR21TEST(start_match - 1) == CHAR_CR && |
| start_match < end_subject && |
| UCHAR21TEST(start_match) == CHAR_NL && |
| (re->flags & PCRE2_HASCRORLF) == 0 && |
| (mb->nltype == NLTYPE_ANY || |
| mb->nltype == NLTYPE_ANYCRLF || |
| mb->nllen == 2)) |
| start_match++; |
|
|
| } |
|
|
| NOMATCH_EXIT: |
| match_data->subject = original_subject; |
| match_data->subject_length = length; |
| match_data->start_offset = start_offset; |
| rc = PCRE2_ERROR_NOMATCH; |
|
|
| EXIT: |
| while (rws->next != NULL) |
| { |
| RWS_anchor *next = rws->next; |
| rws->next = next->next; |
| mb->memctl.free(next, mb->memctl.memory_data); |
| } |
|
|
| match_data->rc = rc; |
| return rc; |
| } |
|
|
| |
|
|
| #undef NLBLOCK |
| #undef PSSTART |
| #undef PSEND |
|
|
| |
|
|