3 union locale_data_value {
9 extern __thread struct locale_data **_nl_current_LC_CTYPE;
10 typedef unsigned long int reg_syntax_t;
11 extern reg_syntax_t re_syntax_options;
17 unsigned char *translate;
21 extern __thread void *__libc_tsd_CTYPE_TOLOWER;
22 inline int **__ctype_tolower_loc(void) {
28 u.ptr = (&__libc_tsd_CTYPE_TOLOWER);
29 if (*u.tablep == 0) *u.tablep = (*_nl_current_LC_CTYPE)->values[0].string;
32 inline int tolower(int __c) {
33 return *__ctype_tolower_loc()[__c];
43 CHARACTER = 1, COMPLEX_BRACKET = 6 }
53 unsigned long int *sbcset;
59 typedef struct re_dfa_t re_dfa_t;
66 unsigned int nodes_len;
67 re_dfastate_t *init_state;
68 unsigned long int *sb_char;
70 unsigned int has_mb_node:1;
71 unsigned int is_utf8:1;
72 unsigned int map_notascii:1;
76 static inline void re_set_fastmap(char *fastmap, int icase, int ch) {
82 else __res = tolower(ch);
87 static void re_compile_fastmap_iter(regex_t * bufp, re_dfastate_t * init_state, char *fastmap) {
92 node_cnt < init_state->nodes.nelem;
95 if (type == CHARACTER) {
96 if ((bufp->syntax & 0x40000) && dfa->mb_cur_max > 1) {
97 void *buf = alloca(dfa->mb_cur_max);
102 i < (256 / (sizeof(unsigned long int) * 8));
108 ) if (w & 1) re_set_fastmap(fastmap, icase, ch);
111 else if (type == COMPLEX_BRACKET) {
119 if (__wcrtomb(buf, cset->mbchars[i], &state) != -1) re_set_fastmap(fastmap, icase, *buf);
124 static unsigned long int *utf8_sb_map;
125 static reg_errcode_t re_compile_internal(regex_t * preg, const char *pattern, unsigned int length, reg_syntax_t syntax) {
127 if (dfa->is_utf8 && !(syntax & 0x400000) && preg->translate == 0) optimize_utf8(dfa);
129 if (strlen((*_nl_current_LC_CTYPE)->values[0].string) < 4) result = (*_nl_current_LC_CTYPE)->values[0].string[0] - 'U';
130 else result = strcmp((*_nl_current_LC_CTYPE)->values[0].string, "UTF-8");
131 if (dfa->mb_cur_max == 6 && result == 0) dfa->is_utf8 = 1;
132 if (dfa->mb_cur_max > 1) {
133 if (dfa->is_utf8) dfa->sb_char = utf8_sb_map;
137 i < (256 / (sizeof(unsigned long int) * 8));
147 node < dfa->nodes_len;
148 ) switch (dfa->nodes[node].type) {
149 case CHARACTER: if (dfa->nodes[node].opr.c >= 0x80) mb_chars = 1;
151 i < (256 / (sizeof(unsigned long int) * 8));
152 ) if (dfa->nodes[node].opr.sbcset[i]) return;
154 dfa->has_mb_node = dfa->nbackref > 0 || has_period;
155 if (dfa->subexp_map != 0) {
158 i++) if (dfa->subexp_map[i] != i) break;
161 const char *__re_compile_pattern(const char *pattern, unsigned int length, regex_t * bufp) {
162 reg_errcode_t ret = re_compile_internal(bufp, pattern, length, re_syntax_options);
164 void __re_compile_fastmap(regex_t * bufp) {
167 re_compile_fastmap_iter(bufp, dfa->init_state, fastmap);