2006-01-08 05:15:08 -05:00
|
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
use strict;
|
|
|
|
|
use warnings;
|
|
|
|
|
use diagnostics;
|
|
|
|
|
|
2006-01-08 17:57:14 -05:00
|
|
|
|
print "Usage: $0 [FILE]\n\tParses [FILE], outputing the result to stdout.\n"
|
2006-01-08 05:15:08 -05:00
|
|
|
|
and exit if not @ARGV;
|
|
|
|
|
|
|
|
|
|
my ($input) = @ARGV;
|
2006-01-08 15:54:00 -05:00
|
|
|
|
my ($found, $start, $first, $gotone);
|
2006-01-08 05:15:08 -05:00
|
|
|
|
print "Copyleft<66> 2006, Russ Rowan (See `COPYING')\n" and exit if $input eq '-v';
|
|
|
|
|
open FILEIN, "<$input" or print "File `$input' was not found.\n" and exit;
|
|
|
|
|
while (<FILEIN>)
|
|
|
|
|
{
|
|
|
|
|
if ($found)
|
|
|
|
|
{
|
2006-01-08 13:05:11 -05:00
|
|
|
|
if ($_ =~ /^\s+\*\s$/) { next if $first; $_ =~ s/\s\*// if not $first; }
|
2006-01-08 05:15:08 -05:00
|
|
|
|
if ($_ =~ /^\s\*+\/$/ or $_ !~ /^\s/) { $found = undef; next; }
|
|
|
|
|
$_ =~ s/^(\s*)\s\*\s/$1/;
|
2006-01-08 17:42:04 -05:00
|
|
|
|
$found = 'sorta' if $_ =~ s/\s*\*\/$/\n/; $first = undef;
|
2006-01-08 05:15:08 -05:00
|
|
|
|
}
|
|
|
|
|
elsif ($_ =~ /^\s*\/\*\*\s(.*)/)
|
|
|
|
|
{
|
2006-01-08 16:20:46 -05:00
|
|
|
|
$_ = $1; $first = 1;
|
2006-01-08 17:57:14 -05:00
|
|
|
|
print STDOUT "\n\n" if $start;
|
2006-01-08 05:15:08 -05:00
|
|
|
|
if ($_ =~ s/\s*\*\/$//) { $found = 'sorta'; } else { $found = $.; }
|
2006-01-08 15:37:03 -05:00
|
|
|
|
if ($_ =~ /::/) { $_ = "$_\n\n"; }
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
my $dash; for (my $x = 0; $x < length($_); $x++) { $dash .= '-'; }
|
|
|
|
|
$_ = "$_\n$dash\n\n";
|
|
|
|
|
}
|
2006-01-08 05:15:08 -05:00
|
|
|
|
}
|
2006-01-08 17:42:04 -05:00
|
|
|
|
elsif ($_ =~ /\s*([A-Z0-9_]+)(\s+=\s+[0-9]+)?,\s*\/\*::\s*(.*)\s+\*\/$/)
|
2006-01-08 05:15:08 -05:00
|
|
|
|
{
|
2006-01-08 17:57:14 -05:00
|
|
|
|
print STDOUT "\n" if $gotone;
|
2006-01-08 17:42:04 -05:00
|
|
|
|
$_ =~ s/\s*([A-Z0-9_]+)(\s+=\s+[0-9]+|),\s*\/\*::\s*(.*)\s+\*\/$/id[$1]::\n $3/;
|
2006-01-08 16:20:46 -05:00
|
|
|
|
$found = 'sorta'; $gotone = $.;
|
2006-01-08 05:15:08 -05:00
|
|
|
|
}
|
2006-01-08 17:57:14 -05:00
|
|
|
|
print STDOUT "\n" and $gotone = undef if $gotone and $gotone < $.;
|
2006-01-08 05:15:08 -05:00
|
|
|
|
next if not $found; $found = undef if $found eq 'sorta';
|
2006-01-08 17:57:14 -05:00
|
|
|
|
print STDOUT $_ and $start = 1;
|
2006-01-08 05:15:08 -05:00
|
|
|
|
}
|
|
|
|
|
close FILEIN;
|