From: Gurusamy Sarathy Date: Tue, 22 Feb 2000 05:35:27 +0000 (+0000) Subject: adjust for lost fp precision in require version check X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dbe7b1772b1a5593767d19db4bfee18f47979155;p=p5sagit%2Fp5-mst-13.2.git adjust for lost fp precision in require version check p4raw-id: //depot/perl@5190 --- diff --git a/pp_ctl.c b/pp_ctl.c index 7c69e35..308c824 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -2931,15 +2931,17 @@ PP(pp_require) } } else if (!SvPOKp(sv)) { /* require 5.005_03 */ - NV n = SvNV(sv); - rev = (UV)n; - ver = (UV)((n-rev)*1000); - sver = (UV)((((n-rev)*1000 - ver) + 0.0009) * 1000); - if ((NV)PERL_REVISION + ((NV)PERL_VERSION/(NV)1000) + ((NV)PERL_SUBVERSION/(NV)1000000) + 0.00000099 < SvNV(sv)) { + NV nrev = SvNV(sv); + UV rev = (UV)nrev; + NV nver = (nrev - rev) * 1000; + UV ver = (UV)(nver + 0.0009); + NV nsver = (nver - ver) * 1000; + UV sver = (UV)(nsver + 0.0009); + DIE(aTHX_ "Perl v%"UVuf".%"UVuf".%"UVuf" required--this is only version " "v%d.%d.%d, stopped", rev, ver, sver, PERL_REVISION, PERL_VERSION, PERL_SUBVERSION); diff --git a/t/comp/require.t b/t/comp/require.t index 7af8932..cd97c55 100755 --- a/t/comp/require.t +++ b/t/comp/require.t @@ -7,7 +7,7 @@ BEGIN { # don't make this lexical $i = 1; -print "1..18\n"; +print "1..19\n"; sub do_require { %INC = (); @@ -65,10 +65,10 @@ print "# $@\nnot " if $@; print "ok ",$i++,"\n"; # check inaccurate fp -#$ver = 10.2; -#eval { require $ver; }; -#print "# $@\nnot " unless $@ =~ /^Perl v10\.200\.0 required/; -#print "ok ",$i++,"\n"; +$ver = 10.2; +eval { require $ver; }; +print "# $@\nnot " unless $@ =~ /^Perl v10\.200\.0 required/; +print "ok ",$i++,"\n"; $ver = 10.000_02; eval { require $ver; };