1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
#! /usr/bin/env perl
##
## Copyright (C) by Argonne National Laboratory
## See COPYRIGHT in top-level directory
##
# Tested with -w 10/28/05
#
# Find the parse.sub routine.
my $maintdir = "./maint";
my $rootdir = ".";
if ( ! -s "maint/parse.sub" ) {
my $program = $0;
$program =~ s/^.*[\/\\]//;
if (-s "$program/parse.sub") {
$maintdir = $program;
$rootdir = $program;
$rootdir =~ s/\/maint//g;
print "Rootdir = $rootdir\n" if $debug;
}
}
require "$maintdir/parse.sub";
$debug = 0;
$showfiles = 0;
$quiet = 0;
$textOutput = 1;
$htmlOutput = 0;
$htmlFullpage = 0;
# Strict is used to control checking of error message strings.
$gStrict = 0;
if (defined($ENV{"DEBUG_STRICT"})) { $gStrict = 1; }
# Check for special args
@files = ();
%skipFiles = ();
foreach $arg (@ARGV) {
if ($arg =~ /^-showfiles/) { $showfiles = 1; }
elsif( $arg =~ /-debug/) { $debug = 1; }
elsif( $arg =~ /-quiet/) { $quiet = 1; }
elsif( $arg =~ /-html/) { $textOutput = 0;
$htmlOutput = 1; $htmlFullpage = 1; }
elsif( $arg =~ /-skip=(.*)/) { $skipFiles{$1} = 1; }
else {
print "Adding $arg to files\n" if $debug;
if (-d $arg) {
# Add all .c files from directory $arg to the list of files
# to process (this lets shorten the arg list)
@files = (@files, &ExpandDir( $arg ));
}
else {
$files[$#files+1] = $arg;
}
}
}
# Be nice to Windows
$eol = "\r\n";
if ($htmlOutput) {
if ($htmlFullpage) {
print STDOUT "<html><head><title>FIXME Items for MPICH</title></head>$eol";
print STDOUT "<body bgcolor=\"ffffff\">$eol";
}
print STDOUT "<table><tr><th width=20%>File</th><th>FIXME Note</th></tr>$eol";
}
# Process the definitions
foreach $file (@files) {
print "$file\n" if $showfiles;
&ProcessFile( $file );
}
if ($htmlOutput) {
print STDOUT "</table>$eol";
if ($htmlFullpage) {
print STDOUT "</body></html>$eol";
}
}
#-----------------------------------------------------------------------------
# ROUTINES
# ----------------------------------------------------------------------------
# ==========================================================================
# Call this for each file
# This reads a C source or header file and adds does the following:
# adds any generic message short names encountered to the hash generic_msgs.
# adds any specific message short names encounter to the hash specific_msgs.
# adds the filename to the hash generic_loc{msg} as the value (: separated)
# and the same for hash specific_loc{msg}.
# The last two are used to provide better error reporting.
#
$filename = ""; # Make global so that other routines can echo filename
$comment_line = "";
sub ProcessFile
{
# Leave filename global for AddTest
$filename = $_[0];
open (FD, "<$filename" ) || die "Could not open $filename\n";
while (<FD>) {
# Look for /* FIXME
while (/\/\*\s[Ff][Ii][Xx][Mm][Ee]/) {
$comment_line = "";
$_ = StripComments( FD, $_ );
# Comment is in $comment_line
$comment_line =~ s/\/\*\s*[Ff][Ii][Xx][Mm][Ee]:?\s*//;
$comment_line =~ s/\s*\*\///;
&PrintFIXME( $filename, $comment_line );
}
}
close FD;
}
# Get all of the .c files from the named directory, including any subdirs
sub ExpandDir {
my $dir = $_[0];
my @otherdirs = ();
my @files = ();
opendir DIR, "$dir";
for $filename (sort readdir DIR) {
if ($filename =~ /^\./ || $filename eq ".svn") {
next;
}
elsif (-d "$dir/$filename") {
$otherdirs[$#otherdirs+1] = "$dir/$filename";
}
elsif ($filename =~ /(.*\.[chi])$/) {
# Test for both Unix- and Windows-style directory separators
if (!defined($skipFiles{"$dir/$filename"}) &&
!defined($skipFiles{"dir\\$filename"})) {
$files[$#files + 1] = "$dir/$filename";
}
}
}
closedir DIR;
# (almost) tail recurse on otherdirs (we've closed the directory handle,
# so we don't need to worry about it anymore)
foreach $dir (@otherdirs) {
@files = (@files, &ExpandDir( $dir ) );
}
return @files;
}
sub PrintFIXME {
my ($filename, $comment_line ) = @_;
# Some fixmes start with fixme - ; remove the - in that case.
$comment_line =~ s/^\s*[:-]\s*//;
if ($textOutput) {
print STDOUT $filename . ":";
foreach my $line (split(/\r?\n/,$comment_line)) {
# Remote any leading blanks or *
$line =~ s/^\s*//;
$line =~ s/^\*\s?//g;
print $line . "\n";
}
}
elsif ($htmlOutput) {
# HTMLify the line
if ($comment_line =~ /--AMP--/) {
print STDERR "Comment line contains --AMP--\n";
}
else {
$comment_line =~ s/&/--AMP--amp;/g;
$comment_line =~ s/</--AMP--lt;/g;
$comment_line =~ s/>/--AMP--gt;/g;
$comment_line =~ s/--AMP--/&/g;
}
print STDOUT "<tr><td valign=\"top\">$filename</td><td>";
my $nl = "";
foreach my $line (split(/\r?\n/,$comment_line)) {
# Remote any leading blanks or *
$line =~ s/^\s*//;
$line =~ s/^\*\s?//g;
print $nl . $line;
$nl = "<br>$eol";
}
print STDOUT "<br></td></tr>$eol"
}
else {
print STDERR "Unknown output form\n";
exit(1);
}
}
|