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 );
26 open FILE, $file or die "Could nod read $file ($!)\n";
34 while( defined( $line = <FILE> ) ) {
37 if( $line =~ /\*\// ) {
40 $line =~ s/^\s*\* ?//;
44 if( $line =~ /\*\// ) {
47 $line =~ s/^\s*\* ?//;
52 if( ( $line =~ /\S/ ) && ( defined $buff ) ) {
57 if( $head =~ /[;{]/ ) {
58 $head =~ s/\/\*.*?\*\///gs;
60 $head =~ s/([;{]).*/$1/;
61 print OUT $levelMark." + +++$head+++ +\n+\n$buff\n";
63 $levelMark = '*' unless( $markDepth ++ );
68 } elsif( my( $head, $comment ) = ( $line =~ /^(.*)\/\*\*(.*)\*\*\// ) ) {
70 $head =~ s/\/\*.*?\*\///gs;
72 $head =~ s/([;{]).*/$1/;
75 print OUT $levelMark." + +++$head+++ +\n+\n$comment\n\n";
77 $levelMark = '*' unless( $markDepth ++ );
79 } elsif( $line =~ /\}/ && $markDepth ) {
80 $levelMark = '-' unless( -- $markDepth );
81 } elsif( $line =~ /\/\*\*\*/ ) {
83 } elsif( $line =~ /\/\*\*/ ) {
92 while( defined( $line = <IN> ) ) {
94 if( my( $fname ) = ( $line =~ /^!!\s*(.*\S)/ ) ) {
95 $fname = "$basedir/$fname" if( ( $fname !~ /^\// ) && defined $basedir );
97 print DEP " $fname" if( $hasdep );
103 print DEP "\n" if( $hasdep );