|
From: <kar...@us...> - 2006-05-15 18:41:19
|
Revision: 1376 Author: karstenw Date: 2006-05-15 11:41:11 -0700 (Mon, 15 May 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1376&view=rev Log Message: ----------- corrections to parsepopnumber() to return a long if in range Modified Paths: -------------- Frontier/branches/Int64/Common/source/langscan.c Frontier/branches/Int64/Common/source/langvalue.c Modified: Frontier/branches/Int64/Common/source/langscan.c =================================================================== --- Frontier/branches/Int64/Common/source/langscan.c 2006-05-13 17:30:47 UTC (rev 1375) +++ Frontier/branches/Int64/Common/source/langscan.c 2006-05-15 18:41:11 UTC (rev 1376) @@ -435,7 +435,7 @@ while (true) { - register byte ch = parsefirstchar (); + byte ch = parsefirstchar (); if ((ch == '.') && !flfloat) flfloat = true; @@ -449,16 +449,16 @@ if (flfloat) { double d; - Handle x; + Handle fx; // 2006-05-15 - kw --- renamed due to ambiguity stringtofloat (bsnumber, &d); - if (!newfilledhandle (&d, longsizeof (d), &x)) + if (!newfilledhandle (&d, longsizeof (d), &fx)) return (false); initvalue (val, doublevaluetype); - (*val).data.binaryvalue = x; + (*val).data.binaryvalue = fx; } else { #if LONGINT_LONGDATE == 1 @@ -470,10 +470,11 @@ if (flhex) { #if LONGINT_LONGDATE == 1 - if (stringlength (bsnumber) > 10) + // 0x + 16 hex chars + if (stringlength (bsnumber) > 18) goto overflow; #else - if (stringlength (bsnumber) > 20) + if (stringlength (bsnumber) > 10) goto overflow; #endif hexstringtonumber (bsnumber, &x); @@ -481,11 +482,16 @@ else { #if LONGINT_LONGDATE == 1 stringtolonglongint (bsnumber, &x); - +#else + stringtonumber (bsnumber, &x); +#endif popleadingchars (bsnumber, '0'); - + +#if LONGINT_LONGDATE == 1 longlonginttostring (x, bstest, 10); - +#else + numbertostring (x, bstest); +#endif popleadingchars (bstest, '0'); if (!equalstrings (bsnumber, bstest)) @@ -496,23 +502,20 @@ x = -x; x = -x; } -#else - stringtonumber (bsnumber, &x); - - popleadingchars (bsnumber, '0'); - - numbertostring (x, bstest); - - popleadingchars (bstest, '0'); - - if (!equalstrings (bsnumber, bstest)) - goto overflow; -#endif - } + } #if LONGINT_LONGDATE == 1 - setlongvalue (x, val); + if ( (x < (tylonglongint)LONG_MAX) + && (x > (tylonglongint)LONG_MIN)) + { + long lx = (long)x; + setlongvalue (lx, val); + } + else + { + setllintvaluewrap (x, val); + } #else - setllintvaluewrap (x, val); + setlongvalue (x, val); #endif } @@ -1371,12 +1374,3 @@ */ #endif - - - - - - - - - Modified: Frontier/branches/Int64/Common/source/langvalue.c =================================================================== --- Frontier/branches/Int64/Common/source/langvalue.c 2006-05-13 17:30:47 UTC (rev 1375) +++ Frontier/branches/Int64/Common/source/langvalue.c 2006-05-15 18:41:11 UTC (rev 1376) @@ -247,21 +247,19 @@ boolean setllintvaluewrap (tylonglongint x, tyvaluerecord *val) { /* + modelled after setdoublevalue() set val to be a the long long value x. + + turn val into a double value, allocated in the heap. + + the handle is recorded in the tmpstack so that it gets deallocated. */ - Handle h = newclearhandle(sizeof(tylonglongint), &x); - **h = x; + return (newheapvalue (&x, sizeof (x), longlongintvaluetype, val)); - return(setlonglongintvalue(h, val)); } /* setlonglongintvalue */ - -#endif - - -#if LONGINT_LONGDATE == 1 boolean setlongdatevalue (Handle x, tyvaluerecord *val) { // set val to be a the long date value x. @@ -2148,8 +2146,8 @@ 3.0.2 dmb: range check when coercing floats */ - register long x; - register double f; + long x; + double f; switch ((*v).valuetype) { @@ -2231,29 +2229,28 @@ case longlongintvaluetype: case longdatetimevaluetype: { - tylonglongint n; - Handle h; + tylonglongint lln; boolean fl = false; - h = (*v).data.binaryvalue; - if (8 == gethandlesize(h)) + if (nil != (*v).data.binaryvalue) { - n = (tylonglongint)**h; - if ( (n > LONG_MAX) - || (n < LONG_MIN)) + if (8 == gethandlesize((*v).data.binaryvalue)) { - // longlongvalue is out of range - x = 0; + lln = **((*v).data.longlongintvalue);; + if ( (lln > LONG_MAX) + || (lln < LONG_MIN)) + { + // longlongvalue is out of range + x = 0; + } + else + { + // we're in range + x = (long)lln; + fl = true; + } } - else - { - // we're in range - x = (long)n; - fl = true; - } } - - releaseheaptmp (h); return (fl); break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |