mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
dfa: don't clear states, just mark dfa dead
The previous change caused some assertion issues.
This commit is contained in:
parent
3d4d39b8a9
commit
75e4aefabe
@ -59,6 +59,7 @@
|
|||||||
#include "dfa_min.h"
|
#include "dfa_min.h"
|
||||||
|
|
||||||
#include "grey.h"
|
#include "grey.h"
|
||||||
|
#include "mcclellancompile_util.h"
|
||||||
#include "rdfa.h"
|
#include "rdfa.h"
|
||||||
#include "ue2common.h"
|
#include "ue2common.h"
|
||||||
#include "util/container.h"
|
#include "util/container.h"
|
||||||
@ -299,6 +300,10 @@ void minimize_hopcroft(raw_dfa &rdfa, const Grey &grey) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_dead(rdfa)) {
|
||||||
|
DEBUG_PRINTF("dfa is empty\n");
|
||||||
|
}
|
||||||
|
|
||||||
UNUSED const size_t states_before = rdfa.states.size();
|
UNUSED const size_t states_before = rdfa.states.size();
|
||||||
|
|
||||||
HopcroftInfo info(rdfa);
|
HopcroftInfo info(rdfa);
|
||||||
|
@ -964,6 +964,8 @@ bytecode_ptr<NFA> mcclellanCompile_i(raw_dfa &raw, accel_dfa_build_strat &strat,
|
|||||||
const CompileContext &cc,
|
const CompileContext &cc,
|
||||||
bool trust_daddy_states,
|
bool trust_daddy_states,
|
||||||
set<dstate_id_t> *accel_states) {
|
set<dstate_id_t> *accel_states) {
|
||||||
|
assert(!is_dead(raw));
|
||||||
|
|
||||||
u16 total_daddy = 0;
|
u16 total_daddy = 0;
|
||||||
dfa_info info(strat);
|
dfa_info info(strat);
|
||||||
bool using8bit = cc.grey.allowMcClellan8 && info.size() <= 256;
|
bool using8bit = cc.grey.allowMcClellan8 && info.size() <= 256;
|
||||||
|
@ -197,7 +197,6 @@ bool clear_deeper_reports(raw_dfa &raw, u32 max_offset) {
|
|||||||
return ds.reports.empty() && ds.reports_eod.empty();
|
return ds.reports.empty() && ds.reports_eod.empty();
|
||||||
})) {
|
})) {
|
||||||
DEBUG_PRINTF("no reports left at all, dfa is dead\n");
|
DEBUG_PRINTF("no reports left at all, dfa is dead\n");
|
||||||
raw.states.clear();
|
|
||||||
raw.start_anchored = DEAD_STATE;
|
raw.start_anchored = DEAD_STATE;
|
||||||
raw.start_floating = DEAD_STATE;
|
raw.start_floating = DEAD_STATE;
|
||||||
}
|
}
|
||||||
@ -287,4 +286,9 @@ bool can_die_early(const raw_dfa &raw, u32 age_limit) {
|
|||||||
return can_die_early(raw, raw.start_anchored, visited, age_limit);
|
return can_die_early(raw, raw.start_anchored, visited, age_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_dead(const raw_dfa &rdfa) {
|
||||||
|
return rdfa.start_anchored == DEAD_STATE &&
|
||||||
|
rdfa.start_floating == DEAD_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ue2
|
} // namespace ue2
|
||||||
|
@ -59,6 +59,13 @@ size_t hash_dfa(const raw_dfa &rdfa);
|
|||||||
|
|
||||||
bool can_die_early(const raw_dfa &raw, u32 age_limit);
|
bool can_die_early(const raw_dfa &raw, u32 age_limit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Returns true if this DFA cannot match, i.e. its start state is
|
||||||
|
* DEAD_STATE.
|
||||||
|
*/
|
||||||
|
bool is_dead(const raw_dfa &rdfa);
|
||||||
|
|
||||||
|
|
||||||
} // namespace ue2
|
} // namespace ue2
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user