diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-01-22 10:53:06 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-01-22 10:53:06 +0000 |
commit | 2f3b6ae408a2d23f3c90b00b9fbaa2ad4c9a755a (patch) | |
tree | fcadde88e0cff324438491ab42fb917befd622c7 /pp_sys.c | |
parent | f89480d452d435e4e828b4920af70120508474bb (diff) | |
download | perl-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.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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; |