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-require-effective-target fpic } */
4 /* { dg-skip-if "Incompatible command line options: -mfloat-abi=soft -mfloat-abi=hard" { *-*-* } { "-mfloat-abi=hard" } { "" } } */
5 /* { dg-require-effective-target arm_arch_v5te_thumb_ok } */
10 typedef unsigned long int bitset_word_t
;
11 typedef bitset_word_t bitset_t
[(256 / (sizeof (bitset_word_t
) * 8))];
12 typedef bitset_word_t
*re_bitset_ptr_t
;
13 typedef const bitset_word_t
*re_const_bitset_ptr_t
;
22 re_token_type_t type
:8;
23 unsigned int word_char
:1;
26 const unsigned char *raw_mbs
;
29 unsigned int tip_context
;
30 re_const_bitset_ptr_t word_char
;
32 typedef struct re_string_t re_string_t
;
33 typedef struct re_dfa_t re_dfa_t
;
34 struct re_dfastate_t
{
37 typedef struct re_dfastate_t re_dfastate_t
;
39 re_dfastate_t
**array
;
43 } re_sub_match_last_t
;
46 re_sub_match_last_t
**lasts
;
52 re_sub_match_top_t
**sub_tops
;
56 re_bitset_ptr_t sb_char
;
61 re_string_reconstruct (
67 int offset
= idx
- pstr
->raw_mbs_idx
;
68 int c
= pstr
->raw_mbs
[pstr
->raw_mbs_idx
+ offset
- 1];
69 pstr
->tip_context
= ((pstr
->word_char
[c
] & ((bitset_word_t
) 1)) ? : (c
));
72 static void match_ctx_clean (
75 static int check_matching (
77 static re_dfastate_t
*transit_state (
79 static int build_trtable (
81 re_search_internal (int eflags
89 re_match_context_t mctx
;
90 err
= re_string_allocate (&mctx
.input
);
91 for (;; match_first
+= incr
)
93 err
= re_string_reconstruct (&mctx
.input
, match_first
, eflags
);
94 err
= re_string_reconstruct (&mctx
.input
, match_first
, eflags
);
95 match_last
= check_matching (&mctx
, &match_first
);
96 match_ctx_clean (&mctx
);
100 check_matching (re_match_context_t
* mctx
, int *p_match_first
103 int cur_str_idx
= ((&mctx
->input
)->cur_idx
);
104 re_dfastate_t
*cur_state
;
105 int next_start_idx
= cur_str_idx
;
106 cur_state
= transit_state (mctx
, cur_state
);
107 *p_match_first
+= next_start_idx
;
110 static re_dfastate_t
*
112 re_match_context_t
* mctx
,
113 re_dfastate_t
* state
116 if (!build_trtable (mctx
->dfa
, state
))
121 build_trtable (const re_dfa_t
* dfa
,
122 re_dfastate_t
* state
128 const re_node_set
*cur_nodes
= &state
->nodes
;
129 for (i
= 0; i
< cur_nodes
->nelem
; ++i
)
131 re_token_t
*node
= &dfa
->nodes
[cur_nodes
->elems
[i
]];
132 re_token_type_t type
= node
->type
;
134 if (dfa
->mb_cur_max
> 1)
135 bitset_merge (accepts
, dfa
->sb_char
);
137 bitset_word_t any_set
= 0;
138 if (type
== CHARACTER
&& !node
->word_char
)
139 any_set
|= (accepts
[j
] &= (dfa
->word_char
[j
] | ~dfa
->sb_char
[j
]));
141 for (j
= 0; j
< (256 / (sizeof (bitset_word_t
) * 8)); ++j
)
142 any_set
|= (accepts
[j
] &= dfa
->word_char
[j
]);
150 re_match_context_t
* mctx
154 for (st_idx
= 0; st_idx
< mctx
->nsub_tops
; ++st_idx
)
157 re_sub_match_top_t
*top
= mctx
->sub_tops
[st_idx
];
158 for (sl_idx
= 0; sl_idx
< top
->nlasts
; ++sl_idx
)
160 re_sub_match_last_t
*last
= top
->lasts
[sl_idx
];
161 free (last
->path
.array
);