|
From: <kar...@us...> - 2006-05-16 11:50:09
|
Revision: 1377 Author: karstenw Date: 2006-05-16 04:49:49 -0700 (Tue, 16 May 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1377&view=rev Log Message: ----------- minor comment and formatting changes Modified Paths: -------------- Frontier/branches/Int64/Common/source/langscan.c Frontier/branches/Int64/Common/source/ops.c Modified: Frontier/branches/Int64/Common/source/langscan.c =================================================================== --- Frontier/branches/Int64/Common/source/langscan.c 2006-05-15 18:41:11 UTC (rev 1376) +++ Frontier/branches/Int64/Common/source/langscan.c 2006-05-16 11:49:49 UTC (rev 1377) @@ -497,6 +497,7 @@ if (!equalstrings (bsnumber, bstest)) goto overflow; + // DELETEME if (x > 2147483647LL) { x = -x; Modified: Frontier/branches/Int64/Common/source/ops.c =================================================================== --- Frontier/branches/Int64/Common/source/ops.c 2006-05-15 18:41:11 UTC (rev 1376) +++ Frontier/branches/Int64/Common/source/ops.c 2006-05-16 11:49:49 UTC (rev 1377) @@ -261,7 +261,10 @@ #if LONGINT_LONGDATE == 1 boolean -longlonginttostring(tylonglongint theInt, bigstring bs, int radix) +longlonginttostring( + tylonglongint theInt, + bigstring bs, + int radix) { SInt8 isNegative = 0; UInt64 theUnsignedNumber; @@ -269,19 +272,16 @@ int stringIndex = 0; ptrbyte t = stringbaseaddress(bs); - if (theInt < 0) - { + if (0 > theInt) { theUnsignedNumber = -theInt; isNegative = 1; - } + } else - { theUnsignedNumber = theInt; - } - do - { - SInt32 currentDigit = theUnsignedNumber % radix; + do { + SInt32 + currentDigit = theUnsignedNumber % radix; if (currentDigit > 9) t[stringIndex++] = currentDigit + 'A' - 10; @@ -298,60 +298,71 @@ return(false); return stringreverse(bs); -} + } boolean stringtolonglongint ( bigstring bs, tylonglongint *llival) { - - // 2006-05-13 - kw - first write; modelled after stringtonumber - long - i, + /* + convert a bigstring into a tylonglongint + */ + /* + 2006-05-13 - kw - first write; modelled after stringtonumber + */ + long i, n; + + // + if (bs) n = (long)stringlength (bs); + else + return(false); *llival = 0; - for (i = 1; i <= n; ++i) - { + for (i = 1; i <= n; ++i) { + byte ch = bs [i]; - if (!isdigit (ch)) - { + if (!isdigit (ch)) { + if ( (i > 1) || ( ch != '+' - && ch != '-')) - { + && ch != '-')) { + /*not a leading +/-*/ setstringlength (bs, i - 1); break; + } } } - } - if (isemptystring (bs)) - { + if (isemptystring (bs)) { *llival = 0; - } - else - { + + } else { + n = (long)stringlength (bs); - for ( i = 1; i <= n; i++) - { + + for ( i = 1; i <= n; i++) { + byte ch = bs [i]; - if (isdigit(ch)) - { + + if (isdigit(ch)) { + *llival *= 10; + *llival += (ch - '0'); - } + } + if (ch == '-') *llival = -(*llival); + } } - } return (true); -} /*stringtolonglongint*/ + } /*stringtolonglongint*/ #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |