Fixed several major bugs

This commit is contained in:
Андреев Григорий 2024-08-05 03:36:13 +03:00
parent e3ae909253
commit 2a4d2feed2
6 changed files with 18 additions and 13 deletions

View File

@ -14,7 +14,7 @@ struct Libregexis024BuildSystem {
"-Wno-unused-but-set-variable", "-Wno-reorder"};
std::vector<std::string> version_flags = {"--std", "c++14", "-D", "_POSIX_C_SOURCE=200809L"};
std::vector<std::string> debug_defines_release = {};
std::vector<std::string> debug_defines_release = {"_GLIBCXX_DEBUG"};
std::vector<std::string> debug_defines_debug = {"_GLIBCXX_DEBUG", "LIBREGEXIS024_DEBUG", "LIBREGEXIS024_ALLOW_LOUD"};
std::vector<std::string> opt_flags_release = {"-g", "-O2"};
std::vector<std::string> opt_flags_debug = {"-g", "-ggdb", "-O0"};

View File

@ -56,6 +56,7 @@ namespace regexis024 {
if (leader >= 0){
ret_is_multicode = false;
ret_set = codeset_of_one_char(leader);
readChar(ctx);
} else {
report(ctx, "backslash in the wrong place");
}

View File

@ -8,19 +8,9 @@
namespace regexis024 {
struct SubtrackingNameUsageInfo: public TrackingVariableInfo{
bool stored_in_ca = true;
bool stored_in_sa = false;
bool discovered = false;
tracking_var_type_t type;
/* These fields will be -1 if unused */
int colarr_first = -1;
int colarr_second = -1;
bool used_in_sifting = false;
bool minimizing = false;
int selarr_first = -1;
int selarr_second = -1;
};
struct KnownTrackingTools {

View File

@ -51,6 +51,17 @@ void boba(const vector<pair<string, bool>>& input, const string& pattern) {
}
int main() {
#define reg_ALPHA "[a-zA-Z]"
#define reg_pchar "([a-zA-Z0-9\\-._~\\!$\\&'()*+@:,;=]|%[0-9a-hA-H]!r{2})"
#define reg_query "(" reg_pchar"|[?/])*"
#define reg_lin_ws "([ \t]|\r\n[ \t])*"
#define reg_request_line "#method(" reg_ALPHA"+) #uri_path(/(" reg_pchar"|/)*)(\\?#uri_query(" reg_query"))? HTTP/#http_version(!digit;+.!digit;+)\r\n"
#define reg_filed_value "(" reg_lin_ws"#header_field_value_part([\\u0021-\\u007e&^\r\n]+))*" reg_lin_ws
#define reg_HTTP_message reg_request_line "(#header_field_name([\\u0021-\\u007E&^:]+):" reg_filed_value "\r\n)*\r\n"
test("P /aa?:: HTTP/1.1\r\nr--r: qwe\r\n\r\n", reg_HTTP_message, MatchInfo(
{{0, 0}, {1, 1}, {2, 2}, {3, 5}, {4, 6}, {5, 8}, {6, 14}, {7, 17}, {8, 19}, {9, 23}, {10, 25}, {11, 28}}, {}));
test("d3", "[abc]3", MatchInfo());
boba({{"", true}, {"a", false}}, "");
boba({{"", true}, {"a", true}, {"aab", true}, {"aac", false}, {"c", false}, {"abbababa", true}}, "[ab]*");
test("", "", MatchInfo({}, {}));
@ -58,10 +69,8 @@ int main() {
test("1b", "1\\<b", MatchInfo({}, {}));
test("bababbaa", "[ab]*", MatchInfo({}, {}));
test("bababbaa", "!dfa;[ab]*", MatchInfo({}, {}));
test("d3", "[abc]3", MatchInfo());
test("a3", "[abc]3", MatchInfo({}, {}));
test("abba", "!select{M{max}}a#M(b*)a", MatchInfo({}, {1, 3}));
test("LINE\r\nFirst:Second\r\nThird:12\r\n\r\n",
"!dfa;!select{fieldname{ca}fieldbody{ca}}LINE\r\n(#fieldname([\\u0021-\\u007E&^:]+):#fieldbody([\\u0000-\\u007F&^\r\n]*)\r\n)*\r\n",
MatchInfo({{0, 6}, {1, 11}, {2, 12}, {3, 18}, {0, 20}, {1, 25}, {2, 26}, {3, 28}}, {20, 25, 26, 28}));

View File

@ -48,6 +48,9 @@ namespace regexis024 {
return -1;
}
cur_text_pos += adj;
if (cur_text_pos < input.size() && !vm.haveSurvivors()) {
return 0;
}
}
assert(vm.isUsable());
if (vm.isMatched()) {

View File

@ -162,6 +162,8 @@ namespace regexis024 {
if (ctx.initialized){
ctx.timer = 0;
ctx.CAN_total = 0;
ctx.passed_bytes = 0;
ctx.passed_chars = 0;
while (!ctx.READ_halted_stack_new.empty()){
Thread& thread = ctx.READ_halted_slots[ctx.READ_halted_stack_new.pop()];
assert(thread.slot_occupation_status & SLOT_OCCUPIED);