MCPcopy Create free account
hub / github.com/git/git / build_collating_symbol

Function build_collating_symbol

compat/regex/regcomp.c:2994–3053  ·  view source on GitHub ↗
(sbcset, mbcset, coll_sym_alloc, name)

Source from the content-addressed store, hash-verified

2992 bitset_set (sbcset, ch);
2993 }
2994 return REG_NOERROR;
2995 }
2996
2997 /* Local function for parse_bracket_exp used in _LIBC environment.
2998 Build the collating element which is represented by NAME.
2999 The result are written to MBCSET and SBCSET.
3000 COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
3001 pointer argument since we may update it. */
3002
3003 auto inline reg_errcode_t
3004 __attribute ((always_inline))
3005 build_collating_symbol (sbcset, mbcset, coll_sym_alloc, name)
3006 re_charset_t *mbcset;
3007 int *coll_sym_alloc;
3008 bitset_t sbcset;
3009 const unsigned char *name;
3010 {
3011 int32_t elem, idx;
3012 size_t name_len = strlen ((const char *) name);
3013 if (nrules != 0)
3014 {
3015 elem = seek_collating_symbol_entry (name, name_len);
3016 if (symb_table[2 * elem] != 0)
3017 {
3018 /* We found the entry. */
3019 idx = symb_table[2 * elem + 1];
3020 /* Skip the name of collating element name. */
3021 idx += 1 + extra[idx];
3022 }
3023 else if (symb_table[2 * elem] == 0 && name_len == 1)
3024 {
3025 /* No valid character, treat it as a normal
3026 character. */
3027 bitset_set (sbcset, name[0]);
3028 return REG_NOERROR;
3029 }
3030 else
3031 return REG_ECOLLATE;
3032
3033 /* Got valid collation sequence, add it as a new entry. */
3034 /* Check the space of the arrays. */
3035 if (BE (*coll_sym_alloc == mbcset->ncoll_syms, 0))
3036 {
3037 /* Not enough, realloc it. */
3038 /* +1 in case of mbcset->ncoll_syms is 0. */
3039 int new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1;
3040 /* Use realloc since mbcset->coll_syms is NULL
3041 if *alloc == 0. */
3042 int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
3043 new_coll_sym_alloc);
3044 if (BE (new_coll_syms == NULL, 0))
3045 return REG_ESPACE;
3046 mbcset->coll_syms = new_coll_syms;
3047 *coll_sym_alloc = new_coll_sym_alloc;
3048 }
3049 mbcset->coll_syms[mbcset->ncoll_syms++] = idx;
3050 return REG_NOERROR;
3051 }

Callers 1

parse_bracket_expFunction · 0.85

Calls 1

Tested by

no test coverage detected