1 /* { dg-do compile } */
2 /* { dg-options "-march=armv5te -fno-builtin -mfloat-abi=soft -mthumb -fno-stack-protector -Os -fno-tree-loop-optimize -fno-tree-dominator-opts -fPIC -w" } */
3 /* { dg-skip-if "Incompatible command line options: -mfloat-abi=soft -mfloat-abi=hard" { *-*-* } { "-mfloat-abi=hard" } { "" } } */
4 /* { dg-require-effective-target arm_arch_v5te_thumb_ok } */
5
6 typedef enum {
7 REG_ENOSYS = -1,
8 } reg_errcode_t;
9 typedef unsigned long int bitset_word_t;
10 typedef bitset_word_t bitset_t[(256 / (sizeof (bitset_word_t) * 8))];
11 typedef bitset_word_t *re_bitset_ptr_t;
12 typedef const bitset_word_t *re_const_bitset_ptr_t;
13 typedef struct {
14 int nelem;
15 int *elems;
16 } re_node_set;
17 typedef enum {
18 CHARACTER = 1,
19 } re_token_type_t;
20 typedef struct {
21 re_token_type_t type:8;
22 unsigned int word_char:1;
23 } re_token_t;
24 struct re_string_t {
25 const unsigned char *raw_mbs;
26 int raw_mbs_idx;
27 int cur_idx;
28 unsigned int tip_context;
29 re_const_bitset_ptr_t word_char;
30 };
31 typedef struct re_string_t re_string_t;
32 typedef struct re_dfa_t re_dfa_t;
33 struct re_dfastate_t {
34 re_node_set nodes;
35 };
36 typedef struct re_dfastate_t re_dfastate_t;
37 typedef struct {
38 re_dfastate_t **array;
39 } state_array_t;
40 typedef struct {
41 state_array_t path;
42 } re_sub_match_last_t;
43 typedef struct {
44 int nlasts;
45 re_sub_match_last_t **lasts;
46 } re_sub_match_top_t;
47 typedef struct {
48 re_string_t input;
49 const re_dfa_t *dfa;
50 int nsub_tops;
51 re_sub_match_top_t **sub_tops;
52 } re_match_context_t;
53 struct re_dfa_t {
54 re_token_t *nodes;
55 re_bitset_ptr_t sb_char;
56 int mb_cur_max;
57 bitset_t word_char;
58 } bracket_elem_t;
59 static reg_errcode_t
re_string_reconstruct(re_string_t * pstr,int idx,int eflags)60 re_string_reconstruct (
61 re_string_t * pstr,
62 int idx,
63 int eflags
64 )
65 {
66 int offset = idx - pstr->raw_mbs_idx;
67 int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1];
68 pstr->tip_context = ((pstr->word_char[c] & ((bitset_word_t) 1)) ? : (c));
69 }
70
71 static void match_ctx_clean (
72 re_match_context_t *
73 );
74 static int check_matching (
75 );
76 static re_dfastate_t *transit_state (
77 );
78 static int build_trtable (
79 );
re_search_internal(int eflags)80 re_search_internal (int eflags
81 )
82 {
83 reg_errcode_t err;
84 int incr;
85 int
86 match_first,
87 match_last = -1;
88 re_match_context_t mctx;
89 err = re_string_allocate (&mctx.input);
90 for (;; match_first += incr)
91 {
92 err = re_string_reconstruct (&mctx.input, match_first, eflags);
93 err = re_string_reconstruct (&mctx.input, match_first, eflags);
94 match_last = check_matching (&mctx, &match_first);
95 match_ctx_clean (&mctx);
96 }
97 }
98
check_matching(re_match_context_t * mctx,int * p_match_first)99 check_matching (re_match_context_t * mctx, int *p_match_first
100 )
101 {
102 int cur_str_idx = ((&mctx->input)->cur_idx);
103 re_dfastate_t *cur_state;
104 int next_start_idx = cur_str_idx;
105 cur_state = transit_state (mctx, cur_state);
106 *p_match_first += next_start_idx;
107 }
108
109 static re_dfastate_t *
transit_state(re_match_context_t * mctx,re_dfastate_t * state)110 transit_state (
111 re_match_context_t * mctx,
112 re_dfastate_t * state
113 )
114 {
115 if (!build_trtable (mctx->dfa, state))
116 {
117 }
118 }
119
build_trtable(const re_dfa_t * dfa,re_dfastate_t * state)120 build_trtable (const re_dfa_t * dfa,
121 re_dfastate_t * state
122 )
123 {
124 int i,
125 j;
126 bitset_t accepts;
127 const re_node_set *cur_nodes = &state->nodes;
128 for (i = 0; i < cur_nodes->nelem; ++i)
129 {
130 re_token_t *node = &dfa->nodes[cur_nodes->elems[i]];
131 re_token_type_t type = node->type;
132 {
133 if (dfa->mb_cur_max > 1)
134 bitset_merge (accepts, dfa->sb_char);
135 {
136 bitset_word_t any_set = 0;
137 if (type == CHARACTER && !node->word_char)
138 any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j]));
139 else
140 for (j = 0; j < (256 / (sizeof (bitset_word_t) * 8)); ++j)
141 any_set |= (accepts[j] &= dfa->word_char[j]);
142 }
143 }
144 }
145 }
146
147 static void
match_ctx_clean(re_match_context_t * mctx)148 match_ctx_clean (
149 re_match_context_t * mctx
150 )
151 {
152 int st_idx;
153 for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx)
154 {
155 int sl_idx;
156 re_sub_match_top_t *top = mctx->sub_tops[st_idx];
157 for (sl_idx = 0; sl_idx < top->nlasts; ++sl_idx)
158 {
159 re_sub_match_last_t *last = top->lasts[sl_idx];
160 free (last->path.array);
161 }
162 }
163 }
164
165