3 union locale_data_value {
8 extern __thread struct locale_data **_nl_current_LC_CTYPE;
9 typedef unsigned long int reg_syntax_t;
10 extern reg_syntax_t re_syntax_options;
15 unsigned char *buffer;
17 unsigned char *translate;
20 extern __thread void *__libc_tsd_CTYPE_TOLOWER;
21 inline int **__ctype_tolower_loc(void)
27 u.ptr = (&__libc_tsd_CTYPE_TOLOWER);
29 *u.tablep = (*_nl_current_LC_CTYPE)->values[0].string;
32 inline int tolower(int __c)
34 return *__ctype_tolower_loc()[__c];
43 CHARACTER = 1, COMPLEX_BRACKET = 6
52 unsigned long int * sbcset;
57 typedef struct re_dfa_t re_dfa_t;
58 typedef struct bin_tree_t bin_tree_t;
64 unsigned int nodes_len;
65 re_dfastate_t *init_state;
67 unsigned long int * sb_char;
69 unsigned int has_mb_node:1;
70 unsigned int is_utf8:1;
71 unsigned int map_notascii:1;
75 static reg_errcode_t analyze(regex_t * preg);
76 static reg_errcode_t optimize_subexps(void *extra, bin_tree_t * node);
77 static inline void re_set_fastmap(char *fastmap, int icase, int ch)
89 static void re_compile_fastmap_iter(regex_t * bufp, re_dfastate_t * init_state,
96 icase = (dfa->mb_cur_max == 1 && (bufp->syntax & 0x40000));
97 for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt) {
99 node = init_state->nodes.elems[node_cnt];
100 re_token_type_t type;
101 type = dfa->nodes[node].type;
102 if (type == CHARACTER) {
103 if ((bufp->syntax & 0x40000) && dfa->mb_cur_max > 1) {
104 void *buf = alloca(dfa->mb_cur_max);
108 for (; i < (256 / (sizeof(unsigned long int) * 8));) {
112 dfa->nodes[node].opr.sbcset[i];
115 re_set_fastmap(fastmap, icase,
118 } else if (type == COMPLEX_BRACKET) {
121 cset = dfa->nodes[node].opr.mbcset;
122 for (; i < cset->nmbchars;) {
125 if (__wcrtomb(buf, cset->mbchars[i], &state) !=
127 re_set_fastmap(fastmap, icase, *buf);
128 if ((bufp->syntax & 0x4000)
129 && dfa->mb_cur_max > 1) {
135 static unsigned long int * utf8_sb_map;
136 static reg_errcode_t re_compile_internal(regex_t * preg, const char *pattern,
143 if (dfa->is_utf8 && !(syntax & 0x400000) && preg->translate == 0)
145 unsigned int __s1_len =
146 strlen((*_nl_current_LC_CTYPE)->values[0].string);
148 (((!((int)((((*_nl_current_LC_CTYPE)->values[0].string))) -
149 (int)(((*_nl_current_LC_CTYPE)->values[0].string))))
150 && (!((int)(("UTF-8") + 1) - (int)("UTF-8")))) ?
151 strcmp(((*_nl_current_LC_CTYPE)->values[0].string),
153 : (((int)((((*_nl_current_LC_CTYPE)->values[0].string)) + 1) -
154 (int)(((*_nl_current_LC_CTYPE)->values[0].string)))
156 4 ? (((int)(("UTF-8")) - (int)("UTF-8")) ?
157 strcmp(((*_nl_current_LC_CTYPE)->values[0].string),
158 "UTF-8") : (((*_nl_current_LC_CTYPE)->values[0].
160 'U'))) : (((int)(("UTF-8")) -
163 ((((*_nl_current_LC_CTYPE)->values[0].string))) - (int)(((*_nl_current_LC_CTYPE)->values[0].string))) ? strcmp(((*_nl_current_LC_CTYPE)->values[0].string), "UTF-8") : (((*_nl_current_LC_CTYPE)->values[0].string[0] - 'U'))) : strcmp(((*_nl_current_LC_CTYPE)->values[0].string), "UTF-8"))));
164 if (dfa->mb_cur_max == 6 && result == 0)
166 dfa->map_notascii = (*_nl_current_LC_CTYPE)->values[0].word != 0;
167 if (dfa->mb_cur_max > 1) {
176 i < (256 / (sizeof(unsigned long int) * 8));
180 if (wch != (0xffffffffu))
181 dfa->sb_char[i] |= 1 << j;
189 for (; node < dfa->nodes_len;)
190 switch (dfa->nodes[node].type) {
192 if (dfa->nodes[node].opr.c >= 0x80)
194 for (; i < (256 / (sizeof(unsigned long int) * 8));)
195 if (dfa->nodes[node].opr.sbcset[i])
198 dfa->has_mb_node = dfa->nbackref > 0 || has_period;
200 static reg_errcode_t analyze(regex_t * preg)
204 if (dfa->subexp_map != 0) {
206 for (; i < preg->re_nsub;)
207 dfa->subexp_map[i] = i;
208 preorder(dfa->str_tree, optimize_subexps, dfa);
209 for (; i < preg->re_nsub; i++)
210 if (dfa->subexp_map[i] != i)
214 const char *__re_compile_pattern(const char *pattern, unsigned int length,
218 re_compile_internal(bufp, pattern, length, re_syntax_options);
221 void __re_compile_fastmap(regex_t * bufp)
225 re_compile_fastmap_iter(bufp, dfa->init_state, fastmap);