|
From: Andre R. <and...@us...> - 2004-12-03 13:09:26
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9052/Common/source Modified Files: Tag: New_Tables_Experiment-branch langhash.c langexternal.c Log Message: Fixed a crashing bug in thelogic underlying langexternalgetfullpath and langexternalgetquotedpath. Local symbol tables don't maintain a sort order anymore, so we have to fall back to looping over the hash buckets in this case. Luckily, this doesn't happen very often. Index: langexternal.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/langexternal.c,v retrieving revision 1.3.2.3 retrieving revision 1.3.2.4 diff -C2 -d -r1.3.2.3 -r1.3.2.4 *** langexternal.c 20 Nov 2004 18:59:48 -0000 1.3.2.3 --- langexternal.c 3 Dec 2004 13:09:11 -0000 1.3.2.4 *************** *** 1209,1253 **** } /*langexternalbracketname*/ long fullpathloopcount = 0; ! static boolean istableintable (hdlhashtable hparent, hdlhashtable hchild, hdlhashnode * hnode) { ! hdlhashnode x; hdlexternalvariable hv; - #ifdef fltablesortorderisarray - long k; - #endif ! *hnode = nil; ! ! if (hparent == nil) ! return (false); //defensive driving ! #ifdef fltablesortorderisarray ! for (k = 0; hashgetnthnode (hparent, k, &x); k++) ! #else ! for (x = (**hparent).hfirstsort; x != nil; x = (**x).sortedlink) ! #endif ! { ! if ((**x).val.valuetype == externalvaluetype) { ! ! hv = (hdlexternalvariable) (**x).val.data.externalvalue; ! if ((**hv).id == idtableprocessor) { ! if ((hdlhashtable)(**hv).variabledata == hchild) { ! *hnode = x; ! return (true); ! } } } ! } /*for*/ return (false); } /* istableintable */ ! static boolean fullpathsearch (hdlhashtable intable, hdlhashtable fortable, bigstring forname, boolean flonlyinmemory, boolean flquote, boolean flincludeself, bigstring bspath, hdlwindowinfo *hroot) { /* --- 1209,1331 ---- } /*langexternalbracketname*/ + long fullpathloopcount = 0; ! typedef struct tyistableintableinfo { ! hdlhashtable hchild; ! hdlhashnode hnode; ! } tyistableintableinfo; ! ! ! static boolean istableintablevisit (hdlhashnode x, ptrvoid refcon) { ! ! /* ! 2004-12-02 aradke: see istableintable below ! */ ! ! tyistableintableinfo *info = (tyistableintableinfo *) refcon; hdlexternalvariable hv; ! if ((**x).val.valuetype == externalvaluetype) { ! ! hv = (hdlexternalvariable) (**x).val.data.externalvalue; ! if ((**hv).id == idtableprocessor) { ! if ((hdlhashtable)(**hv).variabledata == info->hchild) { ! info->hnode = x; ! return (false); /*found it*/ } } ! } ! ! return (true); /*continue visit*/ ! } /*istableintablevisit*/ + + static boolean istableintable (hdlhashtable hparent, hdlhashtable hchild, hdlhashnode * hnode) { + + /* + 2004-12-02 aradke: use hashtablesortedvisit instead of looping over the sort order ourselves. + some tables are no longer maintaining a sort order. in that case, hashtablesortedvisit + will do the right thing and fall back to hashtablevisit. part of the former loop + body moved into istableintablevisit. + */ + + tyistableintableinfo info; + + *hnode = nil; + + if (hparent != nil) { //defensive driving + + info.hchild = hchild; + info.hnode = nil; + + if (!hashtablesortedvisit (hparent, &istableintablevisit, &info)) { /*found it*/ + + *hnode = info.hnode; + + return (true); + } + } + return (false); } /* istableintable */ ! typedef struct tyfullpathsearchinfo { ! hdlhashtable fortable; ! ptrstring forname; ! ptrstring bspath; ! hdlwindowinfo *hroot; ! hdlhashnode hnode; ! boolean flquote; ! } tyfullpathsearchinfo; ! ! ! /*forward declaration*/ ! ! static boolean fullpathsearch (hdlhashtable, hdlhashtable, bigstring, boolean, boolean, bigstring, hdlwindowinfo *); ! ! ! static boolean fullpathsearchvisit (hdlhashnode x, ptrvoid refcon) { ! ! /* ! 2004-12-03 aradke: see fullpathsearch below ! */ ! ! tyfullpathsearchinfo *info = (tyfullpathsearchinfo *) refcon; ! hdlexternalvariable hv; ! ! ++fullpathloopcount; ! ! if ((**x).val.valuetype != externalvaluetype) ! return (true); /*continue*/ ! ! hv = (hdlexternalvariable) (**x).val.data.externalvalue; ! ! if ((**hv).id != idtableprocessor) ! return (true); /*continue*/ ! ! if (!(**hv).flinmemory) /*the one we're looking for is in memory, so this can't be it*/ ! return (true); /*continue*/ ! ! //assert (tablesetdebugglobals (ht, x)); /*set debug globals*/ ! ! if (fullpathsearch ((hdlhashtable) (**hv).variabledata, info->fortable, info->forname, info->flquote, true, info->bspath, info->hroot)) { ! ! info->hnode = x; /*found it*/ ! ! return (false); /*unwind recursion*/ ! } ! ! return (true); /*keep looking*/ ! } /*fullpathsearchvisit*/ ! ! ! static boolean fullpathsearch (hdlhashtable intable, hdlhashtable fortable, bigstring forname, boolean flquote, boolean flincludeself, bigstring bspath, hdlwindowinfo *hroot) { /* *************** *** 1255,1262 **** 5.0a18 dmb: added hroot parameter, for guest databases. */ register hdlhashtable ht = intable; - register boolean fltempload; hdlhashnode x; register hdlexternalvariable hv = nil; --- 1333,1344 ---- 5.0a18 dmb: added hroot parameter, for guest databases. + + 2004-12-03 aradke: use hashtablesortedvisit instead of looping over the sort order ourselves. + some tables are no longer maintaining a sort order. in that case, hashtablesortedvisit + will do the right thing and fall back to hashtablevisit. part of the former loop + body moved into fullpathsearchvisit. */ register hdlhashtable ht = intable; hdlhashnode x; register hdlexternalvariable hv = nil; *************** *** 1265,1271 **** extern boolean tablesetdebugglobals (hdlhashtable, hdlhashnode); hdlhashtable pht; ! #ifdef fltablesortorderisarray ! long k; ! #endif pht = nil; --- 1347,1351 ---- extern boolean tablesetdebugglobals (hdlhashtable, hdlhashnode); hdlhashtable pht; ! tyfullpathsearchinfo info; pht = nil; *************** *** 1295,1299 **** } - if ((**fortable).parenthashtable != nil) { --- 1375,1378 ---- *************** *** 1323,1330 **** } - if (pht != nil) { /*Then lets follow the nodes up...*/ ! if (fullpathsearch (ht, pht, "", flonlyinmemory, flquote, flincludeself, bs, hroot)) { if ((ht != pht) || flincludeself) { --- 1402,1408 ---- } if (pht != nil) { /*Then lets follow the nodes up...*/ ! if (fullpathsearch (ht, pht, "", flquote, flincludeself, bs, hroot)) { if ((ht != pht) || flincludeself) { *************** *** 1349,1355 **** setemptystring (bspath); ! ! ! if (! isemptystring (forname)) { /*asking for specific name*/ if (hashtablesymbolexists (fortable, forname)) { //Make sure the symbol exists --- 1427,1431 ---- setemptystring (bspath); ! if (!isemptystring (forname)) { /*asking for specific name*/ if (hashtablesymbolexists (fortable, forname)) { //Make sure the symbol exists *************** *** 1366,1373 **** } ! // return (false); } if (hroot) { x = (**fortable).thistableshashnode; --- 1442,1450 ---- } ! //return (false); } if (hroot) { + x = (**fortable).thistableshashnode; *************** *** 1383,1461 **** return (false); } ! #ifdef fltablesortorderisarray ! for (k = 0; hashgetnthnode (ht, k, &x); k++) ! #else ! for (x = (**ht).hfirstsort; x != nil; x = (**x).sortedlink) ! #endif ! { /*chain through the hash list*/ ! ! fltempload = false; ! ! ++fullpathloopcount; ! ! if ((**x).val.valuetype != externalvaluetype) ! goto nextx; ! ! hv = (hdlexternalvariable) (**x).val.data.externalvalue; ! ! if ((**hv).id != idtableprocessor) ! goto nextx; ! ! if (!(**hv).flinmemory) { ! ! if (flonlyinmemory) /*can't find it if it isn't in memory*/ ! goto nextx; ! ! if (!tableverbinmemory (hv, x)) ! return (false); ! ! fltempload = true; ! } ! ///////// assert (tablesetdebugglobals (ht, x)); /*set debug globals*/ ! if (fullpathsearch ((hdlhashtable) (**hv).variabledata, fortable, forname, flonlyinmemory, flquote, true, bs, hroot)) { ! hdlhashtable cht; ! hdlhashnode nn; ! ! cht = ((hdlhashtable) (**hv).variabledata); ! /*we do not have an if statement here since the straight assignment is faster*/ ! (**cht).parenthashtable = ht; /*set the parent pointer for next time*/ ! if ((**cht).thistableshashnode == nil) ! if (istableintable (ht, cht, &nn)) ! (**cht).thistableshashnode = nn; ! if (flincludeself) { ! gethashkey (x, bspath); ! if (flquote) ! langexternalbracketname (bspath); ! if (stringlength (bs) > 0) { ! ! pushchar ('.', bspath); ! ! pushstring (bs, bspath); ! } } - else - copystring (bs, bspath); - - if (hroot && (*hroot == nil)) - if (langexternalvariablewindowopen (hv, &hinfo) && (hinfo != nil)) - getrootwindow ((**hinfo).macwindow, hroot); - - return (true); /*unwind recursion*/ } ! ! nextx: ! if (fltempload) ! tableverbunload (hv); ! } /*while*/ return (false); --- 1460,1511 ---- return (false); } + + info.fortable = fortable; + info.forname = (ptrstring) forname; + info.bspath = (ptrstring) bs; + info.hroot = hroot; + info.flquote = flquote; + + if (!hashtablesortedvisit (ht, &fullpathsearchvisit, &info)) { /*found it*/ ! hdlhashtable cht; ! hdlhashnode hn; ! hv = (hdlexternalvariable) (**(info.hnode)).val.data.externalvalue; ! cht = ((hdlhashtable) (**hv).variabledata); ! /*we do not have an if statement here since the straight assignment is faster*/ ! (**cht).parenthashtable = ht; /*set the parent pointer for next time*/ ! if ((**cht).thistableshashnode == nil) ! if (istableintable (ht, cht, &hn)) ! (**cht).thistableshashnode = hn; ! if (flincludeself) { ! ! gethashkey (info.hnode, bspath); ! ! if (flquote) ! langexternalbracketname (bspath); ! ! if (stringlength (bs) > 0) { ! /*bspath = bspath + "." + bs*/ ! pushchar ('.', bspath); ! pushstring (bs, bspath); } } ! else ! copystring (bs, bspath); ! if (hroot && (*hroot == nil)) ! if (langexternalvariablewindowopen (hv, &hinfo) && (hinfo != nil)) ! getrootwindow ((**hinfo).macwindow, hroot); ! ! return (true); /*unwind recursion*/ ! } return (false); *************** *** 1870,1873 **** --- 1920,1925 ---- searching the file window table if we're not quoting the path, to avoid file names in window titles. + + 2004-12-03 aradke: unwired flonlyinmemory feature -- it's never needed. */ *************** *** 1887,1894 **** if ((htable == filewindowtable) || (tablegetdatabase (htable) != tablegetdatabase (roottable))) ! if (fullpathsearch (filewindowtable, htable, bsname, true, flquote, flquote, bspath, hroot)) goto exit; ! if (fullpathsearch (roottable, htable, bsname, true, flquote, true, bspath, hroot)) goto exit; } --- 1939,1946 ---- if ((htable == filewindowtable) || (tablegetdatabase (htable) != tablegetdatabase (roottable))) ! if (fullpathsearch (filewindowtable, htable, bsname, flquote, flquote, bspath, hroot)) goto exit; ! if (fullpathsearch (roottable, htable, bsname, flquote, true, bspath, hroot)) goto exit; } *************** *** 1918,1922 **** for (ht = currenthashtable; ht != nil; ht = (**ht).prevhashtable) { ! if (fullpathsearch (ht, htable, bsname, true, flquote, true, bspath, hroot)) goto exit; } --- 1970,1974 ---- for (ht = currenthashtable; ht != nil; ht = (**ht).prevhashtable) { ! if (fullpathsearch (ht, htable, bsname, flquote, true, bspath, hroot)) goto exit; } *************** *** 1930,1937 **** } } - - // now try non-inmemory search - //if (fullpathsearch (roottable, htable, bsname, false, flquote, bspath, hroot)) - // goto exit; } --- 1982,1985 ---- Index: langhash.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/langhash.c,v retrieving revision 1.4.2.18 retrieving revision 1.4.2.19 diff -C2 -d -r1.4.2.18 -r1.4.2.19 *** langhash.c 1 Dec 2004 20:32:47 -0000 1.4.2.18 --- langhash.c 3 Dec 2004 13:09:11 -0000 1.4.2.19 *************** *** 2556,2559 **** --- 2556,2608 ---- + #if defined(fldebug) && defined(fltablesortorderisarray) + + static long ctdebughashtablesortedvisitfallbacks = 0; + + #endif + + + boolean hashtablesortedvisit (hdlhashtable htable, langtablevisitcallback visit, ptrvoid refcon) { + + /* + 2004-12-02 aradke: visit in sort order. if table is unsorted, fall back to hashtablevisit. + visit is not supposed to change the list behind our back. + */ + + #ifdef fltablesortorderisarray + + register hdllist hlist = (**htable).sortedlist; + register long k, kmax; + + if (hlist == nil) { /*fallback*/ + + #ifdef fldebug + ctdebughashtablesortedvisitfallbacks++; + #endif + + return (hashtablevisit (htable, visit, refcon)); + } + + for (k = 0, kmax = listcount (hlist); k < kmax; k++) + + if (!(*visit) ((hdlhashnode) listget (hlist, k), refcon)) + + return (false); + + #else + + register hdlhashnode x; + + for (x = (**htable).hfirstsort; x != nil; x = (**x).sortedlink) + + if (!(*visit) (x, refcon)) + + return (false); + #endif + + return (true); + } /*hashtablesortedvisit*/ + + static boolean hashquicksort (hdlhashtable htable) { |