winapi_check: Print the line number when an error or warning is found in the API files.

Francois Gouget fgouget at free.fr
Fri Jan 26 06:21:54 CST 2007


---

It's a pain when winapi_check complains about a problem in the win32.api 
file but give no hint as to where the problem is...

 tools/winapi/winapi.pm |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/winapi/winapi.pm b/tools/winapi/winapi.pm
index 53b7465..8fcaa41 100644
--- a/tools/winapi/winapi.pm
+++ b/tools/winapi/winapi.pm
@@ -139,7 +139,9 @@ sub parse_api_file($$) {
 
     open(IN, "< $winapi_dir/$file") || die "$winapi_dir/$file: $!\n";
     $/ = "\n";
+    my $linenum=0;
     while(<IN>) {
+        $linenum++;
 	s/^\s*?(.*?)\s*$/$1/; # remove whitespace at begin and end of line
 	s/^(.*?)\s*#.*$/$1/;  # remove comments
 	/^$/ && next;         # skip empty lines
@@ -193,12 +195,12 @@ sub parse_api_file($$) {
 	    if(!$forbidden) {
 		if(defined($module)) {
 		    if($$allowed_modules_unlimited{$type}) {
-			$output->write("$file: type ($type) already specified as an unlimited type\n");
+			$output->write("$file:$linenum: type ($type) already specified as an unlimited type\n");
 		    } elsif(!$$allowed_modules{$type}{$module}) {
 			$$allowed_modules{$type}{$module} = 1;
 			$$allowed_modules_limited{$type} = 1;
 		    } else {
-			$output->write("$file: type ($type) already specified\n");
+			$output->write("$file:$linenum: type ($type) already specified\n");
 		    }
 		} else {
 		    $$allowed_modules_unlimited{$type} = 1;
@@ -207,14 +209,14 @@ sub parse_api_file($$) {
 		$$allowed_modules_limited{$type} = 1;
 	    }
 	    if(defined($$translate_argument{$type}) && $$translate_argument{$type} ne $kind) {
-		$output->write("$file: type ($type) respecified as different kind ($kind != $$translate_argument{$type})\n");
+		$output->write("$file:$linenum: type ($type) respecified as different kind ($kind != $$translate_argument{$type})\n");
 	    } else {
 		$$translate_argument{$type} = $kind;
 	    }
 
 	    $$type_format{$module}{$type} = $format;
 	} else {
-	    $output->write("$file: file must begin with %<type> statement\n");
+	    $output->write("$file:$linenum: file must begin with %<type> statement\n");
 	    exit 1;
 	}
     }
-- 
1.4.4.3




More information about the wine-patches mailing list