diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-07-08 01:24:25 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-07-08 01:24:25 +0000 |
commit | f248d07102861fd4d0819cc0b602f81105bc562c (patch) | |
tree | 56fb766b87f14a99fd56b491dc6fa138a5c63e0f /util.c | |
parent | 3e3318e754fa4289ad1c682811dbe6a31cd59e26 (diff) | |
download | perl-f248d07102861fd4d0819cc0b602f81105bc562c.tar.gz |
fixes for logical bugs in the lexwarn patch; other tweaks to avoid
type mismatch problems
p4raw-id: //depot/perl@3658
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 33 |
1 files changed, 17 insertions, 16 deletions
@@ -2752,14 +2752,15 @@ Perl_scan_bin(pTHX_ char *start, I32 len, I32 *retlen) register UV retval = 0; bool overflowed = FALSE; while (len && *s >= '0' && *s <= '1') { - dTHR; - register UV n = retval << 1; - if (!overflowed && (n >> 1) != retval && ckWARN_d(WARN_UNSAFE)) { - Perl_warner(aTHX_ WARN_UNSAFE, "Integer overflow in binary number"); - overflowed = TRUE; - } - retval = n | (*s++ - '0'); - len--; + register UV n = retval << 1; + if (!overflowed && (n >> 1) != retval) { + dTHR; + if (ckWARN_d(WARN_UNSAFE)) + Perl_warner(aTHX_ WARN_UNSAFE, "Integer overflow in binary number"); + overflowed = TRUE; + } + retval = n | (*s++ - '0'); + len--; } if (len && (*s >= '2' && *s <= '9')) { dTHR; @@ -2777,10 +2778,11 @@ Perl_scan_oct(pTHX_ char *start, I32 len, I32 *retlen) bool overflowed = FALSE; while (len && *s >= '0' && *s <= '7') { - dTHR; register UV n = retval << 3; - if (!overflowed && (n >> 3) != retval && ckWARN_d(WARN_UNSAFE)) { - Perl_warner(aTHX_ WARN_UNSAFE, "Integer overflow in octal number"); + if (!overflowed && (n >> 3) != retval) { + dTHR; + if (ckWARN_d(WARN_UNSAFE)) + Perl_warner(aTHX_ WARN_UNSAFE, "Integer overflow in octal number"); overflowed = TRUE; } retval = n | (*s++ - '0'); @@ -2818,12 +2820,11 @@ Perl_scan_hex(pTHX_ char *start, I32 len, I32 *retlen) } } n = retval << 4; - { + if (!overflowed && (n >> 4) != retval) { dTHR; - if (!overflowed && (n >> 4) != retval && ckWARN_d(WARN_UNSAFE)) { - Perl_warner(aTHX_ WARN_UNSAFE, "Integer overflow in hex number"); - overflowed = TRUE; - } + if (ckWARN_d(WARN_UNSAFE)) + Perl_warner(aTHX_ WARN_UNSAFE, "Integer overflow in hex number"); + overflowed = TRUE; } retval = n | ((tmp - PL_hexdigit) & 15); } |