|
From: <cre...@us...> - 2007-02-25 01:45:08
|
Revision: 1626
http://svn.sourceforge.net/frontierkernel/?rev=1626&view=rev
Author: creecode
Date: 2007-02-24 17:45:06 -0800 (Sat, 24 Feb 2007)
Log Message:
-----------
support for long odb item names and file paths
formatting tweaks
Modified Paths:
--------------
Frontier/branches/Frontier_Long_File_Paths/Common/headers/langexternal.h
Frontier/branches/Frontier_Long_File_Paths/Common/headers/langinternal.h
Frontier/branches/Frontier_Long_File_Paths/Common/headers/langipc.h
Frontier/branches/Frontier_Long_File_Paths/Common/source/langhash.c
Frontier/branches/Frontier_Long_File_Paths/Common/source/langhtml.c
Frontier/branches/Frontier_Long_File_Paths/Common/source/langipc.c
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/headers/langexternal.h
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/headers/langexternal.h 2007-02-24 00:04:28 UTC (rev 1625)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/headers/langexternal.h 2007-02-25 01:45:06 UTC (rev 1626)
@@ -82,6 +82,7 @@
idcardprocessor,
ctexternalprocessors
+
} tyexternalid;
@@ -187,15 +188,15 @@
#define externaldiskversionnumber 1
-/*prototypes*/
+// prototypes
extern tyexternalid langexternalgettype (tyvaluerecord);
-extern boolean langexternalgettable (bigstring, hdlhashtable *);
+extern boolean langexternalgettable ( const Handle, hdlhashtable * );
extern boolean langexternalvaltotable (tyvaluerecord, hdlhashtable *, hdlhashnode);
-extern boolean langexternalfindvariable (hdlexternalvariable, hdlhashtable *, bigstring);
+extern boolean langexternalfindvariable ( hdlexternalvariable, hdlhashtable *, Handle * );
extern boolean langexternalgettablevalue (hdltreenode, short, hdlhashtable *);
@@ -203,11 +204,11 @@
extern void langexternalsetdatabase (hdlexternalvariable, hdldatabaserecord);
-extern boolean langsetexternalsymbol (hdlhashtable, bigstring, tyexternalid, Handle);
+extern boolean langsetexternalsymbol ( hdlhashtable, const Handle, tyexternalid, Handle );
-extern boolean langexternaldontsave (hdlhashtable, bigstring);
+extern boolean langexternaldontsave ( hdlhashtable, const Handle );
-extern boolean langexternalpleasesave (hdlhashtable, bigstring);
+extern boolean langexternalpleasesave ( hdlhashtable, const Handle );
extern boolean langexternaltypestring (hdlexternalhandle, bigstring);
@@ -231,19 +232,19 @@
extern boolean langexternalgetowningwindow (hdlwindowinfo *);
-extern void langexternalquotename (bigstring);
+extern void langexternalquotename ( Handle );
-extern void langexternalbracketname (bigstring);
+extern void langexternalbracketname ( Handle );
-extern boolean langexternalgetfullpath (hdlhashtable, bigstring, bigstring, hdlwindowinfo *);
+extern boolean langexternalgetfullpath ( hdlhashtable, const Handle, Handle *, hdlwindowinfo * );
-extern boolean langexternalgetquotedpath (hdlhashtable, bigstring, bigstring);
+extern boolean langexternalgetquotedpath (hdlhashtable, const Handle, Handle * );
extern boolean langexternalgetexternalparam (hdltreenode, short, short *, hdlexternalvariable *);
-extern boolean langexternalzoomfrom (tyvaluerecord, hdlhashtable, bigstring, rectparam);
+extern boolean langexternalzoomfrom ( tyvaluerecord, hdlhashtable, Handle *, rectparam );
-extern boolean langexternalzoom (tyvaluerecord, hdlhashtable, bigstring);
+extern boolean langexternalzoom ( tyvaluerecord, hdlhashtable, Handle * );
extern boolean langexternalzoomfilewindow (const tyvaluerecord *, ptrfilespec, boolean);
@@ -279,7 +280,7 @@
extern boolean langexternalsettimes (hdlexternalhandle, long, long, hdlhashnode);
-extern boolean langexternalfindusedblocks (hdlexternalhandle, bigstring);
+extern boolean langexternalfindusedblocks ( hdlexternalhandle, const Handle );
extern boolean langexternaltitleclick (Point, hdlexternalvariable);
@@ -303,11 +304,9 @@
extern boolean hashstatsverb (tyvaluerecord *v);
-extern boolean langexternalsymbolchanged (hdlhashtable htable, const bigstring bsname, hdlhashnode hnode, boolean flvalue);
+extern boolean langexternalsymbolchanged ( hdlhashtable, const Handle, hdlhashnode, boolean );
-extern boolean langexternalsymbolinserted (hdlhashtable htable, const bigstring bsname, hdlhashnode hnode);
+extern boolean langexternalsymbolinserted ( hdlhashtable, const Handle, hdlhashnode );
#endif
-
-
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/headers/langinternal.h
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/headers/langinternal.h 2007-02-24 00:04:28 UTC (rev 1625)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/headers/langinternal.h 2007-02-25 01:45:06 UTC (rev 1626)
@@ -272,6 +272,7 @@
anomynousthreadstring,
appleeventthreadstring
+
};
@@ -333,7 +334,7 @@
extern DialogPtr langmodaldialog;
-extern bigstring bsfunctionname;
+extern Handle handleFunctionName;
extern boolean flstackoverflow; /*langops.c*/
@@ -348,10 +349,12 @@
//extern short flextendedsymbolsearch;
-/*prototypes*/
+// prototypes
-extern boolean langpushlocalchain (hdlhashtable *); /*langcallbacks.c*/
+#pragma mark === langcallbacks.c ===
+extern boolean langpushlocalchain (hdlhashtable *);
+
extern boolean langpoplocalchain (hdlhashtable);
extern boolean languserescaped (boolean);
@@ -364,7 +367,7 @@
extern boolean langrestoreglobals (void);
-extern boolean langpushsourcecode (hdlhashtable, hdlhashnode, bigstring);
+extern boolean langpushsourcecode ( hdlhashtable, hdlhashnode, const Handle );
extern boolean langpopsourcecode (void);
@@ -399,53 +402,65 @@
extern boolean langrundialog (hdltreenode, tyvaluerecord *);
-extern boolean langdialogstart (void); /*langdialog.c*/
+#pragma mark === langdialog.c ===
+extern boolean langdialogstart (void);
-extern void parseerror (bigstring); /*langerror.c*/
+#pragma mark === langerror.c ===
-extern hdlerrorstack langerrorgetstack (void); /*langerrorwindow.c*/
+extern void parseerror (bigstring);
+
+#pragma mark === langerrorwindow.c ===
+
+extern hdlerrorstack langerrorgetstack (void);
+
extern boolean langerrorstart (void);
-extern void langseterrorline (hdltreenode); /*langevaluate.c*/
+#pragma mark === langevaluate.c ===
-extern boolean langrunscript (bigstring, tyvaluerecord *, hdlhashtable, tyvaluerecord *);
+extern void langseterrorline (hdltreenode);
extern boolean evaluatetree (hdltreenode, tyvaluerecord *);
extern boolean evaluatelist (hdltreenode, tyvaluerecord *);
-extern boolean hashflushcache (long *); /*langhash.h*/
+#pragma mark === langhash.h ===
-extern short hashfunction (const bigstring);
+extern boolean hashflushcache (long *);
+extern short hashfunction ( const Handle );
+
extern boolean hashresolvevalue (hdlhashtable, hdlhashnode);
-extern boolean langrunmodeless (hdltreenode, tyvaluerecord *); /*langmodeless.c*/
+#pragma mark === langmodeless.c ===
+extern boolean langrunmodeless (hdltreenode, tyvaluerecord *);
-extern boolean langheaptype (tyvaluetype); /*langops.c*/
+#pragma mark === langops.c ===
+
+extern boolean langheaptype (tyvaluetype);
+
extern boolean langheapallocated (tyvaluerecord *, Handle *);
-extern void langgetwithvaluename (short, bigstring);
+extern void langgetwithvaluename ( short, Handle * );
extern boolean langgetvalsize (tyvaluerecord, long *);
extern boolean langgetstringlist (short, bigstring);
-extern boolean langgetmiscstring (short, bigstring);
+extern boolean langgetmiscstring ( short, bigstring, Handle * );
extern boolean langcheckstacklimit (tystackid, short, short);
extern void langbadexternaloperror (short, tyvaluerecord);
-extern void langarrayreferror (short, bigstring, const tyvaluerecord *, tyvaluerecord *);
+extern void langarrayreferror ( short, const Handle, const tyvaluerecord *, tyvaluerecord * );
extern boolean langfindexternalwindow (const bigstring, Handle *);
@@ -453,32 +468,38 @@
extern boolean langsetuserflag (short, boolean);
-extern boolean langgetthisaddress (hdlhashtable *, bigstring);
+extern boolean langgetthisaddress ( hdlhashtable *, Handle * );
-extern boolean langsetthisvalue (hdlhashtable, hdlhashtable, bigstring);
+extern boolean langsetthisvalue ( hdlhashtable, hdlhashtable, const Handle );
-extern boolean langfastaddresstotable (hdlhashtable, bigstring, hdlhashtable *);
+extern boolean langfastaddresstotable ( hdlhashtable, const Handle, const bigstring, hdlhashtable * );
extern boolean langvaltocode (tyvaluerecord *vcode, hdltreenode *hcode); //02/04/02 dmb
extern boolean langfollowifaddressvalue (tyvaluerecord *v);
-extern boolean isfirstidentifierchar (byte ch); /*langscan.c*/
+#pragma mark === langscan.c ===
+extern boolean isfirstidentifierchar (byte ch);
+
extern boolean isidentifierchar (byte ch);
-extern boolean langisidentifier (bigstring);
+extern boolean langisidentifier ( const Handle );
extern boolean langdeparsestring (bigstring, byte);
+extern boolean langDeparseTextHandle ( Handle, byte );
+
extern boolean langstriptextsyntax (Handle);
extern boolean langaddapplescriptsyntax (Handle);
-extern void langstarttrace (void); /*langtrace.c*/
+#pragma mark === langtrace.c ===
+extern void langstarttrace (void);
+
extern void langendtrace (void);
extern void langtrace (bigstring);
@@ -486,8 +507,10 @@
extern void langsyntaxtrace (boolean);
-extern boolean langvisitcodetree (hdltreenode, langtreevisitcallback, ptrvoid); /*langtree.c*/
+#pragma mark === langtree.c ===
+extern boolean langvisitcodetree (hdltreenode, langtreevisitcallback, ptrvoid);
+
extern short langcounttreenodes (hdltreenode);
extern boolean newconstnode (tyvaluerecord, hdltreenode *);
@@ -529,8 +552,10 @@
extern boolean langcopytree (hdltreenode, hdltreenode *);
-extern boolean stringtoaddress (tyvaluerecord *); /*langvalue.c*/
+#pragma mark === langvalue.c ===
+extern boolean stringtoaddress (tyvaluerecord *);
+
extern boolean stringisboolean (bigstring bs, boolean *flboolean);
extern void pullstringvalue (const tyvaluerecord *, bigstring);
@@ -545,7 +570,7 @@
extern boolean langcoerceerror (tyvaluerecord *, tyvaluetype);
-extern boolean langgetdottedsymbolval (hdltreenode, hdlhashtable *, bigstring, tyvaluerecord *, hdlhashnode *);
+extern boolean langgetdottedsymbolval ( hdltreenode, hdlhashtable *, Handle*, tyvaluerecord *, hdlhashnode * );
extern boolean idvalue (hdltreenode, tyvaluerecord *);
@@ -565,25 +590,34 @@
extern boolean incrementvalue (boolean, boolean, hdltreenode, tyvaluerecord *);
-extern boolean langgetnodecode (hdlhashtable, bigstring, hdlhashnode, hdltreenode *);
+extern boolean langgetnodecode ( hdlhashtable, const Handle, hdlhashnode, hdltreenode * );
extern boolean evaluatereadonlyparam (hdltreenode hparam, tyvaluerecord *vparam);
+extern boolean setAddressValueFromHandle ( const Handle, tyvaluerecord * );
-extern boolean langinitbuiltins (void); /*langverbs.h*/
+#pragma mark === langverbs.h ===
+
+extern boolean langinitbuiltins (void);
+
extern boolean langreleasesemaphores (hdlprocessrecord);
-// langxml.c
+#pragma mark === langxml.c ===
extern boolean langisremotefunction (hdltreenode htree);
extern boolean langremotefunctioncall (hdltreenode htree, hdltreenode hparam1, tyvaluerecord *vreturned);
-// lang.c
-extern boolean langrunscriptcode (hdlhashtable htable, bigstring bsverb, hdltreenode hcode, tyvaluerecord *vparams, hdlhashtable hcontext, tyvaluerecord *vreturned);
+#pragma mark === lang.c ===
+extern boolean langrunscript ( const Handle, tyvaluerecord *, hdlhashtable, tyvaluerecord * );
-#endif /*langinternalinclude*/
+extern boolean langRunScriptBigstring ( const bigstring, tyvaluerecord *, hdlhashtable, tyvaluerecord * );
+
+extern boolean langrunscriptcode ( hdlhashtable, const Handle, hdltreenode, tyvaluerecord *, hdlhashtable, tyvaluerecord * );
+
+#endif // langinternalinclude
+
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/headers/langipc.h
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/headers/langipc.h 2007-02-24 00:04:28 UTC (rev 1625)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/headers/langipc.h 2007-02-25 01:45:06 UTC (rev 1626)
@@ -84,7 +84,7 @@
#endif
-extern boolean langipcfindapptable (OSType , boolean, hdlhashtable *, bigstring);
+extern boolean langipcfindapptable ( OSType, boolean, hdlhashtable *, Handle * );
extern boolean langipcbrowsenetwork (hdltreenode, tyvaluerecord *);
@@ -122,11 +122,11 @@
extern boolean langipctablemessage (hdltreenode, tyvaluerecord *);
-extern boolean langipcbuildsubroutineevent (AppleEvent *, bigstring, hdltreenode);
+extern boolean langipcbuildsubroutineevent ( AppleEvent *, Handle *, hdltreenode );
-extern boolean langipchandlercall (hdltreenode, bigstring, hdltreenode, tyvaluerecord *);
+extern boolean langipchandlercall ( hdltreenode, Handle *, hdltreenode, tyvaluerecord * );
-extern boolean langipckernelfunction (hdlhashtable, bigstring, hdltreenode, tyvaluerecord *);
+extern boolean langipckernelfunction ( hdlhashtable, Handle, hdltreenode, tyvaluerecord * );
extern boolean langipcshowmenunode (long);
@@ -139,15 +139,17 @@
extern boolean langipcinit (void);
-extern boolean langipcgetmenuhandle (OSType, short, Handle *); /*langipcmenus.c*/
+#pragma mark === langipcmenus.c ===
+extern boolean langipcgetmenuhandle (OSType, short, Handle *);
+
#ifdef flnewfeatures
-extern boolean langipcgetitemlangtext (long, short, short, Handle *, long *);
+ extern boolean langipcgetitemlangtext (long, short, short, Handle *, long *);
-extern boolean langipccheckformulas (long);
+ extern boolean langipccheckformulas (long);
-extern void langipcdisposemenuarray (long, Handle);
+ extern void langipcdisposemenuarray (long, Handle);
#endif
@@ -161,14 +163,11 @@
extern boolean langipcmenushutdown (void);
-extern boolean langipcsymbolchanged (hdlhashtable, const bigstring, boolean);
+extern boolean langipcsymbolchanged ( hdlhashtable, const Handle, boolean );
-extern boolean langipcsymbolinserted (hdlhashtable, const bigstring);
+extern boolean langipcsymbolinserted ( hdlhashtable, const Handle );
-extern boolean langipcsymboldeleted (hdlhashtable, const bigstring);
+extern boolean langipcsymboldeleted (hdlhashtable, const Handle );
extern boolean langipcmenuinit (void);
-
-
-
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/source/langhash.c
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/source/langhash.c 2007-02-24 00:04:28 UTC (rev 1625)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/source/langhash.c 2007-02-25 01:45:06 UTC (rev 1626)
@@ -46,10 +46,9 @@
#include "timedate.h"
#include "byteorder.h" /* 2006-04-08 aradke: endianness conversion macros */
-#if TARGET_API_MAC_CARBON == 1 /*PBS 03/14/02: AE OS X fix.*/
- #include "aeutils.h" /*PBS 03/14/02: AE OS X fix.*/
-#endif
+#include "aeutils.h" /*PBS 03/14/02: AE OS X fix.*/
+
typedef struct tydisksymbolrecord {
long ixkey; /*in the string handle, where is this symbol's name?*/
@@ -61,6 +60,7 @@
tyvaluedata data; /*if a string, this stores an index into the string handle*/
} tydisksymbolrecord, *ptrdisksymbolrecord, **hdldisksymbolrecord;
+
typedef struct tyOLD42disksymbolrecord {
long ixkey; /*in the string handle, where is this symbol's name?*/
@@ -77,8 +77,7 @@
} tyOLD42disksymbolrecord, *ptrOLD42disksymbolrecord, **hdlOLD42disksymbolrecord;
-// 5.0.1: bumped version number so we can clear uninitialized flags
-#define tablediskversion 0x03
+#define tablediskversion 0x04 // 2006-12-30 creedon: bumped version number, hashkey is stored as handle not Str255
typedef struct tydisktablerecord { /*new in 5.0, a header for each table*/
@@ -90,6 +89,7 @@
unsigned long timecreated, timelastsave; /*number of seconds since 1/1/04*/
long flags;
+
} tydisktablerecord, *ptrdisktablerecord, **hdldisktablerecord;
@@ -107,11 +107,13 @@
#define maxinlinescalarsize 1023
#define diskvalsizeflag (-1)
+
typedef struct tydiskvaluerecord { /*4.0.1b1 dmb*/
long sizeflag; /*always -1*/
dbaddress adr; /*addres of actual scalar value*/
+
} tydiskvaluerecord;
@@ -161,240 +163,245 @@
#endif
-static void hashaddrefnode (hdlhashtable ht, hdlhashnode hn) {
-
- /*
- 2003-05-21 AR: Insert the node at the beginning of the table's
- linked list of nodes that reference it.
-
- This is so that right before the table gets disposed, it can notify
- the nodes that the addresses they contain are about to become invalid.
- Not only are they pointing at an object that will no longer exist
- in the namespace, worse, the handle tacked onto the end of the address
- string will soon point at a block of memory that was already released!
-
- For now, we only keep track of nodes referencing a local table.
-
- Note that references to global tables can become invalid, too, if a
- database file is closed while an address pointing into it is part
- of some thread's stack of local variables.
- */
+ static void hashaddrefnode (hdlhashtable ht, hdlhashnode hn) {
+
+ /*
+ 2003-05-21 AR: Insert the node at the beginning of the table's
+ linked list of nodes that reference it.
+
+ This is so that right before the table gets disposed, it can notify
+ the nodes that the addresses they contain are about to become invalid.
+ Not only are they pointing at an object that will no longer exist
+ in the namespace, worse, the handle tacked onto the end of the address
+ string will soon point at a block of memory that was already released!
+
+ For now, we only keep track of nodes referencing a local table.
+
+ Note that references to global tables can become invalid, too, if a
+ database file is closed while an address pointing into it is part
+ of some thread's stack of local variables.
+ */
- assert (ht != nil);
-
- assert ((**ht).fllocaltable);
-
- assert (hn != nil);
-
- assert ((**hn).val.valuetype == addressvaluetype);
-
- assert ((**hn).refnodelink == nil);
-
- (**hn).refnodelink = (**ht).refnodes;
-
- (**ht).refnodes = hn;
+ assert (ht != nil);
+
+ assert ((**ht).fllocaltable);
+
+ assert (hn != nil);
+
+ assert ((**hn).val.valuetype == addressvaluetype);
+
+ assert ((**hn).refnodelink == nil);
+
+ (**hn).refnodelink = (**ht).refnodes;
+
+ (**ht).refnodes = hn;
- #ifdef fldebug
- ++ctrefnodesadded;
- #endif
- } /*hashaddrefnode*/
+ #ifdef fldebug
+ ++ctrefnodesadded;
+ #endif
+ } /*hashaddrefnode*/
-static void hashremoverefnode (hdlhashtable ht, hdlhashnode hn) {
+ static void hashremoverefnode (hdlhashtable ht, hdlhashnode hn) {
- /*
- 2003-05-21 AR: Complements hashaddrefnode.
- Remove the given node from the table's linked list.
-
- 2003-06-14 AR: Commented out an over-eager assertion.
- */
+ /*
+ 2003-05-21 AR: Complements hashaddrefnode.
+ Remove the given node from the table's linked list.
+
+ 2003-06-14 AR: Commented out an over-eager assertion.
+ */
- assert (ht != nil);
-
- assert ((**ht).fllocaltable);
-
- assert ((**ht).refnodes != nil);
-
- assert (hn != nil);
-
- // assert ((**hn).val.valuetype == addressvaluetype); /* this may no longer be true */
-
- if ((**ht).refnodes == hn) {
-
- (**ht).refnodes = (**hn).refnodelink;
-
- (**hn).refnodelink = nil;
- }
- else {
-
- hdlhashnode nomad = (**ht).refnodes;
-
- while ((**nomad).refnodelink != nil) {
+ assert (ht != nil);
+
+ assert ((**ht).fllocaltable);
+
+ assert ((**ht).refnodes != nil);
+
+ assert (hn != nil);
+
+ // assert ((**hn).val.valuetype == addressvaluetype); /* this may no longer be true */
+
+ if ((**ht).refnodes == hn) {
+
+ (**ht).refnodes = (**hn).refnodelink;
+
+ (**hn).refnodelink = nil;
+ }
+ else {
+
+ hdlhashnode nomad = (**ht).refnodes;
+
+ while ((**nomad).refnodelink != nil) {
- if ((**nomad).refnodelink == hn) {
-
- (**nomad).refnodelink = (**hn).refnodelink;
+ if ((**nomad).refnodelink == hn) {
- (**hn).refnodelink = nil;
+ (**nomad).refnodelink = (**hn).refnodelink;
+
+ (**hn).refnodelink = nil;
+
+ break;
+ } /*while*/
- break;
- } /*while*/
+ nomad = (**nomad).refnodelink;
+ }
+ }
- nomad = (**nomad).refnodelink;
- }
- }
-
- assert ((**hn).refnodelink == nil); /*check that we found it*/
+ assert ((**hn).refnodelink == nil); /*check that we found it*/
- #ifdef fldebug
- ++ctrefnodesremoved;
- #endif
- } /*hashremoverefnode*/
+ #ifdef fldebug
+ ++ctrefnodesremoved;
+ #endif
+ } /*hashremoverefnode*/
-void hashregisteraddressnode (hdlhashtable hparent, hdlhashnode hn) {
+ void hashregisteraddressnode (hdlhashtable hparent, hdlhashnode hn) {
- /*
- 2003-05-21 AR: Call me if the valuerecord of hn has just been
- assigned a new value. If it's an address of a local variable,
- we will register hn with the table that contains the local variable.
-
- When the table is about to be disposed, it can notify us of the fact
- that our address value is about to point to an invalid handle.
-
- Optimization: We don't have to register hn with the destination table
- if hn lives in a stack frame that will be disposed before (or at worst
- at the same time) as the destination table. For this to work properly,
- we have to make sure that if hn is unlinked and inserted into another
- table (or the same table), e.g. via copy&paste, we unregister and
- register hn again.
-
- Actually, the above should work but its probably not a useful optimization.
- Just check whether the table containing hn and the destination table are
- identical. This should already apply to a lot of cases.
- */
-
- assert ((**hn).reftable == nil);
-
- if ((**hn).val.valuetype == addressvaluetype && (**hn).reftable == nil) {
+ /*
+ 2003-05-21 AR: Call me if the valuerecord of hn has just been
+ assigned a new value. If it's an address of a local variable,
+ we will register hn with the table that contains the local variable.
- hdlhashtable hdest;
- bigstring bsname;
- boolean fl;
+ When the table is about to be disposed, it can notify us of the fact
+ that our address value is about to point to an invalid handle.
- disablelangerror ();
+ Optimization: We don't have to register hn with the destination table
+ if hn lives in a stack frame that will be disposed before (or at worst
+ at the same time) as the destination table. For this to work properly,
+ we have to make sure that if hn is unlinked and inserted into another
+ table (or the same table), e.g. via copy&paste, we unregister and
+ register hn again.
- fl = getaddressvalue ((**hn).val, &hdest, bsname);
-
- enablelangerror ();
-
- if (!fl || (hdest == nil) || !(**hdest).fllocaltable)
- return;
-
- if (hparent == hdest) /*don't bother...*/
- return;
-
- /*
- if ((**hparent).fllocaltable) { //optimization?
+ Actually, the above should work but its probably not a useful optimization.
+ Just check whether the table containing hn and the destination table are
+ identical. This should already apply to a lot of cases.
+ */
- register hdlhashtable nomad = hparent;
+ assert ((**hn).reftable == nil);
+
+ if ((**hn).val.valuetype == addressvaluetype && (**hn).reftable == nil) {
- while ((**nomad).parenthashtable != nil) { //surface to stack frame
- nomad = (**nomad).parenthashtable;
- }
+ hdlhashtable hdest;
+ bigstring bsname;
+ boolean fl;
- while (nomad != nil && (**nomad).fllocaltable) { //walk chain and check whether hdest is in it
+ disablelangerror ();
+
+ fl = getaddressvalue ((**hn).val, &hdest, bsname);
+
+ enablelangerror ();
+
+ if (!fl || (hdest == nil) || !(**hdest).fllocaltable)
+ return;
+
+ if (hparent == hdest) /*don't bother...*/
+ return;
+
+ /*
+ if ((**hparent).fllocaltable) { //optimization?
- if (nomad == hdest)
- return;
+ register hdlhashtable nomad = hparent;
+
+ while ((**nomad).parenthashtable != nil) { //surface to stack frame
+ nomad = (**nomad).parenthashtable;
+ }
+
+ while (nomad != nil && (**nomad).fllocaltable) { //walk chain and check whether hdest is in it
- nomad = (**nomad).prevhashtable;
+ if (nomad == hdest)
+ return;
+
+ nomad = (**nomad).prevhashtable;
+ }
}
+ */
+
+ hashaddrefnode (hdest, hn);
+
+ (**hn).reftable = hdest;
+
}
- */
-
- hashaddrefnode (hdest, hn);
- (**hn).reftable = hdest;
- }
- } /*hashregisteraddressnode*/
+ } /*hashregisteraddressnode*/
-void hashunregisteraddressnode (hdlhashnode hn) {
+ void hashunregisteraddressnode (hdlhashnode hn) {
- /*
- 2003-05-21 AR: Call me if the valuerecord of hn has changed
- or if hn itself is about to be disposed.
- */
-
- if ((**hn).reftable != nil) {
-
- hashremoverefnode ((**hn).reftable, hn);
+ /*
+ 2003-05-21 AR: Call me if the valuerecord of hn has changed
+ or if hn itself is about to be disposed.
+ */
- (**hn).reftable = nil;
- }
- } /*hashunregisteraddressnode*/
+ if ((**hn).reftable != nil) {
+ hashremoverefnode ((**hn).reftable, hn);
+
+ (**hn).reftable = nil;
+
+ }
+
+ } /*hashunregisteraddressnode*/
-static void hashinvalidaterefnodes (hdlhashtable ht) {
-
- /*
- 2003-05-21 AR: The hash table is about to be disposed, so notify
- all hash nodes containing an address that reference the table
- of the fact that they are about to become invalid.
-
- Call me from disposehashtable after it has disposed of its nodes.
-
- 2003-05-23 AR: Set refnodes field to nil so we won't crash
- if we are called multiple times for the same table. Also, try
- to get the full path representation of the address, but this
- will only work if the table hasn't been removed from the
- namespace yet.
- */
- hdlhashnode hn, hnext;
- bigstring bspath;
+ static void hashinvalidaterefnodes (hdlhashtable ht) {
- assert (ht != nil);
-
- hn = (**ht).refnodes; /*unlink list from table*/
-
- (**ht).refnodes = nil;
-
- disablelangerror (); /*must re-enable before we return*/
-
- while (hn != nil) {
+ /*
+ 2003-05-21 AR: The hash table is about to be disposed, so notify
+ all hash nodes containing an address that reference the table
+ of the fact that they are about to become invalid.
- assert ((**hn).reftable == ht);
- assert ((**hn).val.valuetype == addressvaluetype);
+ Call me from disposehashtable after it has disposed of its nodes.
- hnext = (**hn).refnodelink;
+ 2003-05-23 AR: Set refnodes field to nil so we won't crash
+ if we are called multiple times for the same table. Also, try
+ to get the full path representation of the address, but this
+ will only work if the table hasn't been removed from the
+ namespace yet.
+ */
+
+ hdlhashnode hn, hnext;
+ bigstring bspath;
+
+ assert (ht != nil);
- /* unlink */
+ hn = (**ht).refnodes; /*unlink list from table*/
- (**hn).refnodelink = nil;
+ (**ht).refnodes = nil;
+
+ disablelangerror (); /*must re-enable before we return*/
- (**hn).reftable = nil;
+ while (hn != nil) {
+
+ assert ((**hn).reftable == ht);
+ assert ((**hn).val.valuetype == addressvaluetype);
+
+ hnext = (**hn).refnodelink;
+
+ /* unlink */
+
+ (**hn).refnodelink = nil;
+
+ (**hn).reftable = nil;
+
+ /* nuke the htable handle tacked onto the item name */
+
+ getaddresspath ((**hn).val, bspath);
+
+ sethandlecontents (bspath, stringsize (bspath), (Handle) (**hn).val.data.addressvalue);
+
+ #if fldebug
+ ++ctrefnodesinvalidated;
+ #endif
+
+ /* advance */
+
+ hn = hnext;
+
+ } /*while*/
+
+ enablelangerror ();
- /* nuke the htable handle tacked onto the item name */
-
- getaddresspath ((**hn).val, bspath);
-
- sethandlecontents (bspath, stringsize (bspath), (Handle) (**hn).val.data.addressvalue);
-
- #if fldebug
- ++ctrefnodesinvalidated;
- #endif
-
- /* advance */
-
- hn = hnext;
- } /*while*/
+ } /*hashinvalidaterefnodes*/
- enablelangerror ();
-
- } /*hashinvalidaterefnodes*/
-
#endif /*fltracklocaladdresses*/
@@ -420,6 +427,7 @@
hmagictable = nil;
return (true);
+
}
#ifdef fldebug
@@ -444,6 +452,7 @@
*htable = ht;
return (true);
+
}
if (!newclearhandle (sizeof (tyhashtable), (Handle *) htable))
@@ -452,6 +461,7 @@
(***htable).timecreated = timenow ();
return (true);
+
} /*newhashtable*/
@@ -490,6 +500,7 @@
(**ht).flchained = true;
currenthashtable = ht;
+
} /*chainhashtable*/
@@ -507,48 +518,10 @@
(**ht).flchained = false;
currenthashtable = hprev;
+
} /*unchainhashtable*/
-#if 0
-
-static boolean indexhashtable_obsolete (short tablenum, hdlhashtable *htable) {
-
- /*
- turn an index into a hash table. the most-global hashtable has index 0.
- its previous table is index 1.
-
- you can safely ask for the most-global one by asking for table number
- infinity, but watch out -- we return false if we fell off the list.
- */
-
- register hdlhashtable nomad = currenthashtable;
- register hdlhashtable prevnomad = nomad;
- register short ct = tablenum;
- register short i;
-
- for (i = 1; i <= ct; i++) {
-
- if (nomad == nil) { /*ran out of tables, return most-global table*/
-
- *htable = prevnomad;
-
- return (false);
- }
-
- prevnomad = nomad;
-
- nomad = (**nomad).prevhashtable;
- } /*for*/
-
- *htable = nomad;
-
- return (true);
- } /*indexhashtable*/
-
-#endif
-
-
hdlhashtable sethashtable (hdlhashtable hset) {
/*
@@ -560,6 +533,7 @@
currenthashtable = hset;
return (hprev);
+
} /*sethashtable*/
@@ -585,6 +559,7 @@
/*stacktracer (toptables);*/
return (true);
+
} /*pushhashtable*/
@@ -597,6 +572,7 @@
shellinternalerror (idtoomanypophashtables, STR_too_many_pophashtables);
return (false);
+
}
currenthashtable = (**hs).stack [--(**hs).toptables];
@@ -604,6 +580,7 @@
/*stacktracer (toptables);*/
return (true);
+
} /*pophashtable*/
@@ -629,11 +606,12 @@
return (pushhashtable (ht));
ht = hprev;
+
} /*while*/
+
} /*pushouterlocaltable*/
-
#ifdef smartmemory
@@ -811,9 +789,11 @@
*ctbytesneeded -= gethandlesize ((Handle) hfreetable);
disposehandle ((Handle) hfreetable);
+
}
return (true);
+
} /*hashflushcache*/
@@ -838,32 +818,35 @@
}
*/
-#ifdef fltracklocaladdresses
- hashunregisteraddressnode (hnode);
-#endif
+ #ifdef fltracklocaladdresses
+
+ hashunregisteraddressnode (hnode);
+
+ #endif
if (fldisposevalue) {
-
+
boolean flneeddatabase = (fldisk && (**hn).val.fldiskval);
hdldatabaserecord hdb = nil;
-
+
if (flneeddatabase) {
-
+
hdb = tablegetdatabase (ht);
if (hdb)
dbpushdatabase (hdb);
}
-
+
disposevaluerecord ((**hn).val, fldisk);
if (flneeddatabase && hdb)
dbpopdatabase ();
}
-
+
disposehandle ((Handle) hn);
return (true);
+
} /*disposehashnode*/
@@ -872,22 +855,26 @@
(**ht).fldirty = true;
(**ht).timelastsave = timenow ();
+
} /*dirtyhashtable*/
static short smashhashtable (hdlhashtable htable, boolean fldisk, boolean flcallback) {
+
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+ // 1996-04-25 ( 4.0b7 ) dmb: pulled this code out of disposehashtable so we
+ // could make a verb out of it. had to add the flcallback parameter, since
+ // disposehashtable doesn't want to.
+ //
- /*
- 4.0b7 4/25/96 dmb: pulled this code out of disposehashtable
- so we could make a verb out of it. had to add the flcallback parameter,
- since disposehashtable doesn't want to.
- */
-
+ register hdlhashnode nomad, nextnomad;
register hdlhashtable ht = htable;
- register hdlhashnode nomad, nextnomad;
register short i;
+
+ Handle h;
short ctdisposed = 0;
- bigstring bs;
if (ht == nil) /*easy to dispose of nil table*/
return (0);
@@ -905,7 +892,7 @@
nextnomad = (**nomad).hashlink;
if (flcallback)
- gethashkey (nomad, bs);
+ gethashkey (nomad, &h);
if (flcallback)
langsymbolunlinking (ht, nomad);
@@ -913,27 +900,40 @@
disposehashnode (ht, nomad, true, fldisk);
if (flcallback)
- langsymboldeleted (ht, bs);
+ langsymboldeleted (ht, h);
++ctdisposed;
+ if ( ctdisposed == 59 ) {
+
+ boolean fl;
+
+ fl = true;
+
+ }
+
nomad = nextnomad;
+
} /*while*/
+
} /*for*/
dirtyhashtable (ht);
- return (ctdisposed);
+ return (ctdisposed);
+
} /*smashhashtable*/
short emptyhashtable (hdlhashtable htable, boolean fldisk) {
return (smashhashtable (htable, fldisk, true));
+
} /*emptyhashtable*/
+
boolean disposehashtable (hdlhashtable htable, boolean fldisk) {
-
+
/*
7/10/90 DW: if it's a local table, don't dispose of any code trees linked
in as values.
@@ -950,11 +950,11 @@
if (ht == nil) /*easy to dispose of nil table*/
return (true);
-
+
#ifdef fldebug
- --cthashtablesallocated;
-
+ --cthashtablesallocated;
+
#endif
if (ht == roottable) { /*very serious internal error*/
@@ -962,6 +962,7 @@
shellinternalerror (iddisposingsystemtable, STR_trying_to_dispose_global_symbol_table);
return (false);
+
}
if ((**ht).flchained) { /*table is in local chain; can't dispose now*/
@@ -969,6 +970,7 @@
(**ht).fldisposewhenunchained = true; /*we'll do it later*/
return (true);
+
}
pushhashtable (ht);
@@ -978,6 +980,7 @@
pophashtable ();
smashhashtable (ht, fldisk, false);
+
/*
for (i = 0; i < ctbuckets; i++) {
@@ -1002,10 +1005,12 @@
}
*/
-#ifdef fltracklocaladdresses
- hashinvalidaterefnodes (ht);
-#endif
+ #ifdef fltracklocaladdresses
+ hashinvalidaterefnodes (ht);
+
+ #endif
+
(**ht).prevhashtable = hfirstfreetable;
hfirstfreetable = ht;
@@ -1014,44 +1019,47 @@
disposehandle ((Handle) ht);
*/
- return (true);
+ return (true);
+
} /*disposehashtable*/
-short hashfunction (const bigstring bs) {
+short hashfunction ( const Handle h ) {
- /*
- 3.0.4b8 dmb: need to make locals unsigned to protect against ctype's int's
- */
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+ // 2006-12-05 creedon: use text handle instead of bigstring
+ //
+ // 3.0.4b8 dmb: need to make locals unsigned to protect against ctype's int's
+ //
-// register unsigned short c;
- register unsigned short len;
-// register ptrstring p = (ptrstring) bs;
- register unsigned short val;
-
- len = stringlength (bs);
+ register unsigned short len, val, val2;
+ register ptrbyte p = ( ptrbyte ) *h;
- if (len == 0)
- return (0);
+ len = gethandlesize ( h );
-// c = p [1];
+ if ( len == 0 )
+ return ( 0 );
+
+ val = getlower ( p [ 0 ] );
- val = getlower(getstringcharacter(bs,0));
+ val2 = getlower ( p [ len - 1 ] );
-// c = p [len];
+ val += val2;
- val += getlower(getstringcharacter(bs,len-1));
+ return ( val % ctbuckets );
- return (val % ctbuckets);
- } /*hashfunction*/
+ } // hashfunction
static boolean hashsortedinsert (hdlhashnode hnode) {
- register hdlhashnode hn = hnode;
+ register hdlhashnode hn = hnode, nomadprev = nil;
register hdlhashtable ht = currenthashtable;
+
register hdlhashnode nomad = (**ht).hfirstsort;
- register hdlhashnode nomadprev = nil;
+
short comparison;
if (nomad == nil) { /*first guy in sorted list*/
@@ -1061,6 +1069,7 @@
(**hn).sortedlink = nil;
return (true);
+
}
while (true) {
@@ -1076,6 +1085,7 @@
(**ht).hfirstsort = hn;
return (true);
+
}
(**hn).sortedlink = nomad; /*insert in before nomad, middle of list*/
@@ -1083,6 +1093,7 @@
(**nomadprev).sortedlink = hn;
return (true);
+
}
nomadprev = nomad; /*advance to next node in list*/
@@ -1096,8 +1107,11 @@
(**nomadprev).sortedlink = hn;
return (true);
+
}
+
} /*while*/
+
} /*hashsortedinsert*/
@@ -1131,38 +1145,51 @@
} /*hashsorteddelete*/
-static boolean hashlinknode (hdlhashtable htable, hdlhashnode hnode) {
+static boolean hashlinknode ( hdlhashtable htable, hdlhashnode hnode ) {
+
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
- register hdlhashnode hn = hnode;
+ register Handle h;
+ register hdlhashnode hn = hnode, hnext;
register hdlhashtable ht = htable;
register short ixbucket;
- register hdlhashnode hnext;
- ixbucket = hashfunction ((**hn).hashkey);
+ gethashkey ( hn, &h );
- hnext = (**ht).hashbucket [ixbucket];
+ ixbucket = hashfunction ( h );
- (**ht).hashbucket [ixbucket] = hnode; /*link new guy at head of list*/
+ disposehandle ( h );
- (**hn).hashlink = hnext;
+ hnext = ( **ht ).hashbucket [ ixbucket ];
- return (true);
- } /*hashlinknode*/
+ ( **ht ).hashbucket [ ixbucket ] = hnode; // link new guy at head of list
+ ( **hn ).hashlink = hnext;
+
+ return ( true );
+
+ } // hashlinknode
+
boolean hashinsertnode (hdlhashnode hnode, hdlhashtable htable) {
+
+ //
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+ // 1993-03-23 dmb: don't invoke callback when flunpackingtable flag is set
+ //
- /*
- 3/23/93 dmb: don't invoke callback when flunpackingtable flag is set
- */
-
register hdlhashnode hn = hnode;
register hdlhashtable ht = htable;
- bigstring bs;
+ Handle h;
+
hashlinknode (ht, hn);
- if (flunpackingtable) /*tableunpack will take care of sort links*/
+ if (flunpackingtable) // tableunpack will take care of sort links
return (true);
pushhashtable (ht);
@@ -1173,13 +1200,16 @@
dirtyhashtable (ht);
- gethashkey (hn, bs);
+ gethashkey ( hn, &h );
- langsymbolinserted (ht, bs, hn);
+ langsymbolinserted ( ht, h, hn );
+ disposehandle ( h );
+
return (true);
- } /*hashinsertnode*/
+ } // hashinsertnode
+
boolean hashunlinknode (hdlhashtable htable, hdlhashnode hnode) {
@@ -1220,61 +1250,77 @@
} /*hashunlinknode*/
-boolean hashsetnodekey (hdlhashtable htable, hdlhashnode hnode, const bigstring bs) {
+boolean hashsetnodekey ( hdlhashtable htable, hdlhashnode hnode, const Handle h ) {
+
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
- if (!sethandlesize ((Handle) hnode, sizeof (tyhashnode) + stringsize (bs)))
- return (false);
+ long size = sizeof ( tyhashnode ) + sizeof ( short ) + gethandlesize ( h );
- hashunlinknode (htable, hnode);
+ if ( ! sethandlesize ( ( Handle ) hnode, size ) )
+ return ( false );
- copystring (bs, (**hnode).hashkey);
+ hashunlinknode ( htable, hnode );
- hashlinknode (htable, hnode);
+ setHashKey ( h, ( **hnode ).hashkey );
- (**htable).flneedsort = true;
+ hashlinknode ( htable, hnode );
- langsymbolchanged (htable, bs, hnode, false); /*value didn't change*/
+ ( **htable ).flneedsort = true;
- return (true);
- } /*hashsetnodekey*/
+ langsymbolchanged ( htable, h, hnode, false); // value didn't change
+
+ return ( true );
+
+ } // hashsetnodekey
-static boolean newhashnode (hdlhashnode *hnode, const bigstring bskey) {
+static boolean newhashnode ( hdlhashnode *hnode, const Handle handleKey ) {
+
+ long size = sizeof ( tyhashnode ) + sizeof ( short ) + gethandlesize ( handleKey );
- if (!newclearhandle (sizeof (tyhashnode) + stringsize (bskey), (Handle *) hnode))
- return (false);
+ if ( ! newclearhandle ( size, ( Handle * ) hnode ) )
+ return ( false );
+
+ setHashKey ( handleKey, ( ***hnode).hashkey );
- copystring (bskey, (***hnode).hashkey);
+ return ( true );
- return (true);
- } /*newhashnode*/
+ } // newhashnode
-boolean hashinsert (const bigstring bs, tyvaluerecord val) {
+boolean hashinsert ( const Handle handleName, tyvaluerecord val ) {
+
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+ //
+ // 5.0.2b10 dmb: make sure we don't put a value with the tmp flag set.
+ //
- /*
- 5.0.2b10 dmb: make sure we don't put a value with the tmp flag set.
- */
-
register hdlhashtable ht = currenthashtable;
register hdlhashnode h;
+
hdlhashnode hnode;
- if (isemptystring (bs)) {
- bigstring bspath;
+ if ( isemptyhandle ( handleName ) ) {
+
+ Handle handlePath;
- langexternalgetfullpath (currenthashtable, (ptrstring) bs, bspath, nil);
+ langexternalgetfullpath ( currenthashtable, handleName, &handlePath, nil );
- lang2paramerror (illegalnameerror, bspath, bs);
+ lang2paramerror ( illegalnameerror, handlePath, handleName );
- return (false);
+ return ( false );
+
}
- if (!newhashnode (&hnode, bs))
- return (false);
+ if ( ! newhashnode ( &hnode, handleName ) )
+ return ( false );
+
+ h = hnode; // copy into register
- h = hnode; /*copy into register*/
-
hnewnode = h; /*copy into global for hashinsertaddress*/
val.fltmpstack = false; // 5.0.2: caller is responsible for actually removing it
@@ -1284,8 +1330,9 @@
hashinsertnode (h, ht);
return (true);
- } /*hashinsert*/
+ } // hashinsert
+
/*
hashmerge (hdlhashtable hsource, hdlhashtable hdest) {
@@ -1354,7 +1401,7 @@
if (!stringtoshort (bscopy, arrayindex)) {
- langparamerror (badindexname, bs);
+ langParamErrBs ( badindexname, bs);
return (false);
}
@@ -1363,66 +1410,72 @@
} /%hashstringtoarrayindex%/
*/
-boolean hashlocate (const bigstring bs, hdlhashnode *hnode, hdlhashnode *hprev) {
+boolean hashlocate ( const Handle handleKey, hdlhashnode *hnode, hdlhashnode *hprev ) {
- /*
- 7/15/90 DW: add support for table array-style references. if the string
- begins with a $, we return the node and prev for the nth guy in the sorted
- list of the table.
- */
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+ // 1990-07-15 DW: add support for table array-style references. if the
+ // string begins with a $, we return the node and prev for
+ // the nth guy in the sorted list of the table.
+ //
+ register hdlhashnode nomad, nomadprev;
register short ixbucket;
- register hdlhashnode nomad, nomadprev;
- /*
- short arrayindex;
+ ixbucket = hashfunction ( handleKey );
- if (hashstringtoarrayindex (bs, &arrayindex)) {
+ nomad = ( **currenthashtable ).hashbucket [ ixbucket ];
- return (hashlocatearray (arrayindex, hnode, hprev));
- }
- */
-
- ixbucket = hashfunction (bs);
-
- //assert (currenthashtable != nil);
-
- //assert (validhandle ((Handle) currenthashtable));
-
- nomad = (**currenthashtable).hashbucket [ixbucket];
-
nomadprev = nil;
while (nomad != nil) {
+
+ Handle h;
- if (equalidentifiers (bs, (**nomad).hashkey)) {
+ gethashkey ( nomad, &h );
+ if ( equalHandleIdentifiers ( handleKey, h ) ) {
+
*hnode = nomad;
*hprev = nomadprev;
+ disposehandle ( h );
+
return (true);
+
}
+ disposehandle ( h );
+
nomadprev = nomad;
nomad = (**nomad).hashlink;
- } /*while*/
- return (false); /*loop terminated, not found*/
- } /*hashlocate*/
+ } // while
+
+ return (false); // loop terminated, not found
+
+ } // hashlocate
-boolean hashunlink (const bigstring bs, hdlhashnode *hnode) {
+boolean hashunlink ( const Handle h, hdlhashnode *hnode) {
+
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
- hdlhashnode hprev;
register hdlhashnode hn;
- if (!hashlocate (bs, hnode, &hprev)) {
+ hdlhashnode hprev;
- langparamerror (cantdeleteerror, bs);
+ if (!hashlocate (h, hnode, &hprev)) {
+
+ langparamerror ( cantdeleteerror, h );
return (false);
+
}
hn = *hnode; /*copy into register*/
@@ -1430,7 +1483,7 @@
langsymbolunlinking (currenthashtable, hn);
if (hprev == nil)
- (**currenthashtable).hashbucket [hashfunction (bs)] = (**hn).hashlink;
+ (**currenthashtable).hashbucket [hashfunction (h)] = (**hn).hashlink;
else
(**hprev).hashlink = (**hn).hashlink;
@@ -1438,9 +1491,10 @@
dirtyhashtable (currenthashtable);
- langsymboldeleted (currenthashtable, bs);
+ langsymboldeleted (currenthashtable, h);
return (true);
+
} /*hashunlink*/
/*
@@ -1460,16 +1514,26 @@
*/
-boolean hashdelete (const bigstring bs, boolean fldisposevalue, boolean fldisk) {
+boolean hashdelete ( const Handle h, boolean fldisposevalue, boolean fldisk) {
+
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+
+ register hdlhashnode hn;
hdlhashnode hnode, hprev;
- register hdlhashnode hn;
+
+ if (!hashlocate ( h, &hnode, &hprev)) {
- if (!hashlocate (bs, &hnode, &hprev)) {
+ bigstring bs;
+
+ texthandletostring ( h, bs );
- langparamerror (cantdeleteerror, bs);
+ langParamErrBs ( cantdeleteerror, bs);
return (false);
+
}
hn = hnode; /*copy into register*/
@@ -1477,7 +1541,7 @@
langsymbolunlinking (currenthashtable, hn);
if (hprev == nil)
- (**currenthashtable).hashbucket [hashfunction (bs)] = (**hn).hashlink;
+ (**currenthashtable).hashbucket [ hashfunction ( h ) ] = (**hn).hashlink;
else
(**hprev).hashlink = (**hn).hashlink;
@@ -1487,49 +1551,103 @@
dirtyhashtable (currenthashtable);
- langsymboldeleted (currenthashtable, bs);
+ langsymboldeleted (currenthashtable, h );
return (true);
- } /*hashdelete*/
+
+ } // hashdelete
-boolean hashtabledelete (hdlhashtable htable, bigstring bs) {
-
+boolean hashtabledelete (hdlhashtable htable, const Handle h ) {
+
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+
boolean fl;
if (!pushhashtable (htable))
return (false);
- fl = hashdelete (bs, true, true);
+ fl = hashdelete ( h, true, true );
pophashtable ();
return (fl);
+
} /*hashtabledelete*/
-boolean hashsymbolexists (const bigstring bs) {
+boolean hashTableDeleteBigstring ( hdlhashtable htable, const bigstring bs ) {
+
+ //
+ // 2007-02-23 creedon: created
+ //
+ Handle h;
+ boolean fl;
+
+ if ( ! newtexthandle ( bs, &h ) )
+ return ( false );
+
+ fl = hashtabledelete ( htable, h );
+
+ disposehandle ( h );
+
+ return ( fl );
+
+ }
+
+
+boolean hashsymbolexists ( Handle h ) {
+
hdlhashnode hnode, hprev;
- return (hashlocate (bs, &hnode, &hprev));
- } /*hashsymbolexists*/
+ return ( hashlocate ( h, &hnode, &hprev ) );
+
+ } // hashsymbolexists
-boolean hashtablesymbolexists (hdlhashtable htable, const bigstring bs) {
+boolean hashtablesymbolexists ( hdlhashtable htable, const Handle h ) {
+
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
boolean fl;
pushhashtable (htable);
- fl = hashsymbolexists (bs);
+ fl = hashsymbolexists ( h );
pophashtable ();
return (fl);
+
} /*hashtablesymbolexists*/
+boolean hashTableSymbolExistsBigstring ( hdlhashtable htable, const bigstring bs ) {
+
+ //
+ // 2007-02-23 creedon: created
+ //
+
+ Handle h;
+ boolean fl;
+
+ if ( ! newtexthandle ( bs, &h ) )
+ return ( false );
+
+ fl = hashtablesymbolexists ( htable, h );
+
+ disposehandle ( h );
+
+ return ( fl );
+
+ } // hashTableSymbolExistsBigstring
+
+
typedef struct localityinfo {
boolean fllocal;
@@ -1557,6 +1675,7 @@
(**ht).fllocaltable = (*info).fllocal;
hashtablevisit (ht, &hashsetlocalityvisit, info);
+
}
}
@@ -1626,29 +1745,35 @@
} /*hashsetlocality*/
-boolean hashassign (const bigstring bs, tyvaluerecord val) {
-
- /*
- 9/23/91 dmb: no longer clear fllangerror, or look at it when
- hashlocate returns false. array references are implemented differently
- now, and hashlocate never generates errors. clearing fllangerror can
- have the side effect of hiding an error condition unexpectedly.
-
- 5.0b17 dmb: if we're assigning a tmp external, claim the data like
- a normal tmp. don't copy the data, clean fltmpdata instead. really, our
- caller should be exempting from the tmp stack, but this close to shipping
- let's not assume more than we have to
+boolean hashassign ( const Handle h, tyvaluerecord val ) {
- 5.0.1b1 dmb: the b17 change broke stuff, because the object may be in
- another table's temp stack. Our caller is responsible for exempting
- anything assinged into a table. we just need to make sure that the
- fltmpstack flag is clear for _any_ object we assign to a hashnode
-
- 5.0.1b2 dmb: when disposing a value, set fldisk false for local table items
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+ // 5.0.2b13 dmb: set fltmpdata false & call hashsetlocality before
+ // hashinsert case
+ //
+ // 5.0.1b2 dmb: when disposing a value, set fldisk false for local table
+ // items
+ //
+ // 5.0.1b1 dmb: the b17 change broke stuff, because the object may be in
+ // another table's temp stack. Our caller is responsible for exempting
+ // anything assinged into a table. we just need to make sure that the
+ // fltmpstack flag is clear for _any_ object we assign to a hashnode
+ //
+ // 5.0b17 dmb: if we're assigning a tmp external, claim the data like a
+ // normal tmp. don't copy the data, clean fltmpdata instead.
+ // really, our caller should be exempting from the tmp stack,
+ // but this close to shipping let's not assume more than we
+ // have to
+ //
+ // 1991-09-23 dmb: no longer clear fllangerror, or look at it when
+ // hashlocate returns false. array references are
+ // implemented differently now, and hashlocate never
+ // generates errors. clearing fllangerror can have the
+ // side effect of hiding an error condition unexpectedly.
+ //
- 5.0.2b13 dmb: set fltmpdata false & call hashsetlocality before hashinsert case
- */
-
hdlhashnode hnode, hprev;
tyvaluerecord existingval;
boolean fllocal = (**currenthashtable).fllocaltable;
@@ -1671,30 +1796,30 @@
//if (val.valuetype == externalvaluetype) // 5.0.2: localness of tables must match parent
hashsetlocality (&val, fllocal);
- if (!hashlocate (bs, &hnode, &hprev)) { /*the name doesn't exist or is invalid*/
+ if ( ! hashlocate ( h, &hnode, &hprev ) ) // the name doesn't exist or is invalid
+ return ( hashinsert ( h, val ) ); // just an undefined variable
- /*just an undefined variable*/
-
- return (hashinsert (bs, val));
- }
-
existingval = (**hnode).val;
- if (fllanghashassignprotect) { /*protect externals from being smashed by assignment*/
+ if (fllanghashassignprotect) { // protect externals from being smashed by assignment
+
+ if ((existingval.valuetype == externalvaluetype) && (val.valuetype != externalvaluetype)) {
- if ((existingval.valuetype == externalvaluetype) && (val.valuetype != externalvaluetype)) {
- bigstring bstype;
+ bigstring bs, bstype;
langexternaltypestring ((hdlexternalhandle) existingval.data.externalvalue, bstype);
- lang2paramerror (badexternalassignmenterror, bstype, bs);
+ texthandletostring ( h, bs );
+ lang2ParamErrBs ( badexternalassignmenterror, bstype, bs );
+
return (false);
+
}
}
+
+ /*carefully nuke existing value*/ {
- /*carefully nuke existing value*/ {
-
boolean flneeddatabase = (!fllocal && existingval.fldiskval);
hdldatabaserecord hdb = nil;
@@ -1714,26 +1839,56 @@
(**hnode).val = val;
- langsymbolchanged (currenthashtable, bs, hnode, true); /*value changed*/
+ langsymbolchanged ( currenthashtable, h, hnode, true ); // value changed
return (true);
- } /*hashassign*/
+
+ } // hashassign
-boolean hashtableassign (hdlhashtable htable, const bigstring bs, tyvaluerecord val) {
+boolean hashtableassign ( hdlhashtable htable, const Handle h, tyvaluerecord val ) {
+
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
boolean fl;
- pushhashtable (htable);
+ pushhashtable ( htable );
- fl = hashassign (bs, val);
+ fl = hashassign ( h, val );
- pophashtable ();
+ pophashtable ( );
- return (fl);
- } /*hashtableassign*/
+ return ( fl );
+
+ } // hashtableassign
+boolean hashtableassignstring ( hdlhashtable htable, const bigstring bs, tyvaluerecord val ) {
+
+ //
+ // 2006-12-08 creedon: cribbed from hashtableassign function
+ //
+
+ Handle h;
+ boolean fl = false;
+
+ pushhashtable ( htable );
+
+ if ( newtexthandle ( bs, &h ) )
+ if ( hashassign ( h, val ) )
+ fl = true;
+ else
+ disposehandle ( h );
+
+ pophashtable ( );
+
+ return ( fl );
+
+ } // hashtableassignstring
+
+
boolean hashresolvevalue (hdlhashtable htable, hdlhashnode hnode) {
/*
@@ -1757,7 +1912,6 @@
register hdlhashnode hn = hnode;
boolean fl;
- #ifdef version5orgreater
if (htable == pathstable && (**hn).flunresolvedaddress) {
(**hn).flunresolvedaddress = false; /*clear now to avoid potential recursion*/
@@ -1775,41 +1929,9 @@
if (!fl)
return (false);
}
- #else
- register hdlstring hstring;
- bigstring bs;
- if ((**hn).flunresolvedaddress) {
-
- (**hn).flunresolvedaddress = false; /*clear now to avoid potential recursion*/
- hstring = (**hn).val.data.addressvalue;
-
- copyheapstring (hstring, bs);
-
- pushhashtable (roottable);
-
- disablelangerror ();
-
- fl = langexpandtodotparams (bs, &htable, bs);
-
- enablelangerror ();
-
- pophashtable ();
-
- if (!fl) {
-
- // (**hn).flunresolvedaddress = true; /*didn't actually resolve it*/
-
- return (false);
- }
-
- setheapstring (bs, hstring); /*now we have just the name*/
-
- enlargehandle ((Handle) hstring, sizeof (hdlhashtable), &htable); /*should never fail*/
- }
- #endif
-
if ((**hn).val.fldiskval) {
+
Handle hbinary;
hdldatabaserecord hdb = tablegetdatabase (htable);
@@ -1832,22 +1954,26 @@
(**hn).val.data.binaryvalue = hbinary;
(**hn).val.fldiskval = false;
+
}
return (true);
+
} /*hashresolvevalue*/
-boolean hashlookup (const bigstring bs, tyvaluerecord *vreturned, hdlhashnode *hnode) {
+boolean hashlookup ( const Handle h, tyvaluerecord *vreturned, hdlhashnode *hnode ) {
+
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+ // 1992-03-19 dmb: must check for unresolved addresses here
+ //
- /*
- 3/19/92 dmb: must check for unresolved addresses here
- */
-
hdlhashnode hprev;
- if (!hashlocate (bs, hnode, &hprev))
- return (false);
+ if ( ! hashlocate ( h, hnode, &hprev ) )
+ return ( false );
if (!hashresolvevalue (currenthashtable, *hnode))
return (false);
@@ -1855,10 +1981,15 @@
*vreturned = (***hnode).val;
return (true);
+
} /*hashlookup*/
-boolean hashtablelookup (hdlhashtable htable, const bigstring bs, tyvaluerecord *vreturned, hdlhashnode *hnode) {
+boolean hashtablelookup (hdlhashtable htable, const Handle h, tyvaluerecord *vreturned, hdlhashnode *hnode) {
+
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
boolean fl;
@@ -1868,120 +1999,116 @@
pushhashtable (htable);
- fl = hashlookup (bs, vreturned, hnode);
+ fl = hashlookup (h, vreturned, hnode);
pophashtable ();
return (fl);
+
} /*hashtablelookup*/
-boolean hashlookupnode (const bigstring bs, hdlhashnode *hnode) {
+boolean hashlookupnode ( Handle h, hdlhashnode *hnode ) {
- /*
- 3/19/92 dmb: must check for unresolved addresses here
- */
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+ // 1992-03-19 dmb: must check for unresolved addresses here
+ //
hdlhashnode hprev;
- if (!hashlocate (bs, hnode, &hprev))
- return (false);
+ if ( ! hashlocate ( h, hnode, &hprev ) )
+ return ( false );
return (hashresolvevalue (currenthashtable, *hnode));
- } /*hashlookupnode*/
+
+ } // hashlookupnode
-boolean hashtablelookupnode (hdlhashtable htable, const bigstring bs, hdlhashnode *hnode) {
+boolean hashtablelookupnode (hdlhashtable htable, const Handle h, hdlhashnode *hnode) {
+
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
boolean fl;
pushhashtable (htable);
- fl = hashlookupnode (bs, hnode);
+ fl = hashlookupnode (h, hnode);
pophashtable ();
return (fl);
+
} /*hashtablelookupnode*/
-static boolean hashinsertaddress (bigstring bsname, bigstring bsval) {
+boolean hashTableLookupNodeBigstring ( hdlhashtable htable, const bigstring bs, hdlhashnode *hnode ) {
+
+ //
+ // 2007-02-23 creedon: created
+ //
- /*
- 3/19/92 dmb: discovered critical bug: if we try to resolve address references
- here, using langexpandtodotparams, an address that references the table
- being unpacked will generate infinite recursion. That answer is to leave
- the address in its string format for now, and then resolve the address when
- it's referenced through a hashlookup. this necessitated adding a new flag
- to the hashrecord, and introducing the hnewnode global so we know what node
- was created by hashinsert. also, to preserve the original path information
- and coordinate with getaddressvalue, we adopted a new convention of using
- a hashtable of -1 to indicate an unresvoled address value.
- */
+ Handle h;
+ boolean fl;
- tyvaluerecord val;
+ if ( ! newtexthandle ( bs, & h ) )
+ return ( false );
- if (!setaddressvalue ((hdlhashtable) -1, bsval, &val))
- return (false);
+ fl = hashtablelookupnode ( htable, h, hnode );
- if (!hashinsert (bsname, val))
- return (false);
+ disposehandle ( h );
- exemptfromtmpstack (&val);
+ return ( fl );
- (**hnewnode).flunresolvedaddress = true;
-
- return (true);
- } /*hashinsertaddress*/
+ } // hashTableLookupNodeBigstring
-/*
-static boolean hashinsertaddress (bigstring bsname, bigstring bsval) {
+static boolean hashinsertaddress ( const Handle handleName, const Handle handleValue ) {
+
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+ // 1992-03-19 dmb: discovered critical bug: if we try to resolve address
+ // references here, using langexpandtodotparams, an address that references
+ // the table being unpacked will generate infinite recursion. The answer
+ // is to leave the address in its string format for now, and then resolve
+ // the address when it's referenced through a hashlookup. this
+ // necessitated adding a new flag to the hashrecord, and introducing the
+ // hnewnode global so we know what node was created by hashinsert. also,
+ // to preserve the original path information and coordinate with
+ // getaddressvalue, we adopted a new convention of using a hashtable of -1
+ // to indicate an unresvoled address value.
+ //
tyvaluerecord val;
- hdlhashtable htable;
- bigstring bs;
- boolean fl;
- pushhashtable (roottable);
-
- disablelangerror ();
-
- if (langexpandtodotparams (bsval, &htable, bs))
- fl = setaddressvalue (htable, bs, &val);
- else
- fl = setstringvalue (bsval, &val);
-
- enablelangerror ();
-
- pophashtable ();
-
- if (!fl)
+ if ( ! setaddressvalue ( ( hdlhashtable ) - 1, handleValue, &val ) )
return (false);
- if (!hashinsert (bsname, val))
- return (false);
+ if ( ! hashinsert ( handleName, val ) )
+ return ( false );
- pushhashtable (roottable);
+ exemptfromtmpstack ( &val );
- exemptfromtmpstack (val);
+ ( **hnewnode ).flunresolvedaddress = true;
- pophashtable ();
+ return ( true );
- return (true);
- } /%hashinsertaddress%/
-*/
+ } // hashinsertaddress
-boolean hashtablevisit (hdlhashtable htable, langtablevisitcallback visit, ptrvoid refcon) {
+boolean hashtablevisit ( hdlhashtable htable, langtablevisitcallback visit, ptrvoid refcon ) {
/*
###4.0.2b1 warning: scalar node values may now be on disk. callers that may
- be examining strings values must handle this. (currently these are no such callers.)
+ be examining strings values must handle this. (currently there are no such callers.)
*/
- register hdlhashnode x;
- register short i;
+ /* register */ hdlhashnode x;
+ /* register */ short i;
for (i = 0; i < ctbuckets; i++) {
@@ -1991,20 +2118,24 @@
hdlhashnode nextx = (**x).hashlink;
- if (!(*visit) (x, refcon))
- return (false);
+ if ( ! ( *visit ) ( x, refcon ) )
+ return ( false );
x = nextx;
- } /*while*/
- } /*for*/
+
+ } // while
+
+ } // for
...
[truncated message content] |