2016-08-19 11:09:23 -04:00
|
|
|
#!/usr/bin/perl
|
|
|
|
use strict;
|
|
|
|
use autodie;
|
|
|
|
use warnings;
|
|
|
|
use File::Compare;
|
|
|
|
use File::Basename;
|
|
|
|
no warnings 'once';
|
|
|
|
|
|
|
|
foreach my $file (@ARGV) {
|
|
|
|
if (-e $file) {
|
|
|
|
my $data = process_file($file);
|
|
|
|
open(MYOUTPUTFILE, "+>$file.bak") or die "Error opening output file $!";
|
|
|
|
print MYOUTPUTFILE $data;
|
|
|
|
close(MYOUTPUTFILE);
|
|
|
|
if (compare($file, "$file.bak") != 0) {
|
|
|
|
print "Processed $file\n";
|
|
|
|
}
|
|
|
|
unlink $file;
|
|
|
|
rename "$file.bak", $file;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
sub process_file {
|
|
|
|
my($filename) = "$_[0]";
|
|
|
|
open(MYINPUTFILE, "<$filename") or die "x $!";
|
|
|
|
my($data) = "";
|
|
|
|
while(<MYINPUTFILE>) {
|
|
|
|
s/\s*$//;
|
|
|
|
my($line) = $_;
|
|
|
|
if($line !~ /^\s*$/) {
|
|
|
|
$data = $data . "$line\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(MYINPUTFILE);
|
|
|
|
chomp($data);
|
|
|
|
if ($data !~ /^\s*\/\*\*/) {
|
|
|
|
my $basename = basename($filename);
|
|
|
|
$data = "/**\n * \@file $basename\n * \@author Austen Adler (agadler)\n * TODO: Description\n */\n$data";
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
2016-08-19 11:10:32 -04:00
|
|
|
#sub process_comment {
|
|
|
|
# # The data string
|
|
|
|
# my $data = $_[0];
|
|
|
|
# # Is the author line in there?
|
|
|
|
# my $author = 0;
|
|
|
|
# # Is the description there?
|
|
|
|
# my $desc = 0;
|
|
|
|
# # Is the first name there?
|
|
|
|
# my $fname = 0;
|
|
|
|
# # Are we still in the top comment area?
|
|
|
|
# my $incomment = 1;
|
|
|
|
# # If there is no top comment in the beginning, add the base comment
|
|
|
|
# if ($data !~ /^\s*\/\*\*/) {
|
|
|
|
# $data = "/**\n * \@file $filename\n * \@author Austen Adler (agadler)\n * TODO: Description\n */\n$data";
|
|
|
|
# $author = 1;
|
|
|
|
# $desc = 1;
|
|
|
|
# $fname = 1;
|
|
|
|
# } else {
|
|
|
|
# # Otherwise process an existing comment
|
|
|
|
# while ($incomment) {
|
|
|
|
# if (/\s*\*\//) {
|
|
|
|
# $incomment = 0;
|
|
|
|
# } elsif (/\s*\* \@author/) {
|
|
|
|
# } elsif (/\s*\* \@file $filename/) {
|
|
|
|
# } elsif (/\s*\* \@author/) {
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
# }
|
|
|
|
# return $data;
|
|
|
|
#}
|