| 921 | |
| 922 | /* Return the context at IDX in INPUT. */ |
| 923 | |
| 924 | static unsigned int |
| 925 | internal_function |
| 926 | re_string_context_at (const re_string_t *input, int idx, int eflags) |
| 927 | { |
| 928 | int c; |
| 929 | if (BE (idx < 0, 0)) |
| 930 | /* In this case, we use the value stored in input->tip_context, |
| 931 | since we can't know the character in input->mbs[-1] here. */ |
| 932 | return input->tip_context; |
| 933 | if (BE (idx == input->len, 0)) |
| 934 | return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF |
| 935 | : CONTEXT_NEWLINE | CONTEXT_ENDBUF); |
| 936 | #ifdef RE_ENABLE_I18N |
| 937 | if (input->mb_cur_max > 1) |
| 938 | { |
| 939 | wint_t wc; |
| 940 | int wc_idx = idx; |
| 941 | while(input->wcs[wc_idx] == WEOF) |
| 942 | { |
| 943 | #ifdef DEBUG |
| 944 | /* It must not happen. */ |
| 945 | assert (wc_idx >= 0); |
| 946 | #endif |
| 947 | --wc_idx; |
| 948 | if (wc_idx < 0) |
| 949 | return input->tip_context; |
| 950 | } |
| 951 | wc = input->wcs[wc_idx]; |
| 952 | if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc)) |
| 953 | return CONTEXT_WORD; |
| 954 | return (IS_WIDE_NEWLINE (wc) && input->newline_anchor |
| 955 | ? CONTEXT_NEWLINE : 0); |
| 956 | } |
| 957 | else |
| 958 | #endif |
| 959 | { |
| 960 | c = re_string_byte_at (input, idx); |
| 961 | if (bitset_contain (input->word_char, c)) |
| 962 | return CONTEXT_WORD; |
| 963 | return IS_NEWLINE (c) && input->newline_anchor ? CONTEXT_NEWLINE : 0; |
| 964 | } |
| 965 | } |
| 966 | |
| 967 |
no outgoing calls
no test coverage detected