From 90eaaf02689a95627535076b787e35a0332ab2d5 Mon Sep 17 00:00:00 2001 From: Eric Brine Date: Fri, 18 Oct 2013 16:13:48 +0100 Subject: [PATCH] Call select's 4th arg's magic [perl #120102] CORE::select ignoring timeout var's magic Patch by Eric, with tested added by davem. --- pp_sys.c | 3 ++- t/op/sselect.t | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pp_sys.c b/pp_sys.c index 5656e5a..b5ed33f 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -1159,8 +1159,9 @@ PP(pp_sselect) # endif sv = SP[4]; + SvGETMAGIC(sv); if (SvOK(sv)) { - value = SvNV(sv); + value = SvNV_nomg(sv); if (value < 0.0) value = 0.0; timebuf.tv_sec = (long)value; diff --git a/t/op/sselect.t b/t/op/sselect.t index 83bd073..879c9d5 100644 --- a/t/op/sselect.t +++ b/t/op/sselect.t @@ -9,7 +9,7 @@ BEGIN { require 'test.pl'; -plan (14); +plan (15); my $blank = ""; eval {select undef, $blank, $blank, 0}; @@ -74,3 +74,20 @@ $t1 = time; $diff = $t1-$t0; ok($diff >= $sleep-$under, "select(\$e,u,u,\$sleep): at least $sleep seconds have passed"); note("diff=$diff under=$under"); + +# [perl #120102] CORE::select ignoring timeout var's magic + +{ + package RT120102; + + my $count = 0; + + sub TIESCALAR { bless [] } + sub FETCH { $count++; 0.1 } + + my $sleep; + + tie $sleep, 'RT120102'; + select (undef, undef, undef, $sleep); + ::is($count, 1, 'RT120102'); +} -- 2.7.4