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