(sbcset, mbcset, range_alloc, start_elem, end_elem)
| 2909 | } |
| 2910 | return UINT_MAX; |
| 2911 | } |
| 2912 | |
| 2913 | /* Local function for parse_bracket_exp used in _LIBC environment. |
| 2914 | Build the range expression which starts from START_ELEM, and ends |
| 2915 | at END_ELEM. The result are written to MBCSET and SBCSET. |
| 2916 | RANGE_ALLOC is the allocated size of mbcset->range_starts, and |
| 2917 | mbcset->range_ends, is a pointer argument since we may |
| 2918 | update it. */ |
| 2919 | |
| 2920 | auto inline reg_errcode_t |
| 2921 | __attribute ((always_inline)) |
| 2922 | build_range_exp (sbcset, mbcset, range_alloc, start_elem, end_elem) |
| 2923 | re_charset_t *mbcset; |
| 2924 | int *range_alloc; |
| 2925 | bitset_t sbcset; |
| 2926 | bracket_elem_t *start_elem, *end_elem; |
| 2927 | { |
| 2928 | unsigned int ch; |
| 2929 | uint32_t start_collseq; |
| 2930 | uint32_t end_collseq; |
| 2931 | |
| 2932 | /* Equivalence Classes and Character Classes can't be a range |
| 2933 | start/end. */ |
| 2934 | if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS |
| 2935 | || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, |
| 2936 | 0)) |
| 2937 | return REG_ERANGE; |
| 2938 | |
| 2939 | start_collseq = lookup_collation_sequence_value (start_elem); |
| 2940 | end_collseq = lookup_collation_sequence_value (end_elem); |
| 2941 | /* Check start/end collation sequence values. */ |
| 2942 | if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0)) |
| 2943 | return REG_ECOLLATE; |
| 2944 | if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0)) |
| 2945 | return REG_ERANGE; |
| 2946 | |
| 2947 | /* Got valid collation sequence values, add them as a new entry. |
| 2948 | However, if we have no collation elements, and the character set |
| 2949 | is single byte, the single byte character set that we |
| 2950 | build below suffices. */ |
| 2951 | if (nrules > 0 || dfa->mb_cur_max > 1) |
| 2952 | { |
| 2953 | /* Check the space of the arrays. */ |
| 2954 | if (BE (*range_alloc == mbcset->nranges, 0)) |
| 2955 | { |
| 2956 | /* There is not enough space, need realloc. */ |
| 2957 | uint32_t *new_array_start; |
| 2958 | uint32_t *new_array_end; |
| 2959 | int new_nranges; |
| 2960 | |
| 2961 | /* +1 in case of mbcset->nranges is 0. */ |
| 2962 | new_nranges = 2 * mbcset->nranges + 1; |
| 2963 | new_array_start = re_realloc (mbcset->range_starts, uint32_t, |
| 2964 | new_nranges); |
| 2965 | new_array_end = re_realloc (mbcset->range_ends, uint32_t, |
| 2966 | new_nranges); |
| 2967 | |
| 2968 | if (BE (new_array_start == NULL || new_array_end == NULL, 0)) |
no test coverage detected