nhsub bug fixes
This commit is contained in:
+19
-5
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
# nhsub
|
# nhsub
|
||||||
# $NHDT-Date: 1427913635 2015/04/01 18:40:35 $
|
# $NHDT-Date: 1427408239 2015/03/26 22:17:19 $
|
||||||
|
|
||||||
# Note: was originally called nhdate; the rename is not reflected in the code.
|
# Note: was originally called nhdate; the rename is not reflected in the code.
|
||||||
|
|
||||||
@@ -87,13 +87,13 @@ if ($^O eq "MSWin32")
|
|||||||
$PDS = '\\';
|
$PDS = '\\';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my @rawlist = &cmdparse(@ARGV);
|
||||||
|
push(@rawlist,'.') if($#rawlist == -1);
|
||||||
|
|
||||||
# pick up the prefix for substitutions in this repo
|
# pick up the prefix for substitutions in this repo
|
||||||
my $PREFIX = &git_config('nethack','substprefix');
|
my $PREFIX = &git_config('nethack','substprefix');
|
||||||
print "PREFIX: '$PREFIX'\n" if($opt{v});
|
print "PREFIX: '$PREFIX'\n" if($opt{v});
|
||||||
|
|
||||||
my @rawlist = &cmdparse(@ARGV);
|
|
||||||
push(@rawlist,'.') if($#rawlist == -1);
|
|
||||||
|
|
||||||
while(@rawlist){
|
while(@rawlist){
|
||||||
my $raw = shift @rawlist;
|
my $raw = shift @rawlist;
|
||||||
if(-f $raw){
|
if(-f $raw){
|
||||||
@@ -201,7 +201,21 @@ my $count = s/\$$PREFIX-(([A-Za-z][A-Za-z0-9_]*)(: ([^\x24]+))?)\$/&handlevar($2
|
|||||||
|
|
||||||
my $ofile = $file . ".nht";
|
my $ofile = $file . ".nht";
|
||||||
open(TOUT, ">", $ofile) or die "Can't open $ofile";
|
open(TOUT, ">", $ofile) or die "Can't open $ofile";
|
||||||
die "write failed: $!" unless defined syswrite(TOUT, $_);
|
|
||||||
|
#XXX MUST add a loop here
|
||||||
|
# die "write failed: $!" unless defined syswrite(TOUT, $_);
|
||||||
|
my $offset = 0;
|
||||||
|
my $sent;
|
||||||
|
#print STDERR "L=",length,"\n";
|
||||||
|
while($offset < length){
|
||||||
|
$sent = syswrite(TOUT, $_, (length($_) - $offset), $offset);
|
||||||
|
die "write failed: $!" unless defined($sent);
|
||||||
|
#print STDERR "rv=$sent\n";
|
||||||
|
last if($sent == (length($_) - $offset));
|
||||||
|
$offset += $sent;
|
||||||
|
#print STDERR "loop: O=$offset\n";
|
||||||
|
}
|
||||||
|
|
||||||
close TOUT or die "Can't close $ofile";
|
close TOUT or die "Can't close $ofile";
|
||||||
rename $ofile, $file or die "Can't rename $ofile to $file";
|
rename $ofile, $file or die "Can't rename $ofile to $file";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user