[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: quality/krazy2/plugins/c++
From: Bertjan Broeksema <b.broeksema () home ! nl>
Date: 2008-10-02 21:43:11
Message-ID: 1222983791.171307.19975.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 867140 by bbroeksema:
Make the postfixop check be a bit less complainer. When the identifier is of an
elementary type it won't complain now anymore. This should reduce the number of
complains somewhat.
M +10 -2 postfixop
--- trunk/quality/krazy2/plugins/c++/postfixop #867139:867140
@@ -87,14 +87,19 @@
next if ($line =~ m+//.*[Kk]razy:exclude=.*$Prog+);
$line =~ s+//.*++; #skip C++ comments
- if ($line =~ m/\w+(\+\+|\-\-)\s*(;|\))/) {
+ if ($line =~ m/(\w+)(\+\+|\-\-)\s*(;|\))/) {
# NOTE: For now we only check in for loops as there is quite a big danger
# that when we expose all postfix usage of ++ and -- to the developers
# that a great deal of off-by-one-errors and what not more are introduced.
# It is (almost?) always safe to change postfix usage in for loops.
#
- if ( &searchBack('^\s*for\s*\(',$linecnt,3) ) {
+ my($identifier) = $1;
+
+ if (&searchBack( '^\s*for\s*\(', $linecnt, 3 )) {
+ # Don't complain when the type of the iterator is of an elementary type.
+ next if (&searchBack( '(int|uint|long|unsigned\sint|ulong)\s'.$identifier, $linecnt, 3));
next if ($line =~ m/(\+\+|\-\-)\s*;\s*$/); # no semis in a for loop
+
$cnt++;
if ($cnt == 1) {
$lstr = "line\#" . $linecnt;
@@ -134,6 +139,7 @@
sub searchBack {
my($p,$l,$n) = @_;
my($i);
+
$n = $#lines if ($#lines < $n);
for($i=1; $i<=$n; $i++) {
if ($lines[$l-$i] =~ $p) {
@@ -142,3 +148,5 @@
}
return 0;
}
+
+# kate: space-indent on;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic