|
Packit |
0848f5 |
#! /usr/bin/env perl
|
|
Packit |
0848f5 |
# -*- Mode: perl; -*-
|
|
Packit |
0848f5 |
# Tested with -w 10/28/05
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# Find the parse.sub routine.
|
|
Packit |
0848f5 |
my $maintdir = "./maint";
|
|
Packit |
0848f5 |
my $rootdir = ".";
|
|
Packit |
0848f5 |
if ( ! -s "maint/parse.sub" ) {
|
|
Packit |
0848f5 |
my $program = $0;
|
|
Packit |
0848f5 |
$program =~ s/^.*[\/\\]//;
|
|
Packit |
0848f5 |
if (-s "$program/parse.sub") {
|
|
Packit |
0848f5 |
$maintdir = $program;
|
|
Packit |
0848f5 |
$rootdir = $program;
|
|
Packit |
0848f5 |
$rootdir =~ s/\/maint//g;
|
|
Packit |
0848f5 |
print "Rootdir = $rootdir\n" if $debug;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
require "$maintdir/parse.sub";
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
$debug = 0;
|
|
Packit |
0848f5 |
$showfiles = 0;
|
|
Packit |
0848f5 |
$quiet = 0;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
$textOutput = 1;
|
|
Packit |
0848f5 |
$htmlOutput = 0;
|
|
Packit |
0848f5 |
$htmlFullpage = 0;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
# Strict is used to control checking of error message strings.
|
|
Packit |
0848f5 |
$gStrict = 0;
|
|
Packit |
0848f5 |
if (defined($ENV{"DEBUG_STRICT"})) { $gStrict = 1; }
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
# Check for special args
|
|
Packit |
0848f5 |
@files = ();
|
|
Packit |
0848f5 |
%skipFiles = ();
|
|
Packit |
0848f5 |
foreach $arg (@ARGV) {
|
|
Packit |
0848f5 |
if ($arg =~ /^-showfiles/) { $showfiles = 1; }
|
|
Packit |
0848f5 |
elsif( $arg =~ /-debug/) { $debug = 1; }
|
|
Packit |
0848f5 |
elsif( $arg =~ /-quiet/) { $quiet = 1; }
|
|
Packit |
0848f5 |
elsif( $arg =~ /-html/) { $textOutput = 0;
|
|
Packit |
0848f5 |
$htmlOutput = 1; $htmlFullpage = 1; }
|
|
Packit |
0848f5 |
elsif( $arg =~ /-skip=(.*)/) { $skipFiles{$1} = 1; }
|
|
Packit |
0848f5 |
else {
|
|
Packit |
0848f5 |
print "Adding $arg to files\n" if $debug;
|
|
Packit |
0848f5 |
if (-d $arg) {
|
|
Packit |
0848f5 |
# Add all .c files from directory $arg to the list of files
|
|
Packit |
0848f5 |
# to process (this lets shorten the arg list)
|
|
Packit |
0848f5 |
@files = (@files, &ExpandDir( $arg ));
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
else {
|
|
Packit |
0848f5 |
$files[$#files+1] = $arg;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
# Be nice to Windows
|
|
Packit |
0848f5 |
$eol = "\r\n";
|
|
Packit |
0848f5 |
if ($htmlOutput) {
|
|
Packit |
0848f5 |
if ($htmlFullpage) {
|
|
Packit |
0848f5 |
print STDOUT "<html><head><title>FIXME Items for MPICH</title></head>$eol";
|
|
Packit |
0848f5 |
print STDOUT "<body bgcolor=\"ffffff\">$eol";
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
print STDOUT "$eol";
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
# Process the definitions
|
|
Packit |
0848f5 |
foreach $file (@files) {
|
|
Packit |
0848f5 |
print "$file\n" if $showfiles;
|
|
Packit |
0848f5 |
&ProcessFile( $file );
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
if ($htmlOutput) {
|
|
Packit |
0848f5 |
print STDOUT "$eol";
|
|
Packit |
0848f5 |
if ($htmlFullpage) {
|
|
Packit |
0848f5 |
print STDOUT "</body></html>$eol";
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
#-----------------------------------------------------------------------------
|
|
Packit |
0848f5 |
# ROUTINES
|
|
Packit |
0848f5 |
# ----------------------------------------------------------------------------
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
# ==========================================================================
|
|
Packit |
0848f5 |
# Call this for each file
|
|
Packit |
0848f5 |
# This reads a C source or header file and adds does the following:
|
|
Packit |
0848f5 |
# adds any generic message short names encountered to the hash generic_msgs.
|
|
Packit |
0848f5 |
# adds any specific message short names encounter to the hash specific_msgs.
|
|
Packit |
0848f5 |
# adds the filename to the hash generic_loc{msg} as the value (: separated)
|
|
Packit |
0848f5 |
# and the same for hash specific_loc{msg}.
|
|
Packit |
0848f5 |
# The last two are used to provide better error reporting.
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
$filename = ""; # Make global so that other routines can echo filename
|
|
Packit |
0848f5 |
$comment_line = "";
|
|
Packit |
0848f5 |
sub ProcessFile
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
# Leave filename global for AddTest
|
|
Packit |
0848f5 |
$filename = $_[0];
|
|
Packit |
0848f5 |
open (FD, "<$filename" ) || die "Could not open $filename\n";
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
while (<FD>) {
|
|
Packit |
0848f5 |
# Look for /* FIXME
|
|
Packit |
0848f5 |
while (/\/\*\s[Ff][Ii][Xx][Mm][Ee]/) {
|
|
Packit |
0848f5 |
$comment_line = "";
|
|
Packit |
0848f5 |
$_ = StripComments( FD, $_ );
|
|
Packit |
0848f5 |
# Comment is in $comment_line
|
|
Packit |
0848f5 |
$comment_line =~ s/\/\*\s*[Ff][Ii][Xx][Mm][Ee]:?\s*//;
|
|
Packit |
0848f5 |
$comment_line =~ s/\s*\*\///;
|
|
Packit |
0848f5 |
&PrintFIXME( $filename, $comment_line );
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
close FD;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
# Get all of the .c files from the named directory, including any subdirs
|
|
Packit |
0848f5 |
sub ExpandDir {
|
|
Packit |
0848f5 |
my $dir = $_[0];
|
|
Packit |
0848f5 |
my @otherdirs = ();
|
|
Packit |
0848f5 |
my @files = ();
|
|
Packit |
0848f5 |
opendir DIR, "$dir";
|
|
Packit |
0848f5 |
while ($filename = readdir DIR) {
|
|
Packit |
0848f5 |
if ($filename =~ /^\./ || $filename eq ".svn") {
|
|
Packit |
0848f5 |
next;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
elsif (-d "$dir/$filename") {
|
|
Packit |
0848f5 |
$otherdirs[$#otherdirs+1] = "$dir/$filename";
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
elsif ($filename =~ /(.*\.[chi])$/) {
|
|
Packit |
0848f5 |
# Test for both Unix- and Windows-style directory separators
|
|
Packit |
0848f5 |
if (!defined($skipFiles{"$dir/$filename"}) &&
|
|
Packit |
0848f5 |
!defined($skipFiles{"dir\\$filename"})) {
|
|
Packit |
0848f5 |
$files[$#files + 1] = "$dir/$filename";
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
closedir DIR;
|
|
Packit |
0848f5 |
# (almost) tail recurse on otherdirs (we've closed the directory handle,
|
|
Packit |
0848f5 |
# so we don't need to worry about it anymore)
|
|
Packit |
0848f5 |
foreach $dir (@otherdirs) {
|
|
Packit |
0848f5 |
@files = (@files, &ExpandDir( $dir ) );
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
return @files;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
sub PrintFIXME {
|
|
Packit |
0848f5 |
my ($filename, $comment_line ) = @_;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
# Some fixmes start with fixme - ; remove the - in that case.
|
|
Packit |
0848f5 |
$comment_line =~ s/^\s*[:-]\s*//;
|
|
Packit |
0848f5 |
if ($textOutput) {
|
|
Packit |
0848f5 |
print STDOUT $filename . ":";
|
|
Packit |
0848f5 |
foreach my $line (split(/\r?\n/,$comment_line)) {
|
|
Packit |
0848f5 |
# Remote any leading blanks or *
|
|
Packit |
0848f5 |
$line =~ s/^\s*//;
|
|
Packit |
0848f5 |
$line =~ s/^\*\s?//g;
|
|
Packit |
0848f5 |
print $line . "\n";
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
elsif ($htmlOutput) {
|
|
Packit |
0848f5 |
# HTMLify the line
|
|
Packit |
0848f5 |
if ($comment_line =~ /--AMP--/) {
|
|
Packit |
0848f5 |
print STDERR "Comment line contains --AMP--\n";
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
else {
|
|
Packit |
0848f5 |
$comment_line =~ s/&/--AMP--amp;/g;
|
|
Packit |
0848f5 |
$comment_line =~ s/</--AMP--lt;/g;
|
|
Packit |
0848f5 |
$comment_line =~ s/>/--AMP--gt;/g;
|
|
Packit |
0848f5 |
$comment_line =~ s/--AMP--/&/;;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
print STDOUT "$filename";
|
|
Packit |
0848f5 |
my $nl = "";
|
|
Packit |
0848f5 |
foreach my $line (split(/\r?\n/,$comment_line)) {
|
|
Packit |
0848f5 |
# Remote any leading blanks or *
|
|
Packit |
0848f5 |
$line =~ s/^\s*//;
|
|
Packit |
0848f5 |
$line =~ s/^\*\s?//g;
|
|
Packit |
0848f5 |
print $nl . $line;
|
|
Packit |
0848f5 |
$nl = " $eol";
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
print STDOUT " $eol"
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
else {
|
|
Packit |
0848f5 |
print STDERR "Unknown output form\n";
|
|
Packit |
0848f5 |
exit(1);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|