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" } { "" } } */
8 typedef unsigned long int bitset_word_t
;
9 typedef bitset_word_t bitset_t
[(256 / (sizeof (bitset_word_t
) * 8))];
10 typedef bitset_word_t
*re_bitset_ptr_t
;
11 typedef const bitset_word_t
*re_const_bitset_ptr_t
;
20 re_token_type_t type
:8;
21 unsigned int word_char
:1;
24 const unsigned char *raw_mbs
;
27 unsigned int tip_context
;
28 re_const_bitset_ptr_t word_char
;
30 typedef struct re_string_t re_string_t
;
31 typedef struct re_dfa_t re_dfa_t
;
32 struct re_dfastate_t
{
35 typedef struct re_dfastate_t re_dfastate_t
;
37 re_dfastate_t
**array
;
41 } re_sub_match_last_t
;
44 re_sub_match_last_t
**lasts
;
50 re_sub_match_top_t
**sub_tops
;
54 re_bitset_ptr_t sb_char
;
59 re_string_reconstruct (
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
));
70 static void match_ctx_clean (
73 static int check_matching (
75 static re_dfastate_t
*transit_state (
77 static int build_trtable (
79 re_search_internal (int eflags
87 re_match_context_t mctx
;
88 err
= re_string_allocate (&mctx
.input
);
89 for (;; match_first
+= incr
)
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
);
98 check_matching (re_match_context_t
* mctx
, int *p_match_first
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
;
108 static re_dfastate_t
*
110 re_match_context_t
* mctx
,
111 re_dfastate_t
* state
114 if (!build_trtable (mctx
->dfa
, state
))
119 build_trtable (const re_dfa_t
* dfa
,
120 re_dfastate_t
* state
126 const re_node_set
*cur_nodes
= &state
->nodes
;
127 for (i
= 0; i
< cur_nodes
->nelem
; ++i
)
129 re_token_t
*node
= &dfa
->nodes
[cur_nodes
->elems
[i
]];
130 re_token_type_t type
= node
->type
;
132 if (dfa
->mb_cur_max
> 1)
133 bitset_merge (accepts
, dfa
->sb_char
);
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
]));
139 for (j
= 0; j
< (256 / (sizeof (bitset_word_t
) * 8)); ++j
)
140 any_set
|= (accepts
[j
] &= dfa
->word_char
[j
]);
148 re_match_context_t
* mctx
152 for (st_idx
= 0; st_idx
< mctx
->nsub_tops
; ++st_idx
)
155 re_sub_match_top_t
*top
= mctx
->sub_tops
[st_idx
];
156 for (sl_idx
= 0; sl_idx
< top
->nlasts
; ++sl_idx
)
158 re_sub_match_last_t
*last
= top
->lasts
[sl_idx
];
159 free (last
->path
.array
);