[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[Libvir] [PATCH] Print line numbers in unnecessary-if-before-free check
- From: Mark McLoughlin <markmc redhat com>
- To: mark skynet ie
- Cc:
- Subject: [Libvir] [PATCH] Print line numbers in unnecessary-if-before-free check
- Date: Thu, 07 Feb 2008 09:51:40 +0000
The unnecessary-if-before-free doesn't currently print line
numbers, which is a little annoying.
This patch fixes that with some rather hideous perl hacking.
I should have known to let well enough alone rather than
dredge up my long forgotten perl knowledge :-)
Signed-off-by: Mark McLoughlin <markmc redhat com>
Index: libvirt/build-aux/find-unnecessary-if-before-free
===================================================================
--- libvirt.orig/build-aux/find-unnecessary-if-before-free 2008-02-07 09:24:08.000000000 +0000
+++ libvirt/build-aux/find-unnecessary-if-before-free 2008-02-07 09:29:16.000000000 +0000
@@ -18,15 +18,20 @@
{
open FH, '<', $file
or die "$ME: can't open `$file' for reading: $!\n";
+ my $i = 1;
while (defined (my $line = <FH>))
{
- if ($line =~
+ my @matches = ($line =~
/\b(if\s*\(\s*(\S+?)(?:\s*!=\s*NULL)?\s*\)
- \s+(?:xmlXPathFreeContext|(?:sexpr_)?free)\s*\(\s*\2\s*\))/sx)
+ \s+(?:xmlXPathFreeContext|(?:sexpr_)?free)\s*\(\s*\2\s*\))/sx);
+
+ if (@matches)
{
- print "$file: $1\n";
+ my $j = $i + (my @a = split(/\n/, substr($line, 0, index($line, $matches[0])))) - 1;
+ print "$file:$j $1\n";
$found_match = 1;
}
+ $i += (my @a = split(/\n/, $line)) - 1;
}
close FH;
}
--
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]