| 491 | /* Skip characters until the index becomes greater than NEW_RAW_IDX. |
| 492 | Return the index. */ |
| 493 | |
| 494 | static int |
| 495 | internal_function |
| 496 | re_string_skip_chars (re_string_t *pstr, int new_raw_idx, wint_t *last_wc) |
| 497 | { |
| 498 | mbstate_t prev_st; |
| 499 | int rawbuf_idx; |
| 500 | size_t mbclen; |
| 501 | wint_t wc = WEOF; |
| 502 | |
| 503 | /* Skip the characters which are not necessary to check. */ |
| 504 | for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len; |
| 505 | rawbuf_idx < new_raw_idx;) |
| 506 | { |
| 507 | wchar_t wc2; |
| 508 | int remain_len = pstr->len - rawbuf_idx; |
| 509 | prev_st = pstr->cur_state; |
| 510 | mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx, |
| 511 | remain_len, &pstr->cur_state); |
| 512 | if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0)) |
| 513 | { |
| 514 | /* We treat these cases as a single byte character. */ |
| 515 | if (mbclen == 0 || remain_len == 0) |
| 516 | wc = L'\0'; |
| 517 | else |
| 518 | wc = *(unsigned char *) (pstr->raw_mbs + rawbuf_idx); |
| 519 | mbclen = 1; |
| 520 | pstr->cur_state = prev_st; |
| 521 | } |
| 522 | else |
| 523 | wc = (wint_t) wc2; |
| 524 | /* Then proceed the next character. */ |
| 525 | rawbuf_idx += mbclen; |
| 526 | } |
| 527 | *last_wc = (wint_t) wc; |
| 528 | return rawbuf_idx; |
| 529 | } |
| 530 | #endif /* RE_ENABLE_I18N */ |
| 531 |
no outgoing calls
no test coverage detected