[PATCH] winapi: Skip #if 0 sections.
They are typically used as 'super comments' and may not contain C code. They are also typically not nested so this ignores nesting. Signed-off-by: Francois Gouget <fgouget(a)free.fr> --- tools/winapi/winapi_parser.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/winapi/winapi_parser.pm b/tools/winapi/winapi_parser.pm index 0ad7057a0e3..941fdfe5a0b 100644 --- a/tools/winapi/winapi_parser.pm +++ b/tools/winapi/winapi_parser.pm @@ -244,7 +244,21 @@ sub parse_c_file($$) { # remove preprocessor directives if(s/^\s*\#/\#/s) { - if(/^(\#.*?)\\$/s) { + if (/^#\s*if\s+0\s*$/ms) { + # Skip #if 0 ... #endif sections entirely. + # They are typically used as 'super comments' and may not + # contain C code. This totally ignores nesting. + if(s/^(\s*#\s*if\s+0\s*\n.*?\n\s*#\s*endif\s*)\n//s) { + my @lines = split(/\n/, $1); + $_ = "\n" x $#lines; + &$preprocessor_found_callback("if", "0"); + $again = 1; + } else { + $lookahead = 1; + } + next readmore; + } + elsif(/^(\#.*?)\\$/s) { $_ = "$1\n"; $lookahead = 1; next; -- 2.20.1
participants (1)
-
Francois Gouget