# Currently, only single include nesting is supported. The included file is
# not processed for additional =include statements.
-require 5.006;
+require 5.00503;
use Cwd qw(getcwd);
use File::Basename qw(dirname basename);
my $start = getcwd;
for my $file (@ARGV) {
chdir $start or die "cannot chdir to $start: $!\n";
+ $file =~ s:\\:/:g if $^O eq 'cygwin';
my $dir = dirname ($file);
my $out = $file;
unless ($out =~ s/\.in\z//) {
die "input file $file does not end in .in\n";
}
- open (FILE, '<', $file) or die "cannot open $file: $!\n";
- open (OUT, '>', $out) or die "cannot open $out: $!\n";
+ open (FILE, "< $file") or die "cannot open $file: $!\n";
+ binmode FILE, ':crlf' if $^O eq 'MSWin32';
+ binmode FILE, ':crlf' if $^O eq 'cygwin';
+ open (OUT, "> $out") or die "cannot open $out: $!\n";
chdir $dir or die "cannot chdir to $dir: $!\n";
local $/ = '';
local $_;
while (<FILE>) {
if (/^=include\s+(\S+)/) {
- open (INCLUDE, '<', $1) or die "cannot open $1: $!\n";
+ open (INCLUDE, "< $1") or die "cannot open $1: $!\n";
local $/;
print OUT <INCLUDE> or die "cannot read/write from $1: $!\n";
close INCLUDE or die "cannot read from $1: $!\n";