tools/bulk_marking.pl
changeset 92 458d62869c00
parent 82 e044daaa1848
child 99 e23a8d7ea8bb
--- a/tools/bulk_marking.pl	Wed Oct 27 15:24:40 2010 +0100
+++ b/tools/bulk_marking.pl	Wed Oct 27 15:25:50 2010 +0100
@@ -16,17 +16,22 @@
 use strict;
 use Getopt::Long;
 
-my $marking;
+my $newcmd = "";
 my $who;
+my $marking;
+my $other_exes = 0;
 GetOptions(
+  "c|command=s" => \$newcmd,    # value for the What colum (can be blank)
   "m|message=s" => \$marking,   # comment to add to the CSV lines
   "u|user=s" => \$who,          # value for the Who column
+  "x" => \$other_exes,          # marking is applied to exes NOT listed
   );
 
 die("must specify a value for the Why column with the -m option") if (!defined $marking);
 die("must specify a value for the Who column with the -u option") if (!defined $who);
 
 my %romfiles;
+my $mark_count = 0;
 my $line;
 while ($line=<>)
 	{
@@ -34,25 +39,56 @@
 	if ($line =~ /^\S+\t\S+\t(\S+)/)
 		{
 		my $romfile = $1;
-		$romfiles{$romfile} = 1;
+		$romfiles{lc $romfile} = 1;
 		next;
 		}
 
 	my ($romfile,$hostfile,$ibyfile,$package,$cmd,@rest) = split /,/, $line;
-	next if (!defined $cmd);
-	
-	if (defined $romfiles{$romfile})
+	if (!defined $cmd)
 		{
-		if ($cmd eq "")
+		if ($other_exes && $line =~ /^(\S+)$/)
 			{
-			# mark this one
-			print join(",", $romfile,$hostfile,$ibyfile,$package,"",$who,$marking), "\n";
-			next;
+			# guess that this is a preserved filename
+			my $exe = "sys\\bin\\". lc $1;
+			$romfiles{$exe} = 1;
+			# print STDERR "Preserving $exe\n";
 			}
-		else
+		next;
+		}
+	
+	if ($cmd ne "")
+		{
+		print $line;	# already marked, so leave it alone
+		next;
+		}
+
+	my $mark_me = 0;
+	if ($other_exes)
+		{
+		if ($romfile =~ /^sys.bin.(.*)$/i)
 			{
-			print STDERR "Skipping $romfile line - already marked as $cmd,",join(",", @rest);
+			# this is an exe - are we tagging it?
+			if (!defined $romfiles{lc $romfile})
+				{
+				# print STDERR "Marking $romfile\n";
+				$mark_me = 1;
+				}
 			}
 		}
-	print $line;
+	elsif (defined $romfiles{lc $romfile})
+		{
+		$mark_me = 1;
+		}
+
+	if ($mark_me)
+		{
+		$mark_count += 1;
+		print join(",", $romfile,$hostfile,$ibyfile,$package,$newcmd,$who,$marking), "\n";
+		}
+	else
+		{
+		print $line;
+		}
 	}
+
+print STDERR "Marked $mark_count lines\n";