tmpgv = gv_fetchpv(POPpx, FALSE, SVt_PVIO);
do_ftruncate:
TAINT_PROPER("truncate");
- if (!GvIO(tmpgv) || !IoIFP(GvIOp(tmpgv)) ||
+ if (!GvIO(tmpgv) || !IoIFP(GvIOp(tmpgv)))
+ result = 0;
+ else {
+ PerlIO_flush(IoIFP(GvIOp(tmpgv)));
#ifdef HAS_TRUNCATE
- ftruncate(PerlIO_fileno(IoIFP(GvIOn(tmpgv))), len) < 0)
+ if (ftruncate(PerlIO_fileno(IoIFP(GvIOn(tmpgv))), len) < 0)
#else
- my_chsize(PerlIO_fileno(IoIFP(GvIOn(tmpgv))), len) < 0)
+ if (my_chsize(PerlIO_fileno(IoIFP(GvIOn(tmpgv))), len) < 0)
#endif
- result = 0;
+ result = 0;
+ }
}
else {
SV *sv = POPs;
truncate "Iofs.tmp", 0;
if (-z "Iofs.tmp") {print "ok 24\n"} else {print "not ok 24\n"}
open(FH, ">Iofs.tmp") or die "Can't create Iofs.tmp";
+ binmode FH;
{ select FH; $| = 1; select STDOUT }
{
use strict;
- print FH "helloworld\n";
- truncate FH, 5;
+ print FH "x\n" x 200;
+ truncate(FH, 200) or die "Can't truncate FH: $!";
}
if ($^O eq 'dos'
# Not needed on HPFS, but needed on HPFS386 ?!
{
close (FH); open (FH, ">>Iofs.tmp") or die "Can't reopen Iofs.tmp";
}
- if (-s "Iofs.tmp" == 5) {print "ok 25\n"} else {print "not ok 25\n"}
+ if (-s "Iofs.tmp" == 200) {print "ok 25\n"} else {print "not ok 25\n"}
truncate FH, 0;
if ($^O eq 'dos'
# Not needed on HPFS, but needed on HPFS386 ?!