[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    quality/krazy2/plugins/c++
From:       Allen Winter <winter () kde ! org>
Date:       2008-01-16 23:10:32
Message-ID: 1200525032.678985.9301.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 762409 by winterz:

skip C-style comments
skip #if 0 blocks
smarter 


 M  +25 -9     iconnames  


--- trunk/quality/krazy2/plugins/c++/iconnames #762408:762409
@@ -37,9 +37,12 @@
 
 use strict;
 use Getopt::Long;
+use FindBin qw($Bin);
+use lib "$Bin/../../../../lib";
+use Krazy::PreProcess;
 
 my($Prog) = "iconnames";
-my($Version) = "1.0";
+my($Version) = "1.1";
 
 my($help) = '';
 my($version) = '';
@@ -58,12 +61,24 @@
 &Explain() if $explain;
 if ($#ARGV != 0){ &Help(); exit 0; }
 
+my($f) = $ARGV[0];
+
+# open file and slurp it in (C++, non-headers only)
+if ($f =~ m/\.cpp$/ || $f =~ m/\.cxx$/ || $f =~ m/\.cc$/) {
+  open(F, "$f") || die "Couldn't open $f";
+} else {
+  print "okay\n" if (!$quiet);
+  exit 0;
+}
+my(@data_lines) = <F>;
+close(F);
+
+# Remove C-style comments and #if 0 blocks from the file input
+my(@lines) = RemoveIfZeroBlockC( RemoveCommentsC( @data_lines ) );
+
 # Check Condition
-my($f) = $ARGV[0];
-open(F, "$f") || die "Couldn't open $f";
 my($cnt) = 0;
 my($linecnt) = 0;
-my($line);
 my($lstr) = "";
 
 # this list is autogenerated based on the data in kdesdk/scripts/qt4/icons-kde3tokde4-renamer
@@ -1089,8 +1104,9 @@
 zip_unmountdf-odb
 };
 
-while ($line = <F>) {
-
+my($line);
+while ($linecnt < $#lines) {
+  $line = $lines[$linecnt++];
   if ($line =~ m+//.*[Kk]razy:excludeall=.*$Prog+ ||
       $line =~ m+//.*[Kk]razy:skip+) {
     $cnt = 0;
@@ -1099,9 +1115,9 @@
   next if ($line =~ m+//.*[Kk]razy:exclude=.*$Prog+);
   $line =~ s+//.*++;  #skip C++ comments
 
-  $linecnt++;
-  # does this cover everything? without any filtering we get too much noise unfortunately
-  if ( $line =~ m/icon/i || $line =~ m/pixmap/i ) {
+  # does this cover everything? without any filtering we get too much noise
+  if ( $line =~ m/Icon\s*\(/ || $line =~ m/iconPath\s*\(/ ||
+       $line =~ m/[Pp]ixmap/ ) {
     # FIXME: this fails for quoted quotes and god knows what else...
     my @strings = split( /\"/, $line );
     for ( my $i = 1; $i < $#strings; $i = $i + 2 ) {
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic