desc 1.78 KB
#!/bin/perl
#
#  Perl script to find comments for a particular
#  test case.
#

sub ParseIndexFile
{
  open(INDEXFILE, $IndexFile) || die "Couldn't open $IndexFile \n";
  while ($IndexInputLine = <INDEXFILE>)
    {
      if ($IndexInputLine =~ /^#$Dependency/) 
	{	    
	  print $IndexInputLine;
	}       
    }
  close(INDEXFILE);	
}				

sub ParseDependencyLine
{
  $ContinuedLine = 1;
  $InputLine =~ s/^.*:[ ]?//;

  while ($ContinuedLine)
    {
      @Dependencies = split(/[ \t\n]+/, $InputLine);
      foreach $j (0 .. $#Dependencies)
	{
	  $Dependency = $Dependencies[$j];
	  $Dependency =~ s/^.*\///;
	  $Dependency =~ s/\..*\\?$//;
	  
	  if ($Dependency =~ /inp/)
	    {
	      $IndexFile = "InData/index";	  
	      &ParseIndexFile;
	    }
	  elsif (($Dependency =~ /auto/) || ($Dependency =~ /hand/))
	    {
	      $IndexFile = "TmemData/index";
	      &ParseIndexFile;
	    }
	  elsif ($Dependency =~ /tile/)
	    {
	      $IndexFile = "TileData/index";
	      &ParseIndexFile;
	    }
	  elsif (($Dependency =~ /\\/) || ($Dependency =~ /^\s+$/) || (!$Dependency))
	    {
	    }
	  elsif (($Dependency =~ /tctm/) || ($Dependency =~ /\$\$@/))
	    {
	    }
	  else
	    {
	      print "Unrecognized index file ->$Dependency<- \n";
	    }			
	}

      if ($InputLine =~ /\\/)
	{
	  $InputLine = <MAKEFILE>;
	  $InputLine =~ s/^.*:[ ]?//;
	}
      else
	{
	  $ContinuedLine = 0;
	}      
    }
}

print "\n";

foreach $i (0 .. $#ARGV)
{    
  open(MAKEFILE, "Makefile") || die "Couldn't open Makefile \n";

  print "Description for $ARGV[$i]: \n";
  while ($InputLine = <MAKEFILE>)
    {				
      if ($InputLine =~ /^#$ARGV[$i]/) 
	{		       
	  print $InputLine;
	}
      elsif ($InputLine =~ /$ARGV[$i]:/)
	{
	  $InputLine = <MAKEFILE>;
	  &ParseDependencyLine;
	}
    }
  close(MAKEFILE);
  printf("\n");
}