diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-03-05 04:30:02 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-03-05 04:30:02 +0000 |
commit | 9b0e499bcdd1e62b4ead7739d3482d056b5ac3dc (patch) | |
tree | 1f0b19fb5573092a339abc73c454ee7256f1009f /pp.c | |
parent | d5448623582779336009dd8bafd91e2a4ca7c599 (diff) | |
download | perl-9b0e499bcdd1e62b4ead7739d3482d056b5ac3dc.tar.gz |
scan_num() sticks to UVs rather than IVs (now -2147483648 doesn't
end up being promoted to an NV)
p4raw-id: //depot/perl@5533
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -1391,9 +1391,23 @@ PP(pp_negate) dTOPss; if (SvGMAGICAL(sv)) mg_get(sv); - if (SvIOKp(sv) && !SvNOKp(sv) && !SvPOKp(sv) && SvIVX(sv) != IV_MIN) - SETi(-SvIVX(sv)); - else if (SvNIOKp(sv)) + if (SvIOKp(sv) && !SvNOKp(sv) && !SvPOKp(sv)) { + if (SvIsUV(sv)) { + if (SvIVX(sv) == IV_MIN) { + SETi(SvIVX(sv)); /* special case: -((UV)IV_MAX+1) == IV_MIN */ + RETURN; + } + else if (SvUVX(sv) <= IV_MAX) { + SETi(-SvUVX(sv)); + RETURN; + } + } + else if (SvIVX(sv) != IV_MIN) { + SETi(-SvIVX(sv)); + RETURN; + } + } + if (SvNIOKp(sv)) SETn(-SvNV(sv)); else if (SvPOKp(sv)) { STRLEN len; |