[prev in list] [next in list] [prev in thread] [next in thread]
List: mozilla-os2
Subject: prprf.c fix for type conversion at the limits
From: Henry Sobotka <sobotka () axess ! com>
Date: 1998-05-30 23:09:58
[Download RAW message or body]
This fixes the problem caused by type conversion at the limits due to
(unsigned long)LONG_MIN > LONG_MAX in emx's limits.h. All it involves is
conversion to long long and use of the cvt_ll routine in that case. The
result is a full pass for the sprintf test.
Henry
-----------------------snip-snip-snip------------------------------
Index: prprf.c
===================================================================
RCS file: /cvsroot/mozilla/nsprpub/pr/src/io/prprf.c,v
retrieving revision 3.1
diff -r3.1 prprf.c
27a28
> #include <limits.h>
236a238
> PRInt64 lnum, rad;
242a245,267
> /* In case (unsigned long)LONG_MIN > LONG_MAX */
> if ((unsigned long)num > LONG_MAX){
> LL_I2L(lnum, num);
> LL_I2L(rad, radix);
> lnum.hi = 0;
> cvt = cvtbuf + sizeof(cvtbuf);
> digits = 0;
> while (!LL_IS_ZERO(lnum)) {
> PRInt32 digit;
> PRInt64 quot, rem;
> LL_UDIVMOD(", &rem, lnum, rad);
> LL_L2I(digit, rem);
> *--cvt = hexp[digit & 0xf];
> digits++;
> lnum = quot;
> }
> if (digits == 0) {
> *--cvt = '0';
> digits++;
> }
> }
>
> else {
248,258c273,284
< cvt = cvtbuf + sizeof(cvtbuf);
< digits = 0;
< while (num) {
< int digit = (((unsigned long)num) % radix) & 0xF;
< *--cvt = hexp[digit];
< digits++;
< num = (long)((unsigned long)num) / radix;
< }
< if (digits == 0) {
< *--cvt = '0';
< digits++;
---
> cvt = cvtbuf + sizeof(cvtbuf);
> digits = 0;
> while (num) {
> int digit = (((unsigned long)num) % radix) & 0xF;
> *--cvt = hexp[digit];
> digits++;
> num = (long)((unsigned long)num) / radix;
> }
> if (digits == 0) {
> *--cvt = '0';
> digits++;
> }
260d285
<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic