lkml.org 
[lkml]   [2011]   [Feb]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: rename_rev.pl script for reviewing renames
On Thu, Feb 03, 2011 at 11:22:19AM +0100, Wolfram Sang wrote:
> On Thu, Feb 03, 2011 at 01:08:28PM +0300, Dan Carpenter wrote:
> > There are a lot of refactoring patches where people change camel case
> > names to kernel style names etc. I've written a script to make it
> > easier to review them. It's attached.
>
> Cool, thanks for sharing. I guess my comments won't matter much, here
> they are anyway :)
>

Thanks for the review. I made the changes.

regards,
dan carpenter
#!/usr/bin/perl

use File::Temp qw/ :mktemp /;

sub usage() {
print "usage: cat diff | $0 old new old new old new...\n";
exit(1);
}

my @subs;

sub filter($) {
my $line = shift();

foreach my $sub (@subs) {
$line =~ s/$sub->[0]/$sub->[1]/g;
}

# remove the first char
$line =~ s/^[ +-]//;

return $line;
}

($oldfh, $oldfile) = mkstemp("/tmp/oldXXXXX");
($newfh, $newfile) = mkstemp("/tmp/newXXXXX");

while (my $param1 = shift()) {
my $param2 = shift;

if ($param2 =~ /^$/) {
usage();
}
push @subs, [$param1, $param2];
}

while (<>) {
my $line = $_;

if ($line =~ /^(---|\+\+\+)/) {
next;
}

my $output = filter($line);
if ($line =~ /^-/) {
print $oldfh $output;
next;
}
if ($line =~ /^\+/) {
print $newfh $output;
next;
}
print $oldfh $output;
print $newfh $output;
}

system("diff -uw $oldfile $newfile");

unlink($oldfile);
unlink($newfile);
\
 
 \ /
  Last update: 2011-02-03 11:53    [W:0.175 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site