summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-03-05 04:30:02 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-03-05 04:30:02 +0000
commit9b0e499bcdd1e62b4ead7739d3482d056b5ac3dc (patch)
tree1f0b19fb5573092a339abc73c454ee7256f1009f /pp.c
parentd5448623582779336009dd8bafd91e2a4ca7c599 (diff)
downloadperl-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.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/pp.c b/pp.c
index ebfe985b29..fcae1e4db7 100644
--- a/pp.c
+++ b/pp.c
@@ -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;