]> git.wh0rd.org - ICEs.git/blob - hppa-ICE-insn-constraints/regex.i.12
add bfin ice
[ICEs.git] / hppa-ICE-insn-constraints / regex.i.12
1 struct locale_data {
2 unsigned int nstrings;
3 union locale_data_value {
4 char *string;
5 unsigned int word;
6 } values[];
7 };
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;
11 typedef enum {
12 REG_ENOSYS
13 } reg_errcode_t;
14 typedef struct {
15 reg_syntax_t syntax;
16 unsigned char *translate;
17 unsigned int re_nsub;
18 } regex_t;
19 extern __thread void *__libc_tsd_CTYPE_TOLOWER;
20 inline int **__ctype_tolower_loc(void)
21 {
22 union {
23 void **ptr;
24 int **tablep;
25 } u;
26 u.ptr = (&__libc_tsd_CTYPE_TOLOWER);
27 if (*u.tablep == 0)
28 *u.tablep = (*_nl_current_LC_CTYPE)->values[0].string;
29 return u.tablep;
30 }
31 inline int tolower(int __c)
32 {
33 return *__ctype_tolower_loc()[__c];
34 }
35 typedef struct {
36 } mbstate_t;
37 typedef struct {
38 int nelem;
39 } re_node_set;
40 typedef enum {
41 CHARACTER = 1, COMPLEX_BRACKET = 6
42 } re_token_type_t;
43 typedef struct {
44 long int *mbchars;
45 int nmbchars;
46 } re_charset_t;
47 typedef struct {
48 union {
49 unsigned char c;
50 unsigned long int *sbcset;
51 } opr;
52 re_token_type_t type;
53 } re_token_t;
54 typedef struct re_dfa_t re_dfa_t;
55 typedef struct {
56 re_node_set nodes;
57 } re_dfastate_t;
58 struct re_dfa_t {
59 re_token_t *nodes;
60 unsigned int nodes_len;
61 re_dfastate_t *init_state;
62 unsigned long int *sb_char;
63 int nbackref;
64 unsigned int has_mb_node:1;
65 unsigned int is_utf8:1;
66 unsigned int map_notascii:1;
67 int mb_cur_max;
68 int *subexp_map;
69 };
70 static inline void re_set_fastmap(char *fastmap, int icase, int ch)
71 {
72 if (icase) {
73 int __res;
74 if (sizeof(ch) > 1) {
75 if (ch) {
76 } else
77 __res = tolower(ch);
78 }
79 fastmap[__res] = 1;
80 }
81 }
82 static void re_compile_fastmap_iter(regex_t * bufp, re_dfastate_t * init_state,
83 char *fastmap)
84 {
85 re_dfa_t *dfa;
86 int node_cnt;
87 int icase;
88 for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt) {
89 re_token_type_t type;
90 if (type == CHARACTER) {
91 if ((bufp->syntax & 0x40000) && dfa->mb_cur_max > 1) {
92 void *buf = alloca(dfa->mb_cur_max);
93 }
94 int i;
95 int ch;
96 for (; i < (256 / (sizeof(unsigned long int) * 8));) {
97 int j;
98 int w;
99 for (; j < 8;)
100 if (w & 1)
101 re_set_fastmap(fastmap, icase,
102 ch);
103 }
104 } else if (type == COMPLEX_BRACKET) {
105 int i;
106 re_charset_t *cset;
107 for (; i < cset->nmbchars;) {
108 char buf[256];
109 mbstate_t state;
110 if (__wcrtomb(buf, cset->mbchars[i], &state) !=
111 -1)
112 re_set_fastmap(fastmap, icase, *buf);
113 }
114 }
115 }
116 }
117 static unsigned long int *utf8_sb_map;
118 static reg_errcode_t re_compile_internal(regex_t * preg, const char *pattern,
119 unsigned int length,
120 reg_syntax_t syntax)
121 {
122 re_dfa_t *dfa;
123 if (dfa->is_utf8 && !(syntax & 0x400000) && preg->translate == 0)
124 optimize_utf8(dfa);
125 int result;
126 if (strlen((*_nl_current_LC_CTYPE)->values[0].string) < 4)
127 result = (*_nl_current_LC_CTYPE)->values[0].string[0] - 'U';
128 else
129 result = strcmp((*_nl_current_LC_CTYPE)->values[0].string, "UTF-8");
130 if (dfa->mb_cur_max == 6 && result == 0)
131 dfa->is_utf8 = 1;
132 dfa->map_notascii = (*_nl_current_LC_CTYPE)->values[0].word != 0;
133 if (dfa->mb_cur_max > 1) {
134 if (dfa->is_utf8)
135 dfa->sb_char = utf8_sb_map;
136 else {
137 int i;
138 int j;
139 int ch;
140 for (;
141 i < (256 / (sizeof(unsigned long int) * 8));
142 ) {
143 }
144 }
145 }
146 int node;
147 int i;
148 int mb_chars;
149 int has_period;
150 for (; node < dfa->nodes_len;)
151 switch (dfa->nodes[node].type) {
152 case CHARACTER:
153 if (dfa->nodes[node].opr.c >= 0x80)
154 mb_chars = 1;
155 for (; i < (256 / (sizeof(unsigned long int) * 8));)
156 if (dfa->nodes[node].opr.sbcset[i])
157 return;
158 }
159 dfa->has_mb_node = dfa->nbackref > 0 || has_period;
160 if (dfa->subexp_map != 0) {
161 for (; i < preg->re_nsub; i++)
162 if (dfa->subexp_map[i] != i)
163 break;
164 }
165 }
166 const char *__re_compile_pattern(const char *pattern, unsigned int length,
167 regex_t * bufp)
168 {
169 reg_errcode_t ret =
170 re_compile_internal(bufp, pattern, length, re_syntax_options);
171 }
172
173 void __re_compile_fastmap(regex_t * bufp)
174 {
175 re_dfa_t *dfa;
176 char *fastmap;
177 re_compile_fastmap_iter(bufp, dfa->init_state, fastmap);
178 }