regex parser was not properly reset before each file, sometimes resulting in wrong line counts, when the previous scanned file ended with a match

Mon, 19 Mar 2018 16:36:14 +0100

author
Mike Becker <universe@uap-core.de>
date
Mon, 19 Mar 2018 16:36:14 +0100
changeset 54
76d46533b9a9
parent 53
32b9e0a5cebd
child 55
b19e73926a28

regex parser was not properly reset before each file, sometimes resulting in wrong line counts, when the previous scanned file ended with a match

src/regex_parser.c file | annotate | diff | comparison | revisions
src/regex_parser.h file | annotate | diff | comparison | revisions
src/scanner.c file | annotate | diff | comparison | revisions
     1.1 --- a/src/regex_parser.c	Thu Jun 01 17:33:34 2017 +0200
     1.2 +++ b/src/regex_parser.c	Mon Mar 19 16:36:14 2018 +0100
     1.3 @@ -43,6 +43,10 @@
     1.4    return ret;
     1.5  }
     1.6  
     1.7 +void regex_parser_reset(regex_parser_t* parser) {
     1.8 +  parser->pattern_match = parser->matched_lines = 0;
     1.9 +}
    1.10 +
    1.11  void regex_destcomppats(regex_parser_t* parser) {
    1.12    if (parser->compiled_patterns != NULL) {
    1.13      for (int i = 0 ; i < parser->compiled_pattern_count ; i++) {
     2.1 --- a/src/regex_parser.h	Thu Jun 01 17:33:34 2017 +0200
     2.2 +++ b/src/regex_parser.h	Mon Mar 19 16:36:14 2018 +0100
     2.3 @@ -54,6 +54,7 @@
     2.4  
     2.5  regex_parser_t* new_regex_parser_t();
     2.6  void destroy_regex_parser_t(regex_parser_t*);
     2.7 +void regex_parser_reset(regex_parser_t* parser);
     2.8  
     2.9  bool regex_parser_matching(regex_parser_t*);
    2.10  bool regex_compile_all(regex_parser_t*);
     3.1 --- a/src/scanner.c	Thu Jun 01 17:33:34 2017 +0200
     3.2 +++ b/src/scanner.c	Mon Mar 19 16:36:14 2018 +0100
     3.3 @@ -163,6 +163,7 @@
     3.4          lines = 0;
     3.5          bfile = false;
     3.6          bfile_reset(settings->bfileHeuristics);
     3.7 +        regex_parser_reset(settings->regex);
     3.8          char line_buffer[REGEX_MAX_LINELENGTH];
     3.9          int line_buffer_offset = 0;
    3.10  

mercurial