Francois Gouget : winapi: Skip #if 0 sections.

Alexandre Julliard julliard at winehq.org
Tue Apr 14 16:15:27 CDT 2020


Module: wine
Branch: master
Commit: 1c9077f13d32c6b30ac474c52068822525201c36
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=1c9077f13d32c6b30ac474c52068822525201c36

Author: Francois Gouget <fgouget at free.fr>
Date:   Tue Apr 14 16:57:12 2020 +0200

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 at free.fr>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 ca4cef4267..37038371b2 100644
--- a/tools/winapi/winapi_parser.pm
+++ b/tools/winapi/winapi_parser.pm
@@ -240,7 +240,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;




More information about the wine-cvs mailing list