From: Gisle Aas Date: Fri, 21 Oct 2005 08:04:40 +0000 (-0700) Subject: allow "" as select bitmask [PATCH] X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=15547071d7923e1ad71df03a6a5f4bf10b39825e;p=p5sagit%2Fp5-mst-13.2.git allow "" as select bitmask [PATCH] Message-ID: p4raw-id: //depot/perl@25818 --- diff --git a/pp_sys.c b/pp_sys.c index cf6a862..b907093 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -1031,14 +1031,14 @@ PP(pp_sselect) SP -= 4; for (i = 1; i <= 3; i++) { SV *sv = SP[i]; - if (SvOK(sv) && SvREADONLY(sv)) { + if (!SvOK(sv)) + continue; + if (SvREADONLY(sv)) { if (SvIsCOW(sv)) sv_force_normal_flags(sv, 0); - if (SvREADONLY(sv)) + if (SvREADONLY(sv) && !(SvPOK(sv) && SvCUR(sv) == 0)) DIE(aTHX_ PL_no_modify); } - if (!SvOK(sv)) - continue; if (!SvPOK(sv)) { if (ckWARN(WARN_MISC)) Perl_warner(aTHX_ packWARN(WARN_MISC), "Non-string passed as bitmask"); @@ -1093,7 +1093,7 @@ PP(pp_sselect) for (i = 1; i <= 3; i++) { sv = SP[i]; - if (!SvOK(sv)) { + if (!SvOK(sv) || SvCUR(sv) == 0) { fd_sets[i] = 0; continue; } diff --git a/t/op/sselect.t b/t/op/sselect.t index 4e50b29..0f877b1 100644 --- a/t/op/sselect.t +++ b/t/op/sselect.t @@ -7,7 +7,7 @@ BEGIN { require 'test.pl'; -plan (6); +plan (9); my $blank = ""; eval {select undef, $blank, $blank, 0}; @@ -18,8 +18,15 @@ eval {select $blank, $blank, undef, 0}; is ($@, ""); eval {select "", $blank, $blank, 0}; -like ($@, qr/^Modification of a read-only value attempted/); +is ($@, ""); eval {select $blank, "", $blank, 0}; -like ($@, qr/^Modification of a read-only value attempted/); +is ($@, ""); eval {select $blank, $blank, "", 0}; +is ($@, ""); + +eval {select "a", $blank, $blank, 0}; +like ($@, qr/^Modification of a read-only value attempted/); +eval {select $blank, "a", $blank, 0}; +like ($@, qr/^Modification of a read-only value attempted/); +eval {select $blank, $blank, "a", 0}; like ($@, qr/^Modification of a read-only value attempted/);