Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/perl5Public

Commit80c1f1e

Browse files
committed
only clear the stream error state in readline() for glob()
This would previously clear the stream error state in any casewhere sv_gets() failed and the error state was set.This included normal files, which meant that the fact that an erroroccurred was no longer reflected in the stream state.For reads from ARGV this was a no-op, since nextargv() re-opens theinput stream by calling do_open6() which closes the old input streamsilently.For glob() (and really only for miniperl, since File::Glob is used fora full perl) leaving the stream in an error state could be confusingfor the error reporting done when do_close() fails, since it wouldfail if the stream has an error state, but we report it as theunderlying pclose() failing due to the child process failing in someway.Since this now leaves the error state on the stream, the close()calls in the test updated by this commit would fail, changing itsoutput. Since the result of those closes didn't seem relatedto the purpose of the test, I changed it not throw an error oneither close() failing.
1 parent02cf5fb commit80c1f1e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

‎pp_hot.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3334,14 +3334,19 @@ Perl_do_readline(pTHX)
33343334
||SNARF_EOF(gimme,PL_rs,io,sv)
33353335
||PerlIO_error(fp)))
33363336
{
3337-
PerlIO_clearerr(fp);
33383337
if (IoFLAGS(io)&IOf_ARGV) {
33393338
fp=nextargv(PL_last_in_gv,PL_op->op_flags&OPf_SPECIAL);
3340-
if (fp)
3339+
if (fp) {
33413340
continue;
3341+
}
33423342
(void)do_close(PL_last_in_gv, FALSE);
33433343
}
33443344
elseif (type==OP_GLOB) {
3345+
/* clear any errors here so we only fail on the pclose()
3346+
failing, which should only happen on the child
3347+
failing
3348+
*/
3349+
PerlIO_clearerr(fp);
33453350
if (!do_close(PL_last_in_gv, FALSE)) {
33463351
Perl_ck_warner(aTHX_packWARN(WARN_GLOB),
33473352
"glob failed (child exited with status %d%s)",

‎t/lib/warnings/pp_hot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ $a = <FOO> ;
237237
use warnings 'io' ;
238238
$a = <FOO> ;
239239
$a = <FH> ;
240-
close (FH) or die $!;
241-
close (FOO) or die $!;
240+
close (FH);
241+
close (FOO);
242242
unlink $file ;
243243
EXPECT
244244
Filehandle FH opened only for output at - line 5.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp