# HG changeset patch # User Mike Becker # Date 1521473774 -3600 # Node ID 76d46533b9a946bd8c65b697110aae502ad65759 # Parent 32b9e0a5cebd9baed975603cce93d03ec2a7cbe6 regex parser was not properly reset before each file, sometimes resulting in wrong line counts, when the previous scanned file ended with a match diff -r 32b9e0a5cebd -r 76d46533b9a9 src/regex_parser.c --- a/src/regex_parser.c Thu Jun 01 17:33:34 2017 +0200 +++ b/src/regex_parser.c Mon Mar 19 16:36:14 2018 +0100 @@ -43,6 +43,10 @@ return ret; } +void regex_parser_reset(regex_parser_t* parser) { + parser->pattern_match = parser->matched_lines = 0; +} + void regex_destcomppats(regex_parser_t* parser) { if (parser->compiled_patterns != NULL) { for (int i = 0 ; i < parser->compiled_pattern_count ; i++) { diff -r 32b9e0a5cebd -r 76d46533b9a9 src/regex_parser.h --- a/src/regex_parser.h Thu Jun 01 17:33:34 2017 +0200 +++ b/src/regex_parser.h Mon Mar 19 16:36:14 2018 +0100 @@ -54,6 +54,7 @@ regex_parser_t* new_regex_parser_t(); void destroy_regex_parser_t(regex_parser_t*); +void regex_parser_reset(regex_parser_t* parser); bool regex_parser_matching(regex_parser_t*); bool regex_compile_all(regex_parser_t*); diff -r 32b9e0a5cebd -r 76d46533b9a9 src/scanner.c --- a/src/scanner.c Thu Jun 01 17:33:34 2017 +0200 +++ b/src/scanner.c Mon Mar 19 16:36:14 2018 +0100 @@ -163,6 +163,7 @@ lines = 0; bfile = false; bfile_reset(settings->bfileHeuristics); + regex_parser_reset(settings->regex); char line_buffer[REGEX_MAX_LINELENGTH]; int line_buffer_offset = 0;