elimHeaderDiffs.prl 3.14 KB
#!/usr/local/bin/perl5 -w
#
# Copyright (C) 1996-1998 by the Board of Trustees
#    of Leland Stanford Junior University.
# 
# This file is part of the SimOS distribution. 
# See LICENSE file for terms of the license. 
#

#####
##### script to generate a list of files that only differ (cvs diff)
##### for the $Author and $Date line in the heading comment
##### 
#####
##### Script does not do anything bad, but generates 
##### a script that either calls for a remove of the
##### files, or echos its name
#####
##### script should be called at the top of the simulation
##### tree.
#####
##### cvs diff  | elimHeaderDiffs.prl >list_of_files




$state = "nostate";
$numlines = 0;

sub MakeDecision {
    
    if ( $state eq "nostate" ) { 
        return; 
    }


    if ($state eq "remove") {
        if ($numlines <=12) {
            print "rm $file\n";
        } else {
            print "echo \"Keeping $file 'cause diff has $numlines lines\"\n";
        } 
    } else {
        print STDERR "Diff in $file: $reason \n";
        print "echo \"Real diffs in $file \"\n";
    }
    $numlines = 1000;
}

$hasIndex = 0;

while(<>) {
    $numlines++;
    if (/Index: (\S+)/) { 
       MakeDecision();
       $state = "remove";
       $file = $1;
       $numlines = 1;
       $hasIndex = 1;
   } elsif (/RCS file: \/hive\/cvsroot\/simulation\/(\S+)/)  {
       if (!$hasIndex) { 
          MakeDecision();
          $state = "remove";
          $file = $1;
	  chop($file); chop($file);
          $numlines = 1;
      }
    } elsif (/RCS file: (\S+)/) {
       if (!$hasIndex) { 
          MakeDecision();
          $state = "remove";
          $file = $1;
	  chop($file); chop($file);
          $numlines = 1;
       } 
       $hasIndex = 0;
    } elsif (/===================================================================/) { 
    } elsif (/retrieving revision (\S+)/) {
    } elsif (/diff -r(\d+).(\d+)/) {
    } elsif (/(\d+)c(\d+)/) { 
    } elsif (/(\d+),(\d+)c(\d+),(\d+)/) {

    } elsif (/(\S)   \$Revision:/) { 
    } elsif (/(\S)  \* \$Revision:/) { 

    } elsif (/(\S) \/\* \$Header:/) { 
    } elsif (/(\S)  \* \$Header:/) { 
    } elsif (/(\S)  \* rcsid \"\$Header:/) { 

    } elsif (/(\S)  \* \$Author:/) {
    } elsif (/(\S)  \* Author:    \$Author/) {
    } elsif (/(\S)  \* Author:    \$Author:/) { 
    } elsif (/(\S)  \* Author: \$Author:/) { 
    } elsif (/(\S)  \* Author:       \$Author:/) { 
    } elsif (/(\S)  \* Last Modified by: \$Author:/) {
    } elsif (/(\S)  \* Last modified by: \$Author/) {
    } elsif (/(\S)  \* Author:    \$Author:/) { 
    } elsif (/(\S) \# \$Author:/) { 
    } elsif (/(\S) \#\#\# \$Author:/) { 

    } elsif (/(\S)  \* Date: \$Date:/) { 
    } elsif (/(\S)  \* \$Date:/) { 
    } elsif (/(\S)  \* Date:      \$Date/) {
    } elsif (/(\S)  \* Date:   \$Date:/) { 
    } elsif (/(\S) \# \$Date:/) { 
    } elsif (/(\S) \#\#\# \$Date:/) { 

    } elsif (/(\S) \/\* \$Id:/) { 
    } elsif (/(\S)  \* \$Id:/) { 

    } elsif (/(\S) static char rcsid\[\] = \"\$Header:/) { 
    } elsif (/---/) { 
    } else {
        if ($state eq "remove") {
            chop($_);
            $reason = $_;
            $state = "keep";
        }
    }
}

MakeDecision();