summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-01-22 10:53:06 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-01-22 10:53:06 +0000
commit2f3b6ae408a2d23f3c90b00b9fbaa2ad4c9a755a (patch)
treefcadde88e0cff324438491ab42fb917befd622c7 /pp_sys.c
parentf89480d452d435e4e828b4920af70120508474bb (diff)
downloadperl-2f3b6ae408a2d23f3c90b00b9fbaa2ad4c9a755a.tar.gz
truncate(FH) flushes FH before truncating it
p4raw-id: //depot/perl@4838
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/pp_sys.c b/pp_sys.c
index ea34bae31e..df0fb42ff1 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1835,13 +1835,17 @@ PP(pp_truncate)
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;