#!/usr/bin/perl -w
# checkdiff.pl -- 2.5-dj kernel patch checker.
#
# I'm stupid.
# This script sanity checks diffs before I put them out, so
# that hch doesn't have to remind me I goofed.

use strict;

my @lines;

foreach my $file (@ARGV) {
	process ($file)
		or warn "Couldn't check file $file: $!";
}

sub process {
	my $filename=shift;

	return undef unless $filename;

	open INPUT, $filename
		or return undef;

	while(!eof INPUT) {
		my $input=<INPUT>;
		chomp $input;
		push @lines, $input;
	}
	close INPUT;

my $linenr=0;

	foreach my $line (@lines) {

		$linenr++;

		if ($line=~/davej/ and $line=~/\$Id:/) {
			print "Found davej CVS damage at line $linenr\n$line\n\n";
		}

		# We are adding a line, check its not obsolete.
		if ($line=~/^\+/) {

			if ($line=~/iorequest_lock/) {
				print "Adding code to frob iorequest_lock at line $linenr\n$line\n\n";
			}

			if ($line=~/[	 ]MAJOR[ (]/) {
				print "Adding code to frob MAJOR at line $linenr\n$line\n\n";
			}

			if ($line=~/[	 ]MINOR[ (]/) {
				print "Adding code to frob MINOR at line $linenr\n$line\n\n";
			}

			if ($line=~/[	 ]MKDEV[ (]/) {
				print "Adding code to frob MKDEV at line $linenr\n$line\n\n";
			}

			if ($line=~/get_fast_time/) {
				print "Adding get_fast_time at line $linenr\n$line\n\n";
			}
		}
	}
}


