#!/usr/bin/perl

# a simple script to remove comments and #line directives left by CTANGLE
# this allows one to build Makefiles and linker scripts from inside CWEB
# by making a few simple changes to the macros (to facilitate typeseting)
# and using CWEB's @= ... @> facility.

open FILE, "$ARGV[0]" or die "Cannot open input file $ARGV[0]\n";
open FILEOUT, ">$ARGV[1]" or die "Cannot open output file $ARGV[1]\n";

while (<FILE>) {

    $inline = $_;

    s/^(\#line.*)\n$//g; 

    if ( $ARGV[2] != 3 ) {

        s/\/\*.*\*\///g;

    }

    printf FILEOUT "%s", "$_"; 

#    if ( m/^.*\S.*\n$/ ) {

#	printf FILEOUT "%s", "$_"; 

#    }

}
