Branch Coverage

regex_internal.c
Criterion Covered Total %
branch 295 654 45.1


line true false branch
46 3 11 if (init_len < dfa->mb_cur_max)
52 0 14 if (BE (ret != REG_NOERROR, 0))
57 1 13 pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
58 13 1 pstr->valid_len = (pstr->mbs_allocated || dfa->mb_cur_max > 1) ? 0 : len;
0 13 pstr->valid_len = (pstr->mbs_allocated || dfa->mb_cur_max > 1) ? 0 : len;
74 6 0 if (len > 0)
77 0 6 if (BE (ret != REG_NOERROR, 0))
80 1 5 pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
82 1 5 if (icase)
85 1 0 if (dfa->mb_cur_max > 1)
90 0 1 if (BE (ret != REG_NOERROR, 0))
92 1 0 if (pstr->valid_raw_len >= len)
94 0 0 if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max)
97 0 0 if (BE (ret != REG_NOERROR, 0))
108 5 0 if (dfa->mb_cur_max > 1)
113 0 0 if (trans != NULL)
133 20 0 if (pstr->mb_cur_max > 1)
137 0 20 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_buf_len, 0))
140 0 20 re_realloc (pstr->wcs, rpl__wint_t, new_buf_len);
141 0 20 if (pstr->offsets != NULL)
143 0 0 re_realloc (pstr->offsets, Idx, new_buf_len);
147 2 18 if (pstr->mbs_allocated)
167 20 0 pstr->mbs_allocated = (trans != NULL || icase);
2 18 pstr->mbs_allocated = (trans != NULL || icase);
205 112 40 for (byte_idx = pstr->valid_len; byte_idx < end_idx;)
213 0 112 if (BE (pstr->trans != NULL, 0))
217 0 0 for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
0 0 for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
227 112 0 if (BE (mbclen == (size_t) -1 || mbclen == 0
0 112 if (BE (mbclen == (size_t) -1 || mbclen == 0
112 0 if (BE (mbclen == (size_t) -1 || mbclen == 0
0 112 if (BE (mbclen == (size_t) -1 || mbclen == 0
0 0 if (BE (mbclen == (size_t) -1 || mbclen == 0
0 112 if (BE (mbclen == (size_t) -1 || mbclen == 0
233 0 0 if (BE (pstr->trans != NULL, 0))
237 0 112 else if (BE (mbclen == (size_t) -2, 0))
247 88 112 for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
276 17 0 if (! pstr->map_notascii && pstr->trans == NULL && !pstr->offsets_needed)
17 0 if (! pstr->map_notascii && pstr->trans == NULL && !pstr->offsets_needed)
8 9 if (! pstr->map_notascii && pstr->trans == NULL && !pstr->offsets_needed)
278 24 6 while (byte_idx < end_idx)
282 18 6 if (rpl__isascii (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx])
283 18 0 && rpl__mbsinit (&pstr->cur_state))
300 2 4 if (BE (mbclen < (size_t) -2, 1))
303 2 0 if (rpl__iswlower (wc))
309 0 2 if (BE (mbclen == mbcdlen, 1))
321 0 0 for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
324 0 4 else if (mbclen == (size_t) -1 || mbclen == 0
0 0 else if (mbclen == (size_t) -1 || mbclen == 0
325 0 0 || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len))
0 0 || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len))
333 4 0 if (BE (mbclen == (size_t) -1, 0))
348 10 11 for (src_idx = pstr->valid_raw_len; byte_idx < end_idx;)
355 0 12 if (BE (pstr->trans != NULL, 0))
359 0 0 for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
0 0 for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i)
369 10 2 if (BE (mbclen < (size_t) -2, 1))
372 3 7 if (rpl__iswlower (wc))
378 0 3 if (BE (mbclen == mbcdlen, 1))
380 3 0 else if (mbcdlen != (size_t) -1)
384 0 3 if (byte_idx + mbcdlen > pstr->bufs_len)
390 1 2 if (pstr->offsets == NULL)
392 0 1 re_malloc (pstr->offsets, Idx, pstr->bufs_len);
394 2 1 if (!pstr->offsets_needed)
396 9 2 for (i = 0; i < (size_t) byte_idx; ++i)
404 0 3 for (i = 1; i < mbcdlen; ++i)
407 0 0 = src_idx + (i < mbclen ? i : mbclen - 1);
411 3 0 if (pstr->raw_stop > src_idx)
425 7 0 if (BE (pstr->offsets_needed != 0, 0))
428 7 7 for (i = 0; i < mbclen; ++i)
435 0 7 for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
438 0 2 else if (mbclen == (size_t) -1 || mbclen == 0
0 0 else if (mbclen == (size_t) -1 || mbclen == 0
439 0 0 || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len))
0 0 || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len))
444 0 2 if (BE (pstr->trans != NULL, 0))
448 2 0 if (BE (pstr->offsets_needed != 0, 0))
454 2 0 if (BE (mbclen == (size_t) -1, 0))
482 36 10 for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len;
490 36 0 if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
0 36 if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
36 0 if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
0 36 if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
493 0 0 if (mbclen == 0 || remain_len == 0)
0 0 if (mbclen == 0 || remain_len == 0)
520 0 0 for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx)
523 0 0 if (BE (pstr->trans != NULL, 0))
525 0 0 if (rpl__islower (ch))
543 0 0 for (buf_idx = pstr->valid_len; buf_idx < end_idx; ++buf_idx)
563 51 0 if (BE (pstr->raw_mbs_idx <= idx, 0))
569 0 0 if (pstr->mb_cur_max > 1)
578 0 0 pstr->tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
580 0 0 if (!pstr->mbs_allocated)
585 45 6 if (BE (offset != 0, 1))
588 35 10 if (BE (offset < pstr->valid_raw_len, 1))
592 11 24 if (BE (pstr->offsets_needed, 0))
598 20 11 if (pstr->offsets[mid] > offset)
600 2 9 else if (pstr->offsets[mid] < offset)
605 20 2 while (low < high);
606 2 9 if (pstr->offsets[mid] < offset)
614 11 0 if (pstr->valid_len > offset
615 11 0 && mid == offset && pstr->offsets[mid] == offset)
9 2 && mid == offset && pstr->offsets[mid] == offset)
617 0 9 Move (pstr->wcs + offset, pstr->wcs, pstr->valid_len - offset, rpl__wint_t);
621 72 9 for (low = 0; low < pstr->valid_len; low++)
631 2 0 while (mid > 0 && pstr->offsets[mid - 1] == offset)
0 2 while (mid > 0 && pstr->offsets[mid - 1] == offset)
633 2 0 while (mid < pstr->valid_len)
634 2 0 if (pstr->wcs[mid] != rpl__WEOF)
638 0 2 if (mid == pstr->valid_len)
643 2 0 if (pstr->valid_len)
645 2 2 for (low = 0; low < pstr->valid_len; ++low)
659 24 0 if (pstr->mb_cur_max > 1)
660 0 24 Move (pstr->wcs + offset, pstr->wcs, pstr->valid_len - offset, rpl__wint_t);
662 3 21 if (BE (pstr->mbs_allocated, 0))
677 0 10 if (BE (pstr->offsets_needed, 0))
686 10 0 if (pstr->mb_cur_max > 1)
691 0 10 if (pstr->is_utf8)
699 0 0 if (end < pstr->raw_mbs)
704 0 0 if (rpl__isascii (*p) && BE (pstr->trans == NULL, 1))
0 0 if (rpl__isascii (*p) && BE (pstr->trans == NULL, 1))
712 0 0 for (; p >= end; --p)
713 0 0 if ((*p & 0xc0) != 0x80)
722 0 0 if (BE (pstr->trans != NULL, 0))
725 0 0 while (--i >= 0)
734 0 0 if (raw + offset - p <= mbclen
735 0 0 && mbclen < (size_t) -2)
746 10 0 if (wc == rpl__WEOF)
748 2 8 if (wc == rpl__WEOF)
752 0 8 pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0)
0 8 pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0)
753 0 0 && IS_WIDE_WORD_CHAR (wc))
0 0 && IS_WIDE_WORD_CHAR (wc))
756 0 0 && pstr->newline_anchor)
758 0 10 if (BE (pstr->valid_len, 0))
760 0 0 for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx)
762 0 0 if (pstr->mbs_allocated)
772 0 0 if (pstr->trans)
774 0 0 pstr->tip_context = (bitset_contain (aTHX_ pstr->word_char, c)
0 0 pstr->tip_context = (bitset_contain (aTHX_ pstr->word_char, c)
776 0 0 : ((IS_NEWLINE (c) && pstr->newline_anchor)
780 30 15 if (!BE (pstr->mbs_allocated, 0))
789 51 0 if (pstr->mb_cur_max > 1)
791 16 35 if (pstr->icase)
794 0 16 if (BE (ret != REG_NOERROR, 0))
802 0 0 if (BE (pstr->mbs_allocated, 0))
804 0 0 if (pstr->icase)
806 0 0 else if (pstr->trans != NULL)
824 12 0 if (BE (!pstr->mbs_allocated, 1))
828 0 0 if (pstr->mb_cur_max > 1
829 0 0 && ! re_string_is_single_byte_char (aTHX_ pstr, pstr->cur_idx + idx))
0 0 && ! re_string_is_single_byte_char (aTHX_ pstr, pstr->cur_idx + idx))
0 0 && ! re_string_is_single_byte_char (aTHX_ pstr, pstr->cur_idx + idx))
835 0 0 if (pstr->offsets_needed)
846 0 0 if (pstr->offsets_needed && !rpl__isascii (ch))
0 0 if (pstr->offsets_needed && !rpl__isascii (ch))
857 0 0 if (BE (!pstr->mbs_allocated, 1))
861 0 0 if (pstr->offsets_needed)
873 0 0 if (!re_string_first_byte (aTHX_ pstr, pstr->cur_idx))
0 0 if (!re_string_first_byte (aTHX_ pstr, pstr->cur_idx))
879 0 0 if (! rpl__isascii (ch))
896 20 0 re_free (pstr->wcs);
897 1 19 re_free (pstr->offsets);
899 2 18 if (pstr->mbs_allocated)
900 2 0 re_free (pstr->mbs);
910 0 81 if (BE (! REG_VALID_INDEX (idx), 0))
914 3 78 if (BE (idx == input->len, 0))
915 0 3 return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF
918 78 0 if (input->mb_cur_max > 1)
922 80 62 while(input->wcs[wc_idx] == rpl__WEOF)
929 16 64 if (! REG_VALID_INDEX (wc_idx))
933 0 62 if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc))
0 0 if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc))
0 0 if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc))
935 0 62 return (IS_WIDE_NEWLINE (wc) && input->newline_anchor
0 0 return (IS_WIDE_NEWLINE (wc) && input->newline_anchor
942 0 0 if (bitset_contain (aTHX_ input->word_char, c))
944 0 0 return IS_NEWLINE (c) && input->newline_anchor ? CONTEXT_NEWLINE : 0;
0 0 return IS_NEWLINE (c) && input->newline_anchor ? CONTEXT_NEWLINE : 0;
956 0 100 re_malloc (set->elems, Idx, size);
977 0 2 if (elem1 == elem2)
985 2 0 if (elem1 < elem2)
1004 36 0 if (src->nelem > 0)
1007 0 36 re_malloc (dest->elems, Idx, dest->alloc);
1008 0 36 Copy (src->elems, dest->elems, src->nelem, Idx);
1025 19 0 if (src1->nelem == 0 || src2->nelem == 0)
0 19 if (src1->nelem == 0 || src2->nelem == 0)
1030 18 1 if (src1->nelem + src2->nelem + dest->nelem > dest->alloc)
1033 0 18 re_realloc (dest->elems, Idx, new_alloc);
1045 48 9 if (src1->elems[i1] == src2->elems[i2])
1048 47 20 while (REG_VALID_INDEX (id) && dest->elems[id] > src1->elems[i1])
19 28 while (REG_VALID_INDEX (id) && dest->elems[id] > src1->elems[i1])
1051 28 20 if (! REG_VALID_INDEX (id) || dest->elems[id] != src1->elems[i1])
9 19 if (! REG_VALID_INDEX (id) || dest->elems[id] != src1->elems[i1])
1054 29 19 if (! REG_VALID_INDEX (--i1) || ! REG_VALID_INDEX (--i2))
29 0 if (! REG_VALID_INDEX (--i1) || ! REG_VALID_INDEX (--i2))
1059 0 9 else if (src1->elems[i1] < src2->elems[i2])
1061 0 0 if (! REG_VALID_INDEX (--i2))
1066 0 9 if (! REG_VALID_INDEX (--i1))
1079 19 0 if (delta > 0 && REG_VALID_INDEX (id))
19 0 if (delta > 0 && REG_VALID_INDEX (id))
1082 9 19 if (dest->elems[is] > dest->elems[id])
1086 0 9 if (delta == 0)
1093 19 0 if (! REG_VALID_INDEX (--id))
1099 0 19 Copy (dest->elems + sbase, dest->elems, delta, Idx);
1113 0 0 if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0)
0 0 if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0)
0 0 if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0)
0 0 if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0)
1116 0 0 re_malloc (dest->elems, Idx, dest->alloc);
1120 0 0 if (src1 != NULL && src1->nelem > 0)
0 0 if (src1 != NULL && src1->nelem > 0)
1122 0 0 else if (src2 != NULL && src2->nelem > 0)
0 0 else if (src2 != NULL && src2->nelem > 0)
1128 0 0 for (i1 = i2 = id = 0 ; i1 < src1->nelem && i2 < src2->nelem ;)
0 0 for (i1 = i2 = id = 0 ; i1 < src1->nelem && i2 < src2->nelem ;)
1130 0 0 if (src1->elems[i1] > src2->elems[i2])
1135 0 0 if (src1->elems[i1] == src2->elems[i2])
1139 0 0 if (i1 < src1->nelem)
1141 0 0 Copy (src1->elems + i1, dest->elems + id, src1->nelem - i1, Idx);
1144 0 0 else if (i2 < src2->nelem)
1146 0 0 Copy (src2->elems + i2, dest->elems + id, src2->nelem - i2, Idx);
1161 38 0 if (src == NULL || src->nelem == 0)
0 38 if (src == NULL || src->nelem == 0)
1163 14 24 if (dest->alloc < 2 * src->nelem + dest->nelem)
1166 0 14 re_realloc (dest->elems, Idx, new_alloc);
1170 36 2 if (BE (dest->nelem == 0, 0))
1173 0 36 Copy (src->elems, dest->elems, src->nelem, Idx);
1179 2 2 for (sbase = dest->nelem + 2 * src->nelem,
1181 2 0 REG_VALID_INDEX (is) && REG_VALID_INDEX (id); )
1183 0 2 if (dest->elems[id] == src->elems[is])
1185 2 0 else if (dest->elems[id] < src->elems[is])
1191 0 2 if (REG_VALID_INDEX (is))
1195 0 0 Copy (src->elems, dest->elems + sbase, is + 1, Idx);
1201 0 2 if (delta == 0)
1209 2 0 if (dest->elems[is] > dest->elems[id])
1213 2 0 if (delta == 0)
1220 0 0 if (! REG_VALID_INDEX (--id))
1223 0 0 Copy (dest->elems + sbase, dest->elems, delta, Idx);
1242 12 81 if (set->alloc == 0)
1245 57 24 if (BE (set->nelem, 0) == 0)
1254 9 15 if (set->alloc == set->nelem)
1257 0 9 re_realloc (set->elems, Idx, set->alloc);
1262 12 12 if (elem < set->elems[0])
1265 17 12 for (idx = set->nelem; idx > 0; idx--)
1270 0 12 for (idx = set->nelem; set->elems[idx - 1] > elem; idx--)
1289 20 42 if (set->alloc == set->nelem)
1292 0 20 re_realloc (set->elems, Idx, set->alloc);
1308 66 0 if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem)
66 0 if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem)
3 63 if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem)
1310 136 63 for (i = set1->nelem ; REG_VALID_INDEX (--i) ; )
1311 0 136 if (set1->elems[i] != set2->elems[i])
1323 0 54 if (! REG_VALID_NONZERO_INDEX (set->nelem))
1329 74 54 while (idx < right)
1332 44 30 if (set->elems[mid] < elem)
1337 45 9 return set->elems[idx] == elem ? idx + 1 : 0;
1344 0 0 if (idx < 0 || idx >= set->nelem)
1347 0 0 for (; idx < set->nelem; idx++)
1359 0 48 if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0))
1367 0 0 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_nodes_alloc, 0))
1370 0 0 re_realloc (dfa->nodes, re_token_t, new_nodes_alloc);
1371 0 0 re_realloc (dfa->nexts, Idx, new_nodes_alloc);
1372 0 0 re_realloc (dfa->org_indices, Idx, new_nodes_alloc);
1373 0 0 re_realloc (dfa->edests, re_node_set, new_nodes_alloc);
1374 0 0 re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc);
1381 0 0 ((token.type == OP_PERIOD && dfa->mb_cur_max > 1)
1382 0 48 || token.type == COMPLEX_BRACKET);
2 46 || token.type == COMPLEX_BRACKET);
1396 186 93 for (i = 0 ; i < nodes->nelem ; i++)
1423 0 38 if (BE (nodes->nelem == 0, 0))
1431 31 7 for (i = 0 ; i < spot->num ; i++)
1434 0 31 if (hash != state->hash)
1436 31 0 if (re_node_set_compare (aTHX_ &state->nodes, nodes))
1442 0 7 if (BE (new_state == NULL, 0))
1471 0 55 if (nodes->nelem == 0)
1479 35 23 for (i = 0 ; i < spot->num ; i++)
1482 35 0 if (state->hash == hash
1483 35 0 && state->context == context
1484 32 3 && re_node_set_compare (aTHX_ state->entrance_nodes, nodes))
1489 0 23 if (BE (new_state == NULL, 0))
1510 0 30 if (BE (err != REG_NOERROR, 0))
1512 50 30 for (i = 0; i < newstate->nodes.nelem; i++)
1515 32 18 if (!IS_EPSILON_NODE (dfa->nodes[elem].type))
1516 0 32 if (! re_node_set_insert_last (aTHX_ &newstate->non_eps_nodes, elem))
1521 27 3 if (BE (spot->alloc <= spot->num, 0))
1524 0 27 re_realloc (spot->array, re_dfastate_t *, new_alloc);
1534 30 0 re_node_set_free (&state->non_eps_nodes);
1535 5 25 re_node_set_free (&state->inveclosure);
1536 0 30 if (state->entrance_nodes != &state->nodes)
1538 0 0 re_node_set_free (state->entrance_nodes);
1539 0 0 re_free (state->entrance_nodes);
1541 30 0 re_node_set_free (&state->nodes);
1542 0 30 re_free (state->word_trtable);
1543 19 11 re_free (state->trtable);
1544 30 0 re_free (state);
1561 0 7 if (BE (newstate == NULL, 0))
1564 0 7 if (BE (err != REG_NOERROR, 0))
1566 0 0 re_free (newstate);
1571 11 7 for (i = 0 ; i < nodes->nelem ; i++)
1575 1 10 if (type == CHARACTER && !node->constraint)
1 0 if (type == CHARACTER && !node->constraint)
1582 2 8 if (type == END_OF_RE)
1584 0 8 else if (type == OP_BACK_REF)
1586 8 0 else if (type == ANCHOR || node->constraint)
0 8 else if (type == ANCHOR || node->constraint)
1590 0 7 if (BE (err != REG_NOERROR, 0))
1612 0 23 if (BE (newstate == NULL, 0))
1615 0 23 if (BE (err != REG_NOERROR, 0))
1617 0 0 re_free (newstate);
1624 39 23 for (i = 0 ; i < nodes->nelem ; i++)
1630 16 23 if (type == CHARACTER && !constraint)
16 0 if (type == CHARACTER && !constraint)
1637 5 18 if (type == END_OF_RE)
1639 0 18 else if (type == OP_BACK_REF)
1642 0 23 if (constraint)
1644 0 0 if (newstate->entrance_nodes == &newstate->nodes)
1647 0 0 if (re_node_set_init_copy (aTHX_ newstate->entrance_nodes, nodes)
1654 0 0 if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context))
0 0 if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context))
0 0 if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context))
0 0 if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context))
0 0 if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context))
0 0 if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context))
0 0 if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context))
0 0 if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context))
1662 0 23 if (BE (err != REG_NOERROR, 0))