@echo off
perl -x -S %0.bat "%1" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "%9"
goto endofperl
#! /usr/bin/perl
# For DOS perl 5 the previous comment is REQUIRED!  This comment may be deleted.

# Copyright 1991 by Norman Ramsey.  All rights reserved.
# See file COPYRIGHT for more information.
#
# These perl scripts were written by Phil Miller by directly
# copying Norman's shell scripts.  I, Phil Miller, relinquish all rights
# to Norman, and I also take no responsibility.
$NOLIB = $ENV{'NOLIB'};
$DIRSEP = $ENV{'DIRSEP'};
$LIB = "";
if ( $DIRSEP eq "/" && $NOLIB ne "" ) { 
   $LIB = $NOLIB . $DIRSEP;
   $ENV{'PATH'} = $ENV{'PATH'} . ":" . $NOLIB;
}
if ( $NOLIB eq "" ) {
   print STDERR "notangle:  trying to proceed with ENV{'NOLIB'} undefined.\n";
}
if ( $DIRSEP eq "" ) {
   print STDERR "notangle:  trying to proceed with ENV{'DIRSEP'} undefined.\n";
}
$markup = $LIB . "markup";
while ( $ARGV[0] ) {
   $argin = $ARGV[0];
   shift;
   if ( $argin =~ /(-ml|-m3|-awk|-icn|-icon|-pascal|-c|-c\+\+|-f77|-f90|-tex|-w[0-9][0-9]* )$/ ) {
      ; # deliberately ignore nountangle args
   }
   elsif ( $argin eq "-t" ) { ; } # this is the default
   elsif ( $argin =~ /-t(.+)/ ) {
      $markopt = "$markopt -t";
      $opt = "$opt $argin";
   }
   elsif ( $argin eq "-markup" ) { $markup = $ARGV[0]; shift; }
   elsif ( $argin eq "-cppline" ) {$opt = "$opt -L\"#line %L \\\"%F\\\"%N\""; }
   elsif ( $argin eq "-" ) { $arg = "$arg -"; }
   elsif ( $argin =~ "-(.+)" ) { $opt = "$opt $argin";}
   else { $arg = "$arg $argin"; }
}

# If we are outputting a -L #line directive, can't just let nt substitute %F
# for us, because it outputs it with path specification in win32 format
# (e.g. ".\foo.nw") which is NOT valid for CPP #line directives!
$farg = "$arg";
$farg =~ s/^\s+//;
$farg =~ s!\\!/!g;
$opt =~ s/%F/$farg/;

$notanglecmd = "$markup $markopt $arg | $filters $LIB" . "nt $opt";
print STDERR "notangle:  $notanglecmd\n";
print `$notanglecmd`;


__END__
:endofperl

