Make sure parser's filehandle is closed when finished
Steve Hay [Tue, 17 Jun 2008 16:50:57 +0000 (16:50 +0000)]
(It was mistakenly left open if there was no old_parser, which caused
t/comp/require.t to leave behind a 'bleah.pm' (from the test for
#49472) on Win32, where the deletion of an open file fails.)

p4raw-id: //depot/perl@34071

toke.c

diff --git a/toke.c b/toke.c
index a601c51..e98e47c 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -761,8 +761,8 @@ Perl_parser_free(pTHX_  const yy_parser *parser)
 
     if (parser->rsfp == PerlIO_stdin())
        PerlIO_clearerr(parser->rsfp);
-    else if (parser->rsfp && parser->old_parser
-                         && parser->rsfp != parser->old_parser->rsfp)
+    else if (parser->rsfp && (!parser->old_parser ||
+               (parser->old_parser && parser->rsfp != parser->old_parser->rsfp)))
        PerlIO_close(parser->rsfp);
     SvREFCNT_dec(parser->rsfp_filters);