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;
29 print OUT "..................\n";
31 print OUT "..................\n\n";
32 print OUT "$comment\n\n";
37 open FILE, $file or die "Could nod read $file ($!)\n";
44 while( defined( $line = <FILE> ) ) {
49 formatNote( $head, $buff );
54 } elsif( $verbatim ) {
55 if( $line =~ /\*\// ) {
59 $line =~ s/^\s*\* ?//;
63 if( $line =~ /\*\// ) {
66 $line =~ s/^\s*\* ?//;
70 if( ( $line =~ /\S/ ) && ( defined $buff ) ) {
71 if( $line =~ /\(/ || $line !~ /{/ ) {
77 formatNote( $_, $buff );
84 } elsif( ( $buff ) = ( $line =~ /\/\*\*\*(.*)\*\*\*\// ) ) {
86 print OUT "$buff\n\n";
88 } elsif( ( $head, $buff ) = ( $line =~ /^(.*)\/\*\*(.*)\*\*\// ) ) {
91 if( $head =~ /\(/ || $head !~ /{/ ) {
93 $head =~ s/\/\*.*?\*\///gs;
95 formatNote( $head, $buff );
101 } elsif( $line =~ /\/\*\*\*/ ) {
103 } elsif( $line =~ /\/\*\*/ ) {
112 while( defined( $line = <IN> ) ) {
114 if( my( $fname ) = ( $line =~ /^!!\s*(.*\S)/ ) ) {
115 $fname = "$basedir/$fname" if( ( $fname !~ /^\// ) && defined $basedir );
117 print DEP " $fname" if( $hasdep );
123 print DEP "\n" if( $hasdep );