|
From: Karsten W. <kar...@us...> - 2006-03-19 10:51:18
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8383 Modified Files: Tag: pre_int64_branch langhash.c langvalue.c mouse.c oplist.c ops.c strings.c Log Message: longlonginttostring - longlongs can be displayed Index: ops.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/ops.c,v retrieving revision 1.7 retrieving revision 1.7.6.1 diff -C2 -d -r1.7 -r1.7.6.1 *** ops.c 11 Jan 2005 22:48:09 -0000 1.7 --- ops.c 19 Mar 2006 10:51:05 -0000 1.7.6.1 *************** *** 258,261 **** --- 258,304 ---- + #if LONGINT_LONGDATE == 1 + boolean + longlonginttostring(tylonglongint theInt, bigstring bs, int radix) + { + SInt8 isNegative = 0; + UInt64 theUnsignedNumber; + + int stringIndex = 0; + ptrbyte t = stringbaseaddress(bs); + + if (theInt < 0) + { + theUnsignedNumber = -theInt; + isNegative = 1; + } + else + { + theUnsignedNumber = theInt; + } + + do + { + SInt32 currentDigit = theUnsignedNumber % radix; + + if (currentDigit > 9) + t[stringIndex++] = currentDigit + 'A' - 10; + else + t[stringIndex++] = currentDigit + '0'; + + theUnsignedNumber /= radix; + } while (theUnsignedNumber); + + if (isNegative) + t[stringIndex++] = '-'; + + if (!setstringlength(bs, stringIndex)) + return(false); + + return stringreverse(bs); + } + #endif + + boolean stringtonumber (bigstring bs, long *longval) { Index: oplist.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/oplist.c,v retrieving revision 1.7.4.1 retrieving revision 1.7.4.2 diff -C2 -d -r1.7.4.1 -r1.7.4.2 *** oplist.c 10 Mar 2006 22:26:57 -0000 1.7.4.1 --- oplist.c 19 Mar 2006 10:51:05 -0000 1.7.4.2 *************** *** 74,78 **** { Handle oplistindex; ! long start, end, --- 74,78 ---- { Handle oplistindex; ! SInt32 start, end, *************** *** 130,134 **** #if OPLANGLISTACCEL == 1 ! // a try at accelerating indexed list access. currently getnthlistitem has time complexity O(n). // I want O(1) static boolean growlistindex(tylistindexptr theIndex); --- 130,135 ---- #if OPLANGLISTACCEL == 1 ! // a try at accelerating list access by use of an index. ! // currently getnthlistitem has time complexity O(n). // I want O(1) static boolean growlistindex(tylistindexptr theIndex); *************** *** 138,141 **** --- 139,143 ---- initlistindex(tylistindexptr plistidx) { + /* init a new handlecache for a list*/ if (!newclearhandle (sizeof (Handle) * 1024, (Handle *) &(plistidx->oplistindex) )) return (false); *************** *** 154,157 **** --- 156,163 ---- checklistindexlimits(tylistindexptr plistidx) { + /* + check the remaining space in the cache + grow it if only to free places on either side + */ // total push array long limit = plistidx->size - plistidx->start; *************** *** 173,178 **** { disposehandle(theIndex->oplistindex); - // return(false); - return(true); } --- 179,182 ---- *************** *** 181,189 **** --- 185,206 ---- growlistindex(tylistindexptr theIndex) { + // growth rate = 25% + // index sizes are 1024, 1280, 1600, 2000, 2500, 3125 long thesize = theIndex->size + (theIndex->size >> 2); + + // ptrs to start & end of used area void *s, *e; if (!sethandlesize(theIndex->oplistindex, thesize)) + { + // growing failed somehow + // turn index off + disposehandle(theIndex->oplistindex); + theIndex->oplistindex = nil; + theIndex->size = -1; + theIndex->start = -1; + theIndex->end = -1; return(false); + } theIndex->size = thesize; *************** *** 202,206 **** { Handle *dst; ! dst = theIndex->oplistindex; --- 219,226 ---- { Handle *dst; ! ! // check for valid index here ! ! dst = theIndex->oplistindex; *************** *** 217,220 **** --- 237,241 ---- Handle *dst; + // grows when needed if (!checklistindexlimits(theIndex)) return (false); *************** *** 276,280 **** if (!initlistindex(&((**h).listindex))) return(false); - #endif --- 297,300 ---- *************** *** 317,326 **** opdisposeoutline (ho, false); #if OPLANGLISTACCEL == 1 if (!disposelistindex(&((**hlist).listindex))) ; #endif - hcurrentlist = nil; - disposehandle ((Handle) hlist); } /*opdisposelist*/ --- 337,346 ---- opdisposeoutline (ho, false); + hcurrentlist = nil; + #if OPLANGLISTACCEL == 1 if (!disposelistindex(&((**hlist).listindex))) ; #endif disposehandle ((Handle) hlist); } /*opdisposelist*/ Index: strings.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/strings.c,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -C2 -d -r1.8 -r1.8.2.1 *** strings.c 5 Dec 2005 21:49:20 -0000 1.8 --- strings.c 19 Mar 2006 10:51:05 -0000 1.8.2.1 *************** *** 2671,2674 **** --- 2671,2702 ---- } /*pullsuffix*/ + #if LONGINT_LONGDATE == 1 + boolean stringreverse (bigstring bs) + { + // 2006-03-17 - kw --- initial write; needed for longlonginttostring + // reverse a bigstring by swapping bytes 0 & len, 1 & len-1,... + + unsigned char e, s, i, t; + + ptrbyte t1, t2; + + if (!bs) + return (false); + + e = stringlength(bs); + i = e >> 1; + t1 = stringbaseaddress(bs); + t2 = t1 + e - 1; // first char counts; like zero based + + while(i) + { + t = *t1; + *t1++ = *t2; + *t2-- = t; + i--; + } + return (true); + } + #endif void initstrings (void) { Index: mouse.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/mouse.c,v retrieving revision 1.4 retrieving revision 1.4.6.1 diff -C2 -d -r1.4 -r1.4.6.1 *** mouse.c 11 Jan 2005 22:48:09 -0000 1.4 --- mouse.c 19 Mar 2006 10:51:04 -0000 1.4.6.1 *************** *** 388,391 **** --- 388,393 ---- break; } + #else + #pragma unused(eventwhat) #endif Index: langvalue.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/langvalue.c,v retrieving revision 1.8.2.3 retrieving revision 1.8.2.4 diff -C2 -d -r1.8.2.3 -r1.8.2.4 *** langvalue.c 14 Feb 2006 11:43:57 -0000 1.8.2.3 --- langvalue.c 19 Mar 2006 10:51:04 -0000 1.8.2.4 *************** *** 2228,2232 **** return (false); ! x = 0; break; --- 2228,2232 ---- return (false); ! x = LLONG_MAX; break; *************** *** 2433,2437 **** disablelangerror (); ! fl = coercetolong (v); enablelangerror (); --- 2433,2437 ---- disablelangerror (); ! fl = coercetolong (v); enablelangerror (); *************** *** 3469,3476 **** case longvaluetype: numbertostring ((*v).data.longvalue, bs); ! break; ! case ostypevaluetype: case enumvaluetype: --- 3469,3485 ---- case longvaluetype: + { + static UInt32 ncalls = 0; + ncalls++; numbertostring ((*v).data.longvalue, bs); ! } break; ! #if LONGINT_LONGDATE == 1 ! case longlongintvaluetype: ! longlonginttostring(**(*v).data.longlongintvalue, bs, 16); ! ! break; ! #endif ! case ostypevaluetype: case enumvaluetype: *************** *** 3545,3562 **** tyfilespec fs; ! ! #if TARGET_API_MAC_CARBON == 1 ! ! fs.vRefNum = (**(*v).data.filespecvalue).vRefNum; ! ! fs.parID = (**(*v).data.filespecvalue).parID; ! ! copystring ((**(*v).data.filespecvalue).name, fs.name); ! ! #else ! ! fs = **(*v).data.filespecvalue; ! ! #endif filespectopath (&fs, bs); --- 3554,3571 ---- tyfilespec fs; ! ! #if TARGET_API_MAC_CARBON == 1 ! ! fs.vRefNum = (**(*v).data.filespecvalue).vRefNum; ! ! fs.parID = (**(*v).data.filespecvalue).parID; ! ! copystring ((**(*v).data.filespecvalue).name, fs.name); ! ! #else ! ! fs = **(*v).data.filespecvalue; ! ! #endif filespectopath (&fs, bs); Index: langhash.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/langhash.c,v retrieving revision 1.5 retrieving revision 1.5.6.1 diff -C2 -d -r1.5 -r1.5.6.1 *** langhash.c 11 Jan 2005 22:48:06 -0000 1.5 --- langhash.c 19 Mar 2006 10:51:03 -0000 1.5.6.1 *************** *** 3638,3641 **** --- 3638,3644 ---- case listvaluetype: case recordvaluetype: + #if LONGINT_LONGDATE == 1 + case longlongintvaluetype: + #endif if (copyvaluerecord (val, &val) && coercetostring (&val)) { *************** *** 3726,3732 **** break; ! ! #if !flruntime ! case codevaluetype: parsenumberstring (langmiscstringlist, treesizestring, langcounttreenodes (val.data.codevalue), bs); --- 3729,3735 ---- break; ! ! #if !flruntime ! case codevaluetype: parsenumberstring (langmiscstringlist, treesizestring, langcounttreenodes (val.data.codevalue), bs); *************** *** 3741,3746 **** break; ! #endif ! default: langgetmiscstring (unknownstring, bs); --- 3744,3756 ---- break; ! #endif ! #if LONGINT_LONGDATE == 1 ! # if defined (WIN95VERSION) ! ! # endif ! # if defined (MACVERSION) ! ! # endif ! #endif default: langgetmiscstring (unknownstring, bs); |