diff options
author | Explorer09 <explorer09@gmail.com> | 2017-07-08 18:54:30 +0800 |
---|---|---|
committer | Will Estes <westes575@gmail.com> | 2017-07-13 15:15:29 -0400 |
commit | 0f370436e1cf0c731e74bcee806df6c7a43a3094 (patch) | |
tree | 0c981f012f005d594e46114d93865a7db6964eaf /src | |
parent | 19cffb0ff001e24a278ab979ac7a49f788ab2eba (diff) |
filter: new internal function is_blank_line()
It's simply to return (regexec(®ex_blank_line, str, 0, NULL, 0) == 0);
The reason for encapsulation is to allow replacing this with a
non-regex method if necessary.
Diffstat (limited to 'src')
-rw-r--r-- | src/filter.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/filter.c b/src/filter.c index 35b80a9..fd1bb40 100644 --- a/src/filter.c +++ b/src/filter.c @@ -324,6 +324,11 @@ int filter_tee_header (struct filter *chain) return 0; } +static bool is_blank_line (const char *str) +{ + return (regexec (®ex_blank_line, str, 0, NULL, 0) == 0); +} + /** Adjust the line numbers in the #line directives of the generated scanner. * After the m4 expansion, the line numbers are incorrect since the m4 macros * can add or remove lines. This only adjusts line numbers for generated code, @@ -395,9 +400,7 @@ int filter_fix_linedirs (struct filter *chain) } /* squeeze blank lines from generated code */ - else if (in_gen - && regexec (®ex_blank_line, buf, 0, NULL, - 0) == 0) { + else if (in_gen && is_blank_line(buf)) { if (last_was_blank) continue; else |