5 my( $inname, $outname, $depname, $basedir ) = @ARGV;
6 if( defined $inname ) {
7 open IN, $inname or die "Could not read $inname ($!)\n";
9 open IN, "<&STDIN" or die "Could not read stdin ($!)\n";
11 if( defined $outname ) {
12 open OUT, ">$outname" or die "Could not write $outname ($!)\n";
14 open OUT, ">&STDOUT" or die "Could not write to stdout ($!)\n";
17 if( defined $depname ) {
18 open DEP, ">>$depname" or die "Could not write $depname ($!)\n";
22 print DEP "$outname:" if( $hasdep );
24 sub formatNote( $$ ) {
25 my( $head, $comment ) = @_;
26 $head =~ s/(\S)[ ]+/$1 /g;
30 if($head =~ /\w+\([^()]*\)/ && $head !~ /\n/) {
31 print OUT "!!f!$head!!!\n\n";
33 print OUT "..................\n";
35 print OUT "..................\n\n";
37 print OUT "$comment\n\n";
42 open FILE, $file or die "Could nod read $file ($!)\n";
49 while( defined( $line = <FILE> ) ) {
54 formatNote( $head, $buff );
59 } elsif( $verbatim ) {
60 if( $line =~ /\*\// ) {
64 $line =~ s/^\s*\* ?//;
68 if( $line =~ /\*\// ) {
71 $line =~ s/^\s*\* ?//;
75 if( ( $line =~ /\S/ ) && ( defined $buff ) ) {
76 if( $line =~ /\(/ || $line !~ /{/ ) {
82 formatNote( $_, $buff );
89 } elsif( ( $buff ) = ( $line =~ /\/\*\*\*(.*)\*\*\*\// ) ) {
91 print OUT "$buff\n\n";
93 } elsif( ( $head, $buff ) = ( $line =~ /^(.*)\/\*\*(.*)\*\*\// ) ) {
96 if( $head =~ /\(/ || $head !~ /{/ ) {
98 $head =~ s/\/\*.*?\*\///gs;
100 formatNote( $head, $buff );
106 } elsif( $line =~ /\/\*\*\*/ ) {
108 } elsif( $line =~ /\/\*\*/ ) {
117 while( defined( $line = <IN> ) ) {
119 if( my( $fname ) = ( $line =~ /^!!\s*(.*\S)/ ) ) {
120 $fname = "$basedir/$fname" if( ( $fname !~ /^\// ) && defined $basedir );
122 print DEP " $fname" if( $hasdep );
128 print DEP "\n" if( $hasdep );