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/[\t ]+/ /g;
29 print OUT "..................\n";
31 print OUT "..................\n\n";
32 print OUT "$comment\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 =~ /\*\// ) {
58 $line =~ s/^\s*\* ?//;
62 if( $line =~ /\*\// ) {
65 $line =~ s/^\s*\* ?//;
70 if( ( $line =~ /\S/ ) && ( defined $buff ) ) {
71 if( $line =~ /\(/ || $line !~ /{/ ) {
77 formatNote( $_, $buff );
84 } elsif( ( $head, $buff ) = ( $line =~ /^(.*)\/\*\*(.*)\*\*\// ) ) {
87 if( $head =~ /\(/ || $head !~ /{/ ) {
89 $head =~ s/\/\*.*?\*\///gs;
90 $head =~ s/([;{]).*/$1/;
91 formatNote( $head, $buff );
97 } elsif( $line =~ /\/\*\*\*/ ) {
99 } elsif( $line =~ /\/\*\*/ ) {
108 while( defined( $line = <IN> ) ) {
110 if( my( $fname ) = ( $line =~ /^!!\s*(.*\S)/ ) ) {
111 $fname = "$basedir/$fname" if( ( $fname !~ /^\// ) && defined $basedir );
113 print DEP " $fname" if( $hasdep );
119 print DEP "\n" if( $hasdep );