| 576 | Concretely, convert to wide character in case of pstr->mb_cur_max > 1, |
| 577 | convert to upper case in case of REG_ICASE, apply translation. */ |
| 578 | |
| 579 | static reg_errcode_t |
| 580 | internal_function |
| 581 | re_string_reconstruct (re_string_t *pstr, int idx, int eflags) |
| 582 | { |
| 583 | int offset = idx - pstr->raw_mbs_idx; |
| 584 | if (BE (offset < 0, 0)) |
| 585 | { |
| 586 | /* Reset buffer. */ |
| 587 | #ifdef RE_ENABLE_I18N |
| 588 | if (pstr->mb_cur_max > 1) |
| 589 | memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); |
| 590 | #endif /* RE_ENABLE_I18N */ |
| 591 | pstr->len = pstr->raw_len; |
| 592 | pstr->stop = pstr->raw_stop; |
| 593 | pstr->valid_len = 0; |
| 594 | pstr->raw_mbs_idx = 0; |
| 595 | pstr->valid_raw_len = 0; |
| 596 | pstr->offsets_needed = 0; |
| 597 | pstr->tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF |
| 598 | : CONTEXT_NEWLINE | CONTEXT_BEGBUF); |
| 599 | if (!pstr->mbs_allocated) |
| 600 | pstr->mbs = (unsigned char *) pstr->raw_mbs; |
| 601 | offset = idx; |
| 602 | } |
| 603 | |
| 604 | if (BE (offset != 0, 1)) |
| 605 | { |
| 606 | /* Should the already checked characters be kept? */ |
| 607 | if (BE (offset < pstr->valid_raw_len, 1)) |
| 608 | { |
| 609 | /* Yes, move them to the front of the buffer. */ |
| 610 | #ifdef RE_ENABLE_I18N |
| 611 | if (BE (pstr->offsets_needed, 0)) |
| 612 | { |
| 613 | int low = 0, high = pstr->valid_len, mid; |
| 614 | do |
| 615 | { |
| 616 | mid = low + (high - low) / 2; |
| 617 | if (pstr->offsets[mid] > offset) |
| 618 | high = mid; |
| 619 | else if (pstr->offsets[mid] < offset) |
| 620 | low = mid + 1; |
| 621 | else |
| 622 | break; |
| 623 | } |
| 624 | while (low < high); |
| 625 | if (pstr->offsets[mid] < offset) |
| 626 | ++mid; |
| 627 | pstr->tip_context = re_string_context_at (pstr, mid - 1, |
| 628 | eflags); |
| 629 | /* This can be quite complicated, so handle specially |
| 630 | only the common and easy case where the character with |
| 631 | different length representation of lower and upper |
| 632 | case is present at or after offset. */ |
| 633 | if (pstr->valid_len > offset |
| 634 | && mid == offset && pstr->offsets[mid] == offset) |
| 635 | { |
no test coverage detected