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;
16 unsigned char *translate;
19 extern __thread void *__libc_tsd_CTYPE_TOLOWER;
20 inline int **__ctype_tolower_loc(void)
26 u.ptr = (&__libc_tsd_CTYPE_TOLOWER);
28 *u.tablep = (*_nl_current_LC_CTYPE)->values[0].string;
31 inline int tolower(int __c)
33 return *__ctype_tolower_loc()[__c];
41 CHARACTER = 1, COMPLEX_BRACKET = 6
50 unsigned long int *sbcset;
54 typedef struct re_dfa_t re_dfa_t;
60 unsigned int nodes_len;
61 re_dfastate_t *init_state;
62 unsigned long int *sb_char;
64 unsigned int has_mb_node:1;
65 unsigned int is_utf8:1;
66 unsigned int map_notascii:1;
70 static inline void re_set_fastmap(char *fastmap, int icase, int ch)
82 static void re_compile_fastmap_iter(regex_t * bufp, re_dfastate_t * init_state,
88 for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt) {
90 if (type == CHARACTER) {
91 if ((bufp->syntax & 0x40000) && dfa->mb_cur_max > 1) {
92 void *buf = alloca(dfa->mb_cur_max);
96 for (; i < (256 / (sizeof(unsigned long int) * 8));) {
101 re_set_fastmap(fastmap, icase,
104 } else if (type == COMPLEX_BRACKET) {
107 for (; i < cset->nmbchars;) {
110 if (__wcrtomb(buf, cset->mbchars[i], &state) !=
112 re_set_fastmap(fastmap, icase, *buf);
117 static unsigned long int *utf8_sb_map;
118 static reg_errcode_t re_compile_internal(regex_t * preg, const char *pattern,
123 if (dfa->is_utf8 && !(syntax & 0x400000) && preg->translate == 0)
126 if (strlen((*_nl_current_LC_CTYPE)->values[0].string) < 4)
127 result = (*_nl_current_LC_CTYPE)->values[0].string[0] - 'U';
130 strcmp((*_nl_current_LC_CTYPE)->values[0].string, "UTF-8");
131 if (dfa->mb_cur_max == 6 && result == 0)
133 dfa->map_notascii = (*_nl_current_LC_CTYPE)->values[0].word != 0;
134 if (dfa->mb_cur_max > 1) {
136 dfa->sb_char = utf8_sb_map;
139 for (; i < (256 / (sizeof(unsigned long int) * 8));) ;
146 for (; node < dfa->nodes_len;)
147 switch (dfa->nodes[node].type) {
149 if (dfa->nodes[node].opr.c >= 0x80)
151 for (; i < (256 / (sizeof(unsigned long int) * 8));)
152 if (dfa->nodes[node].opr.sbcset[i])
155 dfa->has_mb_node = dfa->nbackref > 0 || has_period;
156 if (dfa->subexp_map != 0) {
157 for (; i < preg->re_nsub; i++)
158 if (dfa->subexp_map[i] != i)
162 const char *__re_compile_pattern(const char *pattern, unsigned int length,
166 re_compile_internal(bufp, pattern, length, re_syntax_options);
169 void __re_compile_fastmap(regex_t * bufp)
173 re_compile_fastmap_iter(bufp, dfa->init_state, fastmap);