|
From: <cre...@us...> - 2007-02-25 04:59:34
|
Revision: 1628
http://svn.sourceforge.net/frontierkernel/?rev=1628&view=rev
Author: creecode
Date: 2007-02-24 20:59:30 -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/langsystem7.h
Frontier/branches/Frontier_Long_File_Paths/Common/source/langregexp.c
Frontier/branches/Frontier_Long_File_Paths/Common/source/langscan.c
Frontier/branches/Frontier_Long_File_Paths/Common/source/langstartup.c
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/headers/langsystem7.h
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/headers/langsystem7.h 2007-02-25 02:52:04 UTC (rev 1627)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/headers/langsystem7.h 2007-02-25 04:59:30 UTC (rev 1628)
@@ -56,11 +56,11 @@
typedef boolean (*langvisitlistvaluescallback) (tyvaluerecord *, ptrvoid); /*2003-04-28 AR*/
-/*prototypes*/
+// prototypes
extern boolean filespectoalias (const ptrfilespec , boolean, AliasHandle *); /*landsystem7.c*/
-extern boolean aliastostring (Handle, bigstring);
+extern boolean aliasToTextHandle ( Handle, Handle );
extern boolean aliastofilespec (AliasHandle, ptrfilespec );
@@ -88,58 +88,61 @@
#ifdef flnewfeatures
-extern boolean filespecaddvalue (tyvaluerecord *, tyvaluerecord *, tyvaluerecord *);
+ extern boolean filespecaddvalue (tyvaluerecord *, tyvaluerecord *, tyvaluerecord *);
-extern boolean filespecsubtractvalue (tyvaluerecord *, tyvaluerecord *, tyvaluerecord *);
+ extern boolean filespecsubtractvalue (tyvaluerecord *, tyvaluerecord *, tyvaluerecord *);
-extern boolean getobjectmodeldisplaystring (tyvaluerecord *, bigstring);
+ extern boolean getobjectmodeldisplaystring ( tyvaluerecord *, bigstring );
-extern boolean makelistvalue (hdltreenode, tyvaluerecord *);
+ extern boolean makelistvalue (hdltreenode, tyvaluerecord *);
-extern boolean makerecordvalue (hdltreenode, boolean, tyvaluerecord *);
+ extern boolean makerecordvalue (hdltreenode, boolean, tyvaluerecord *);
-extern boolean langgetlistsize (const tyvaluerecord *, long *);
+ extern boolean langgetlistsize (const tyvaluerecord *, long *);
-#ifdef oplanglists
- extern boolean langgetlistitem (const tyvaluerecord *, long, ptrstring, tyvaluerecord *);
-
- extern boolean langpushlistval (struct tylistrecord **, ptrstring, tyvaluerecord *);
+ #ifdef oplanglists
- extern boolean langpushlisttext (struct tylistrecord ** hlist, Handle hstring);
-
- extern boolean langpushliststring (struct tylistrecord ** hlist, bigstring bs);
-
- extern boolean langpushlistaddress (struct tylistrecord ** hlist, hdlhashtable ht, bigstring bs);
-
- extern boolean langpushlistlong (struct tylistrecord ** hlist, long num);
-
- extern boolean getnthlistval (struct tylistrecord ** hlist, long n, ptrstring pkey, tyvaluerecord *val);
+ extern boolean langgetlistitem (const tyvaluerecord *, long, ptrstring, tyvaluerecord *);
+
+ extern boolean langpushlistval (struct tylistrecord **, ptrstring, tyvaluerecord *);
- extern boolean setnthlistval (struct tylistrecord ** hlist, long n, ptrstring pkey, tyvaluerecord *val);
-#else
- extern boolean langgetlistitem (const tyvaluerecord *, long, OSType *, tyvaluerecord *);
-#endif
+ extern boolean langpushlisttext (struct tylistrecord ** hlist, Handle hstring);
+
+ extern boolean langpushliststring (struct tylistrecord ** hlist, bigstring bs);
+
+ extern boolean langpushlistaddress ( struct tylistrecord **, hdlhashtable, const Handle );
+
+ extern boolean langPushListAddressBigstring ( struct tylistrecord **, hdlhashtable, bigstring );
+
+ extern boolean langpushlistlong (struct tylistrecord ** hlist, long num);
+
+ extern boolean getnthlistval (struct tylistrecord ** hlist, long n, ptrstring pkey, tyvaluerecord *val);
-extern boolean coercetolist (tyvaluerecord *, tyvaluetype);
+ extern boolean setnthlistval (struct tylistrecord ** hlist, long n, ptrstring pkey, tyvaluerecord *val);
+ #else
+ extern boolean langgetlistitem (const tyvaluerecord *, long, OSType *, tyvaluerecord *);
+
+ #endif
-extern boolean coercelistvalue (tyvaluerecord *, tyvaluetype);
+ extern boolean coercetolist (tyvaluerecord *, tyvaluetype);
-extern boolean listaddvalue (tyvaluerecord *, tyvaluerecord *, tyvaluerecord *);
+ extern boolean coercelistvalue (tyvaluerecord *, tyvaluetype);
-extern boolean listsubtractvalue (tyvaluerecord *, tyvaluerecord *, tyvaluerecord *);
+ extern boolean listaddvalue (tyvaluerecord *, tyvaluerecord *, tyvaluerecord *);
-extern boolean listcomparevalue (tyvaluerecord *, tyvaluerecord *, tytreetype, tyvaluerecord *);
+ extern boolean listsubtractvalue (tyvaluerecord *, tyvaluerecord *, tyvaluerecord *);
-extern boolean coercetolistposition (tyvaluerecord *);
-
-extern boolean listarrayvalue (tyvaluerecord *, bigstring, tyvaluerecord *, tyvaluerecord *);
+ extern boolean listcomparevalue (tyvaluerecord *, tyvaluerecord *, tytreetype, tyvaluerecord *);
-extern boolean listassignvalue (tyvaluerecord *, bigstring, tyvaluerecord *, tyvaluerecord *);
+ extern boolean coercetolistposition (tyvaluerecord *);
+
+ extern boolean listarrayvalue ( tyvaluerecord *, const Handle, tyvaluerecord *, tyvaluerecord * );
-extern boolean listdeletevalue (tyvaluerecord *, bigstring, tyvaluerecord *);
+ extern boolean listassignvalue (tyvaluerecord *, const Handle, tyvaluerecord *, tyvaluerecord *);
-extern boolean langvisitlistvalues (tyvaluerecord *, langvisitlistvaluescallback, ptrvoid); /*2003-04-28 AR*/
+ extern boolean listdeletevalue ( tyvaluerecord *, const Handle, tyvaluerecord * );
+ extern boolean langvisitlistvalues (tyvaluerecord *, langvisitlistvaluescallback, ptrvoid); // 2003-04-28 AR
+
#endif
-
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/source/langregexp.c
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/source/langregexp.c 2007-02-25 02:52:04 UTC (rev 1627)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/source/langregexp.c 2007-02-25 04:59:30 UTC (rev 1628)
@@ -1027,19 +1027,17 @@
}
return (true);
+
} /*regexpgetpatterninfo*/
-static boolean regexpbuildmatchinfotable (Handle hsubject, Handle hcp, Handle hovec,
- boolean flmakegroups, boolean flmakenamedgroups,
- bigstring bserror, hdlhashtable ht) {
+static boolean regexpbuildmatchinfotable ( Handle hsubject, Handle hcp,
+ Handle hovec, boolean flmakegroups, boolean flmakenamedgroups,
+ bigstring bserror, hdlhashtable ht ) {
- long offset = getgroupoffset (hovec, 0);
- long length = getgrouplength (hovec, 0);
- hdllistrecord hoffsets = nil;
- hdllistrecord hlengths = nil;
- hdllistrecord hstrings = nil;
Handle h;
+ long length = getgrouplength (hovec, 0), offset = getgroupoffset (hovec, 0);
+ hdllistrecord hlengths = nil, hoffsets = nil, hstrings = nil;
/* matchOffset */
@@ -1057,8 +1055,11 @@
goto exit;
if (!langassigntextvalue (ht, STR_matchString, h)) {
+
disposehandle (h);
+
goto exit;
+
}
/* make groups */
@@ -1119,7 +1120,6 @@
if (!langpushliststring (hstrings, emptystring))
goto exit;
-
}
}
@@ -1129,7 +1129,7 @@
vtemp.data.binaryvalue = (Handle) hoffsets;
- if (!hashtableassign (ht, STR_groupOffsets, vtemp))
+ if (!hashtableassignstring (ht, STR_groupOffsets, vtemp))
goto exit;
hoffsets = nil;
@@ -1140,7 +1140,7 @@
vtemp.data.binaryvalue = (Handle) hlengths;
- if (!hashtableassign (ht, STR_groupLengths, vtemp))
+ if (!hashtableassignstring (ht, STR_groupLengths, vtemp))
goto exit;
hlengths = nil;
@@ -1151,10 +1151,11 @@
vtemp.data.binaryvalue = (Handle) hstrings;
- if (!hashtableassign (ht, STR_groupStrings, vtemp))
+ if (!hashtableassignstring (ht, STR_groupStrings, vtemp))
goto exit;
hstrings = nil;
+
}
if (flmakenamedgroups) {
@@ -1173,11 +1174,14 @@
res = pcre_fullinfo (getpatternref (hcp), nil, PCRE_INFO_NAMETABLE, (void *) &cptr);
if (res != 0) {
+
regexpverberrorwithnumber (regexpinternalerror, res, bserror);
+
goto exit;
+
}
- if (!langassignnewtablevalue (ht, STR_namedGroups, &htgroups))
+ if ( ! langAssignNewTableValueBigstring ( ht, STR_namedGroups, &htgroups ) )
goto exit;
if (cptr != nil) {
@@ -1188,7 +1192,7 @@
copyctopstring ((char *) (cptr + k * sz + 2), bs);
- if (!langassignnewtablevalue (htgroups, bs, &htname))
+ if ( ! langAssignNewTableValueBigstring ( htgroups, bs, &htname ) )
goto exit;
offset = getgroupoffset (hovec, groupnum);
@@ -1208,24 +1212,29 @@
goto exit;
if (!langassigntextvalue (htname, STR_matchString, h)) {
+
disposehandle (h);
+
goto exit;
+
}
+
} /*for*/
}
}
return (true);
-
-exit:
- opdisposelist (hoffsets);
+ exit:
- opdisposelist (hlengths);
-
- opdisposelist (hstrings);
-
- return (false);
+ opdisposelist (hoffsets);
+
+ opdisposelist (hlengths);
+
+ opdisposelist (hstrings);
+
+ return (false);
+
} /*regexpbuildmatchinfotable*/
@@ -1378,12 +1387,15 @@
releaseheaptmp (val.data.stringvalue);
return (true);
+
} /*replscanwritenumbered*/
-static boolean replscanwritenamed (int ix, int len, const char *cptr, int clen, bigstring bserror, void *refcon) {
-#pragma unused (ix, len, bserror)
+static boolean replscanwritenamed ( int ix, int len, const char *cptr, int clen,
+ bigstring bserror, void *refcon ) {
+ #pragma unused (ix, len, bserror)
+
tyreplscanexpandinfo *info = (tyreplscanexpandinfo *) refcon;
hdlhashnode hnode;
hdlhashtable ht;
@@ -1393,27 +1405,27 @@
moveleft ((void *) cptr, stringbaseaddress (bsname), clen);
setstringlength (bsname, clen);
-
- if (!langhashtablelookup (info->htnames, bsname, &vname, &hnode))
+
+ if ( ! langHashTableLookupBigstring ( info->htnames, bsname, &vname, &hnode ) )
return (false);
-
- if (!langexternalvaltotable (vname, &ht, hnode)) {
+
+ if (!langexternalvaltotable (vname, &ht, hnode))
return (false);
- }
-
- if (!langhashtablelookup (ht, STR_matchString, &vstr, &hnode))
+
+ if ( ! langHashTableLookupBigstring ( ht, STR_matchString, &vstr, &hnode ) )
return (false);
if (vstr.valuetype != stringvaluetype)
if (!copyvaluerecord (vstr, &vstr) || !coercetostring (&vstr))
return (false);
-
+
fl = writehandlestreamhandle (&(info->s), vstr.data.stringvalue);
-
+
if (vstr.fltmpstack)
releaseheaptmp (vstr.data.stringvalue);
+
+ return (fl);
- return (fl);
} /*replscanwritenamed*/
@@ -1717,20 +1729,23 @@
} /*writereplacementhandlestream*/
-static boolean getcodetreefromscriptaddress (hdlhashtable htable, bigstring bsverb, hdltreenode *hcode) {
+static boolean getcodetreefromscriptaddress (hdlhashtable htable, const Handle handleVerb, hdltreenode *hcode) {
+
+ //
+ // Given the address of an object, assume it's a script or code object and
+ // get its code tree
+ //
+ // Code cribbed from langrunscript in lang.c
+ //
+ // 2007-02-24 creedon: support for long odb item names and file paths
+ //
- /*
- Given the address of an object, assume it's a script or code object and get its code tree
-
- Code cribbed from langrunscript in lang.c
- */
-
tyvaluerecord vhandler;
hdlhashnode handlernode;
- if (!hashtablelookupnode (htable, bsverb, &handlernode)) {
+ if (!hashtablelookupnode (htable, handleVerb, &handlernode)) {
- langparamerror (unknownfunctionerror, bsverb);
+ langparamerror ( unknownfunctionerror, handleVerb );
return (false);
}
@@ -1749,9 +1764,10 @@
if (!langexternalvaltocode (vhandler, hcode)) {
- langparamerror (notfunctionerror, bsverb);
+ langparamerror ( notfunctionerror, handleVerb );
return (false);
+
}
if (*hcode == nil) { /*needs compilation*/
@@ -1762,17 +1778,24 @@
}
return (true);
+
} /*getcodetreefromscriptaddress*/
-static boolean regexprunreplacecallback (tyaddress *adrcallback, tyvaluerecord *vrepl, tyvaluerecord *vmatchinfo, Handle *hrepl, boolean *flcallbackresult) {
+static boolean regexprunreplacecallback ( tyaddress *adrcallback,
+ tyvaluerecord *vrepl, tyvaluerecord *vmatchinfo, Handle *hrepl,
+ boolean *flcallbackresult ) {
+
+ //
+ // 2007-02-24 creedon: support for long odb item names and file paths
+ //
+ boolean fl;
+ hdlhashnode hdummy;
hdlhashtable htlocals = nil;
hdllistrecord hparams;
+ hdltreenode hcode;
tyvaluerecord vparams, vresult, val;
- hdltreenode hcode;
- hdlhashnode hdummy;
- boolean fl;
*hrepl = nil;
@@ -1785,13 +1808,13 @@
fl = langpushlocalchain (&htlocals);
if (fl)
- fl = hashtableassign (htlocals, STR_replacementString, *vrepl);
+ fl = hashtableassignstring (htlocals, STR_replacementString, *vrepl);
if (!fl)
disposevaluerecord (*vrepl, false);
if (fl)
- fl = hashtableassign (htlocals, STR_matchInfo, *vmatchinfo);
+ fl = hashtableassignstring (htlocals, STR_matchInfo, *vmatchinfo);
if (!fl)
disposevaluerecord (*vmatchinfo, false);
@@ -1805,20 +1828,20 @@
fl = setheapvalue ((Handle) hparams, listvaluetype, &vparams);
if (fl)
- fl = langpushlistaddress (hparams, htlocals, STR_matchInfo);
+ fl = langPushListAddressBigstring ( hparams, htlocals, STR_matchInfo );
if (fl)
- fl = langpushlistaddress (hparams, htlocals, STR_replacementString);
+ fl = langPushListAddressBigstring ( hparams, htlocals, STR_replacementString );
/* obtain code tree for callback script */
if (fl)
- fl = getcodetreefromscriptaddress ((*adrcallback).ht, (*adrcallback).bs, &hcode);
+ fl = getcodetreefromscriptaddress ((*adrcallback).ht, (*adrcallback).h, &hcode);
/* run callback script */
if (fl)
- fl = langrunscriptcode ((*adrcallback).ht, (*adrcallback).bs, hcode, &vparams, nil, &vresult);
+ fl = langrunscriptcode ((*adrcallback).ht, (*adrcallback).h, hcode, &vparams, nil, &vresult);
if (fl)
fl = coercetoboolean (&vresult);
@@ -1829,7 +1852,7 @@
/* get replacement string from locals table */
if (fl)
- fl = langhashtablelookup (htlocals, STR_replacementString, &val, &hdummy);
+ fl = langHashTableLookupBigstring ( htlocals, STR_replacementString, &val, &hdummy );
if (fl)
fl = copyvaluerecord (val, &val);
@@ -1839,20 +1862,28 @@
fl = coercetostring (&val);
if (fl) {
+
exemptfromtmpstack (&val);
+
*hrepl = val.data.stringvalue;
+
}
/* dispose table for local variables */
return (langpoplocalchain (htlocals) && fl);
+
} /*regexprunreplacecallback*/
-static boolean regexpreplacematch (handlestream *s, Handle hsubject, Handle hreplace, hdlreplacepart hreplaceparts,
- Handle hcp, Handle hovec, tyaddress *adrcallback,
- bigstring bserror, boolean *flresult) {
+static boolean regexpreplacematch ( handlestream *s, Handle hsubject,
+ Handle hreplace, hdlreplacepart hreplaceparts, Handle hcp, Handle hovec,
+ tyaddress *adrcallback, bigstring bserror, boolean *flresult ) {
+ //
+ // 2007-02-24 creedon: support for long odb item names and file paths
+ //
+
hdlhashtable htmatchinfo = nil;
tyvaluerecord vmatchinfo;
handlestream hsrepl;
@@ -1864,26 +1895,26 @@
/* if adrcallback was not specified just perform the replacement and return */
- if ((*adrcallback).ht == nil && isemptystring ((*adrcallback).bs))
+ if ( ( *adrcallback ).ht == nil && isemptyhandle ( ( *adrcallback ).h ) )
return (writereplacementhandlestream (s, hsubject, hreplace, hreplaceparts, hovec));
-
+
/* build default replacement string */
openhandlestream (nil, &hsrepl);
if (!writereplacementhandlestream (&hsrepl, hsubject, hreplace, hreplaceparts, hovec))
return (false);
-
+
hrepl = closehandlestream (&hsrepl);
if (hrepl == nil) {
if (!newemptyhandle (&hrepl))
return (false);
}
-
+
if (!setheapvalue (hrepl, stringvaluetype, &vrepl))
return (false);
-
+
/* build matchInfo table */
if (!tablenewtablevalue (&htmatchinfo, &vmatchinfo))
@@ -1898,18 +1929,22 @@
/* run callback script */
if (!regexprunreplacecallback (adrcallback, &vrepl, &vmatchinfo, &hrepl, flresult)) {
+
disposehandle (hrepl);
+
return (false);
+
}
-
+
if (*flresult)
fl = writehandlestreamhandle (s, hrepl);
else
fl = writehandlestreamhandlepart (s, hsubject, getgroupoffset (hovec, 0), getgrouplength (hovec, 0));
-
+
disposehandle (hrepl);
return (fl);
+
} /*regexpreplacematch*/
@@ -1921,6 +1956,7 @@
return (false);
return (langpushlisttext (hlist, h));
+
} /*pushhandlepartonlist*/
@@ -1989,20 +2025,23 @@
} /*regexpwritelistitemscallback*/
-static boolean regexprunvisitcallback (Handle hsubject, Handle hcp, Handle hovec,
- boolean flmakegroups, boolean flmakenamedgroups, tyaddress *adrcallback,
- bigstring bserror, tyvaluerecord *vresult) {
+static boolean regexprunvisitcallback ( Handle hsubject, Handle hcp,
+ Handle hovec, boolean flmakegroups, boolean flmakenamedgroups,
+ tyaddress *adrcallback, bigstring bserror, tyvaluerecord *vresult ) {
+
+ //
+ // 2007-02-24 creedon: support for long odb item names and file paths
+ //
- hdlhashtable htlocals = nil;
- hdlhashtable htmatchinfo;
+ boolean fl = true;
+ hdlhashtable htlocals = nil, htmatchinfo;
hdllistrecord hparams;
+ hdltreenode hcode;
tyvaluerecord vparams;
- hdltreenode hcode;
- boolean fl = true;
/* obtain code tree for callback script */
- if (!getcodetreefromscriptaddress ((*adrcallback).ht, (*adrcallback).bs, &hcode))
+ if (!getcodetreefromscriptaddress ((*adrcallback).ht, (*adrcallback).h, &hcode))
return (false);
/* set up table for local variables */
@@ -2012,7 +2051,7 @@
/* build match info table */
- fl = langassignnewtablevalue (htlocals, STR_matchInfo, &htmatchinfo);
+ fl = langAssignNewTableValueBigstring (htlocals, STR_matchInfo, &htmatchinfo);
if (fl)
fl = regexpbuildmatchinfotable (hsubject, hcp, hovec, flmakegroups, flmakenamedgroups, bserror, htmatchinfo);
@@ -2026,18 +2065,19 @@
fl = setheapvalue ((Handle) hparams, listvaluetype, &vparams);
if (fl)
- fl = langpushlistaddress (hparams, htlocals, STR_matchInfo);
+ fl = langPushListAddressBigstring (hparams, htlocals, STR_matchInfo);
/* run callback script */
if (fl)
- fl = langrunscriptcode ((*adrcallback).ht, (*adrcallback).bs, hcode, &vparams, nil, vresult);
+ fl = langrunscriptcode ((*adrcallback).ht, (*adrcallback).h, hcode, &vparams, nil, vresult);
/* dispose table for local variables */
fl = langpoplocalchain (htlocals) && fl;
return (fl);
+
} /*regexprunvisitcallback*/
@@ -2490,6 +2530,7 @@
setlongvalue (0, v);
return (true);
+
}
/* catch execution errors, presumably indicative of a bug in the PCRE library */
@@ -2510,35 +2551,31 @@
releaseheaptmp (hovec); /*no need to accumulate these on the tmp stack*/
return (true);
+
} /*regexpmatchverb*/
-static boolean regexpreplaceverb (hdltreenode hp1, tyvaluerecord *v, bigstring bserror) {
+static boolean regexpreplaceverb ( hdltreenode hp1, tyvaluerecord *v,
+ bigstring bserror ) {
/*
replace (patternRef, repl, s, maxReplacements = infinity)
//string: modified string
*/
-
- Handle hcp;
- Handle hovec = nil;
- Handle hreplace;
- long replacelength;
- Handle hsubject;
- long subjectlength;
- long maxrepl;
- tyaddress adrctrepl;
- tyaddress adrcallback;
+
+ //
+ // 2007-02-24 creedon: support for long odb item names and file paths
+ //
+
+ Handle hcp, hovec = nil, hsubject, hreplace, hresult;
+ boolean fl, flresult;
+ handlestream hs;
+ hdlreplacepart hreplaceparts = nil;
+ int ctrepl = 0, ix, lastix, res;
+ long maxrepl, replacelength, subjectlength;
+ short ctconsumed = 3, ctpositional = 3;
+ tyaddress adrcallback, adrctrepl;
tyvaluerecord vtemp;
- short ctconsumed = 3;
- short ctpositional = 3;
- hdlreplacepart hreplaceparts = nil;
- handlestream hs;
- Handle hresult;
- int res;
- int ix, lastix;
- int ctrepl = 0;
- boolean fl, flresult;
clearbytes (&hs, sizeof (hs));
@@ -2573,31 +2610,32 @@
/* get adrReplacementCount parameter */
adrctrepl.ht = nil; /*defaults to a nil address*/
- setemptystring (adrctrepl.bs);
-
- if (!getoptionaladdressparam (hp1, &ctconsumed, &ctpositional, STR_adrReplacementCount, &adrctrepl.ht, adrctrepl.bs))
+ adrctrepl.h = NULL;
+
+ if (!getoptionaladdressparam (hp1, &ctconsumed, &ctpositional, STR_adrReplacementCount, &adrctrepl.ht, &adrctrepl.h))
goto exit;
-
+
/* get adrCallback parameter */
-
+
flnextparamislast = true;
adrcallback.ht = nil; /*defaults to a nil address*/
- setemptystring (adrcallback.bs);
-
- if (!getoptionaladdressparam (hp1, &ctconsumed, &ctpositional, STR_adrCallback, &adrcallback.ht, adrcallback.bs))
+ adrcallback.h = NULL;
+
+ if (!getoptionaladdressparam (hp1, &ctconsumed, &ctpositional, STR_adrCallback, &adrcallback.ht, &adrcallback.h))
goto exit;
-
+
/* return early if the caller hasn't asked for at least one replacement */
if (maxrepl <= 0) {
-
+
if (!copyhandle (hsubject, &hresult))
return (false);
+
+ goto done;
- goto done;
}
-
+
/* scan repl parameter */
lockhandle (hreplace);
@@ -2608,7 +2646,7 @@
if (!fl)
goto exit;
-
+
pushtmpstack ((Handle) hreplaceparts);
/* run engine */
@@ -2618,7 +2656,7 @@
lastix = ix = 0;
while (true) { /*execute loop at least once*/
-
+
res = regexpexechandle (hcp, hsubject, ix, longinfinity, hovec, bserror);
/* catch internal errors */
@@ -2634,8 +2672,9 @@
goto exit;
break;
+
}
-
+
/* write fragment between last match and current match */
if (!writehandlestreamhandlepart (&hs, hsubject, lastix, getgroupoffset (hovec, 0) - lastix))
@@ -2656,6 +2695,7 @@
goto exit;
break;
+
}
/* determine position of next match attempt */
@@ -2664,6 +2704,7 @@
if (getgrouplength (hovec, 0) == 0)
ix++; /* prevent infinite loop if we matched the empty string */
+
} /*while*/
hresult = closehandlestream (&hs);
@@ -2673,30 +2714,37 @@
goto exit;
}
-done:
+ done:
- releaseheaptmp (hovec); /*no need to accumulate these on the tmp stack*/
-
- releaseheaptmp ((Handle) hreplaceparts);
-
- /* set result */
+ releaseheaptmp (hovec); /*no need to accumulate these on the tmp stack*/
+
+ releaseheaptmp ((Handle) hreplaceparts);
+
+ /* set result */
- if (!isemptystring (adrctrepl.bs)) {
+ if ( ! isemptyhandle ( adrctrepl.h ) ) {
- setlongvalue (ctrepl, &vtemp);
+ setlongvalue (ctrepl, &vtemp);
+
+ if (!langsetsymboltableval (adrctrepl.ht, adrctrepl.h, vtemp))
+ goto exit;
+
+ }
+
+ disposehandle ( adrctrepl.h );
+ disposehandle ( adrcallback.h );
- if (!langsetsymboltableval (adrctrepl.ht, adrctrepl.bs, vtemp)) {
- goto exit;
- }
- }
+ return (setheapvalue (hresult, stringvaluetype, v));
+
+ exit:
- return (setheapvalue (hresult, stringvaluetype, v));
-
-exit:
-
- disposehandlestream (&hs);
-
- return (false);
+ disposehandle ( adrctrepl.h );
+ disposehandle ( adrcallback.h );
+
+ disposehandlestream (&hs);
+
+ return (false);
+
} /*regexpreplaceverb*/
@@ -3065,7 +3113,7 @@
if (!getaddressparam (hp1, 3, &vtemp))
return (false);
- if (!getaddressvalue (vtemp, &adrcallback.ht, adrcallback.bs))
+ if ( ! getaddressvalue ( vtemp, &adrcallback.ht, &adrcallback.h ) )
return (false);
/* get flMakeGroups parameter */
@@ -3139,11 +3187,13 @@
if (getgrouplength (hovec, 0) == 0)
ix++; /* prevent infinite loop if we matched the empty string */
+
} /*while*/
releaseheaptmp (hovec); /*no need to accumulate these on the tmp stack*/
return (true);
+
} /*regexpvisitverb*/
@@ -3299,33 +3349,45 @@
} /*regexpgrepverb*/
-static boolean regexpgetpatterninfoverb (hdltreenode hp1, tyvaluerecord *v, bigstring bserror) {
+static boolean regexpgetpatterninfoverb ( hdltreenode hp1, tyvaluerecord *v,
+ bigstring bserror ) {
/*
on getPatternInfo (patternRef, adrInfoTable)
//boolean: true
*/
- Handle hcp;
+ //
+ // 2007-02-24 creedon: support for long odb item names and file paths
+ //
+
+ Handle handleName, hcp;
+ bigstring bsnum;
+ char *cptr;
hdlhashtable htable, htinfo, htfirstbyte, htnames, htoptions;
- bigstring bsname, bsnum;
+ int x, k, ct, sz;
unsigned char *ucptr;
- char *cptr;
- int x, k, ct, sz;
/* get patternRef parameter */
if (!regexpgetpatternvalue (hp1, 1, true, bserror, &hcp, nil))
return (false);
-
+
/* get adrInfoTable parameter */
- if (!getvarparam (hp1, 2, &htable, bsname))
+ if (!getvarparam (hp1, 2, &htable, &handleName))
return (false);
-
- if (!langsuretablevalue (htable, bsname, &htinfo))
+
+ if (!langsuretablevalue (htable, handleName, &htinfo)) {
+
+ disposehandle ( handleName );
+
return (false);
-
+
+ }
+
+ disposehandle ( handleName );
+
/* highest back reference */
if (!regexpgetpatterninfo (hcp, PCRE_INFO_BACKREFMAX, bserror, (void *) &x))
@@ -3361,7 +3423,7 @@
if (!regexpgetpatterninfo (hcp, PCRE_INFO_FIRSTTABLE, bserror, (void *) &ucptr))
return (false);
- if (!langassignnewtablevalue (htinfo, STR_firstByteTable, &htfirstbyte))
+ if ( ! langAssignNewTableValueBigstring ( htinfo, STR_firstByteTable, &htfirstbyte ) )
return (false);
if (ucptr != nil) {
@@ -3372,8 +3434,9 @@
padwithzeros (bsnum, 3);
- if (!langassignbooleanvalue (htfirstbyte, bsnum, ucptr[k/8] & (1 << (k % 8))))
+ if (!langAssignBooleanValueBigstring (htfirstbyte, bsnum, ucptr[k/8] & (1 << (k % 8))))
return (false);
+
} /*for*/
}
@@ -3402,7 +3465,7 @@
if (!regexpgetpatterninfo (hcp, PCRE_INFO_NAMETABLE, bserror, (void *) &cptr))
return (false);
- if (!langassignnewtablevalue (htinfo, STR_nameTable, &htnames))
+ if ( ! langAssignNewTableValueBigstring ( htinfo, STR_nameTable, &htnames ) )
return (false);
if (cptr != nil) {
@@ -3427,28 +3490,28 @@
if (!regexpgetpatterninfo (hcp, PCRE_INFO_OPTIONS, bserror, (void *) &x))
return (false);
- if (!langassignnewtablevalue (htinfo, STR_options, &htoptions))
+ if ( ! langAssignNewTableValueBigstring ( htinfo, STR_options, &htoptions ) )
return (false);
- if (!langassignbooleanvalue (htoptions, STR_flCaseSensitive, (x & PCRE_CASELESS) == 0))
+ if (!langAssignBooleanValueBigstring (htoptions, STR_flCaseSensitive, (x & PCRE_CASELESS) == 0))
return (false);
- if (!langassignbooleanvalue (htoptions, STR_flDotMatchesAll, (x & PCRE_DOTALL) != 0))
+ if (!langAssignBooleanValueBigstring (htoptions, STR_flDotMatchesAll, (x & PCRE_DOTALL) != 0))
return (false);
- if (!langassignbooleanvalue (htoptions, STR_flMultiLine, (x & PCRE_MULTILINE) != 0))
+ if (!langAssignBooleanValueBigstring (htoptions, STR_flMultiLine, (x & PCRE_MULTILINE) != 0))
return (false);
- if (!langassignbooleanvalue (htoptions, STR_flAutoCapture, (x & PCRE_NO_AUTO_CAPTURE) == 0))
+ if (!langAssignBooleanValueBigstring (htoptions, STR_flAutoCapture, (x & PCRE_NO_AUTO_CAPTURE) == 0))
return (false);
- if (!langassignbooleanvalue (htoptions, STR_flGreedyQuantifiers, (x & PCRE_UNGREEDY) == 0))
+ if (!langAssignBooleanValueBigstring (htoptions, STR_flGreedyQuantifiers, (x & PCRE_UNGREEDY) == 0))
return (false);
- if (!langassignbooleanvalue (htoptions, STR_flMatchEmptyString, (x & PCRE_NOTEMPTY) == 0))
+ if (!langAssignBooleanValueBigstring (htoptions, STR_flMatchEmptyString, (x & PCRE_NOTEMPTY) == 0))
return (false);
- if (!langassignbooleanvalue (htoptions, STR_flExtendedMode, (x & PCRE_EXTENDED) == 0))
+ if (!langAssignBooleanValueBigstring (htoptions, STR_flExtendedMode, (x & PCRE_EXTENDED) == 0))
return (false);
/* size */
@@ -3472,41 +3535,55 @@
setbooleanvalue (true, v);
return (true);
+
} /*regexpgetpatterninfoverb*/
static boolean regexpexpandverb (hdltreenode hp1, tyvaluerecord *v, bigstring bserror) {
-
+
/*
on expand (s, adrMatchInfoTable)
//string: processed copy of s
*/
-
- Handle hsubject;
+
+ //
+ // 2007-02-24 creedon: support for long odb item names and file paths
+ //
+
+ Handle h, hresult, hsubject;
+ boolean fl;
+ hdlhashnode hnode;
+ hdlhashtable htmatchinfo;
long subjectlength;
+ tyreplscanexpandinfo info;
tyvaluerecord vtemp;
- hdlhashtable htmatchinfo;
- hdlhashnode hnode;
- tyreplscanexpandinfo info;
- Handle hresult;
- boolean fl;
-
+
/* get s parameter */
if (!getreadonlytextvalue (hp1, 1, &hsubject))
return (false);
-
+
subjectlength = gethandlesize (hsubject);
/* get adrMatchInfoTable parameter */
if (!gettablevalue (hp1, 2, &htmatchinfo))
return (false);
-
+
/* get groupStrings list from info table*/
+
+ if ( ! newtexthandle ( STR_groupStrings, &h ) )
+ return ( false );
- if (!langhashtablelookup (htmatchinfo, STR_groupStrings, &vtemp, &hnode))
+ if ( ! langhashtablelookup ( htmatchinfo, h, &vtemp, &hnode ) ) {
+
+ disposehandle ( h );
+
return (false);
+
+ }
+
+ disposehandle ( h );
if (vtemp.valuetype != listvaluetype) {
@@ -3514,17 +3591,24 @@
return (false);
}
}
-
+
info.hgroups = (hdllistrecord) vtemp.data.binaryvalue;
-
+
/* get namedGroups sub-table from info table*/
-
- if (hashtablelookup (htmatchinfo, STR_namedGroups, &vtemp, &hnode)) {
- if (!langexternalvaltotable (vtemp, &info.htnames, hnode)) {
+
+ if ( ! newtexthandle ( STR_namedGroups, &h ) )
+ return ( false );
+
+ if ( hashtablelookup ( htmatchinfo, h, &vtemp, &hnode ) ) {
+
+ disposehandle ( h );
+
+ if ( ! langexternalvaltotable (vtemp, &info.htnames, hnode))
return (false);
- }
}
+ disposehandle ( h );
+
/* perform replacement */
info.hsubject = hsubject;
@@ -3533,12 +3617,8 @@
lockhandle (hsubject);
- fl = regexpscanreplacement (*hsubject, subjectlength, bserror,
- &replscanwriteliteral,
- &replscanwritenumbered,
- &replscanwritenamed,
- &replscanerror,
- (void *) &info);
+ fl = regexpscanreplacement ( *hsubject, subjectlength, bserror, &replscanwriteliteral, &replscanwritenumbered,
+ &replscanwritenamed, &replscanerror, ( void * ) &info );
unlockhandle (hsubject);
@@ -3555,6 +3635,7 @@
}
return (setheapvalue (hresult, stringvaluetype, v));
+
} /*regexpexpandverb*/
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/source/langscan.c
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/source/langscan.c 2007-02-25 02:52:04 UTC (rev 1627)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/source/langscan.c 2007-02-25 04:59:30 UTC (rev 1628)
@@ -62,8 +62,6 @@
bigstring bstoken; /*for viewing with the debugger, text of last token*/
-
-
boolean isfirstidentifierchar (byte ch) {
/*
@@ -102,41 +100,44 @@
} /*isidentifierchar*/
-boolean langisidentifier (bigstring bs) {
+boolean langisidentifier ( const Handle h ) {
+
+ //
+ // called externally to determine when quoting in necessary in path
+ // construction
+ //
+ // 2007-02-24 creedon: support for long odb item names and file paths
+ //
+ // 4.1b2 dmb: check the constants table too
+ //
- /*
- called externally to determine when quoting in necessary in path
- construction
+ register byte *s = *h;
+ register short ct = gethandlesize ( h );
- 4.1b2 dmb: check the constants table too
- */
-
- register short ct = stringlength (bs);
- register byte *s = bs;
+ hdlhashnode hnode;
tyvaluerecord val;
- hdlhashnode hnode;
if (ct == 0) /*empty string*/
return (false);
-
- if (!isfirstidentifierchar (*++s))
+
+ if ( ! isfirstidentifierchar ( *s ) )
return (false);
-
+
while (--ct > 0)
if (!isidentifierchar (*++s))
return (false);
-
- if (hashtablelookup (hkeywordtable, bs, &val, &hnode)) /*it's a keyword*/
+
+ if ( hashtablelookup ( hkeywordtable, h, &val, &hnode ) ) // it's a keyword
return (false);
-
- if (hashtablelookup (hconsttable, bs, &val, &hnode)) /*dmb 4.1b2 - it's a constant*/
+
+ if ( hashtablelookup ( hconsttable, h, &val, &hnode ) ) // dmb 4.1b2 - it's a constant
return (false);
+
+ return (true);
- return (true);
- } /*langisidentifier*/
+ } // langisidentifier
-
#if (odbengine==0)
static boolean midinsertchar (byte ch, bigstring bs, short ixinsert) {
@@ -152,9 +153,116 @@
setstringwithchar (ch, bs1);
return (midinsertstring (bs1, bs, ixinsert)); /*should always be true*/
+
} /*midinsertchar*/
+boolean langDeparseTextHandle ( Handle text, byte chendquote ) {
+
+ //
+ // add any necessary escape sequences to make the string compilable. return
+ // true if we don't have to truncate the string to do so.
+ //
+ // 2007-02-24 creedon: created, cribbed from langdeparse function
+ //
+
+ register byte ch;
+ register short ct = gethandlesize ( text ), ix;
+
+ byte hex [ 16 ]; // should only need 7 bytes
+
+ for ( ix = 0; --ct >= 0; ++ix ) {
+
+ ch = ( byte ) *( *text + ix );
+
+ if ( isprint ( ch ) ) { // look for the few printable characters that
+ // might need quoting
+ switch ( ch ) {
+
+ case '\\':
+
+ break;
+
+ case '\'':
+ case '\"':
+ case chclosecurlyquote:
+
+ if ( ch != chendquote ) // don't always need to quote these
+ ch = 0;
+
+ break;
+
+ default:
+
+ ch = 0;
+
+ break;
+ }
+
+ if ( ch == 0 ) // no quote necessary
+ continue;
+ }
+
+ if ( ch >= 128 ) // extended ascii
+ continue;
+
+ if ( ! insertCharInTextHandle ( '\\', ix++, text ) )
+ return ( false );
+
+ switch ( ch ) {
+
+ case '\n':
+
+ ch = 'n';
+
+ break;
+
+ case '\r':
+
+ ch = 'r';
+
+ break;
+
+ case '\t':
+
+ ch = 't';
+
+ break;
+
+ case '\\':
+ case '\'':
+ case '\"':
+ case chclosecurlyquote:
+
+ break;
+
+ default:
+
+ if ( ! insertCharInTextHandle ( 'x', ix++, text ) )
+ return ( false );
+
+ numbertohexstring ( ch, hex );
+
+ if ( ! insertCharInTextHandle ( hex [ 5 ], ix++, text ) ) // skip over 0x00
+ return ( false );
+
+ ch = hex [ 6 ];
+
+ break;
+ }
+
+ /* if ( ix > ct )
+ return ( false ); */
+
+ *( *text + ix ) = ch;
+
+ } // for
+
+ return ( true );
+
+ } // langDeparseTextHandle
+
+
boolean langdeparsestring (bigstring bs, byte chendquote) {
/*
@@ -344,21 +452,21 @@
static byte parsefirstchar (void) {
+
+ //
+ // return the character at the head of the parse stream without popping it
+ //
- /*
- return the character at the head of the parse stream without
- popping it.
- */
-
register long ix = ixparsestring;
register ptrbyte p;
if (ix >= lenparsestring)
return (chendscanstring);
-
+
p = (ptrbyte) *hscanstring + ix;
return (*p);
+
} /*parsefirstchar*/
@@ -381,23 +489,27 @@
} /*parsenextchar*/
-static void parsepopidentifier (bigstring bs) {
+static void parsepopidentifier ( Handle *h ) {
+
+ //
+ // pull characters off the front of the input stream as long as we're still
+ // getting identifier characters.
+ //
+ // 2007-02-24 creedon: support for long odb item names and file paths
+ //
- /*
- pull characters off the front of the input stream as long as
- we're still getting identifier characters.
- */
+ newemptyhandle ( h );
- setstringlength (bs, 0);
+ while ( true ) {
- while (true) {
-
- if (!isidentifierchar (parsefirstchar ())) /*finished accumulating identifier*/
+ if ( ! isidentifierchar ( parsefirstchar ( ) ) ) // finished accumulating identifier
return;
+
+ pushcharhandle ( parsepopchar ( ), *h ); // add char to the end of the string
- pushchar (parsepopchar (), bs); /*add char to the end of the string*/
- } /*while*/
- } /*parsepopidentifier*/
+ } // while
+
+ } // parsepopidentifier
static boolean parsepopnumber (tyvaluerecord *val) {
@@ -457,8 +569,10 @@
initvalue (val, doublevaluetype);
(*val).data.binaryvalue = x;
+
}
else {
+
long x;
bigstring bstest;
@@ -483,6 +597,7 @@
}
setlongvalue (x, val);
+
}
#ifdef fldebug
@@ -492,6 +607,7 @@
#endif
return (true);
+
}
}
@@ -500,7 +616,7 @@
overflow:
- langparamerror (numbertoolargeerror, bsnumber);
+ langParamErrBs ( numbertoolargeerror, bsnumber);
return (false);
} /*parsepopnumber*/
@@ -805,31 +921,33 @@
static tokentype langscanner (hdltreenode *nodetoken) {
+
+ //
+ // scan the input string for the next token, return the character that we
+ // stopped on in chtoken.
+ //
+ // if it's an identifier or a constant, nodetoken will be non-nil.
+ //
+ // 2007-02-24 creedon: support for long odb item names and file paths
+ //
+ // 5.0.2b10 dmb: exempt const identifier from tmp stack before pushing it
+ // into code tree. it will be disposed on error
+ //
+ // 1991-11-22 dmb: return zero when out of text, after returning exactly
+ // one (non-zero) eoltoken.
+ //
- /*
- scan the input string for the next token, return the character
- that we stopped on in chtoken.
+ register byte ch, chfirst, chsecond;
- if it's an identifier or a constant, nodetoken will be non-nil.
-
- 11/22/91 dmb: return zero when out of text, after returning exactly
- one (non-zero) eoltoken.
-
- 5.0.2b10 dmb: exempt const identifier from tmp stack before pushing it
- into code tree. it will be disposed on error
- */
-
- register byte ch, chfirst, chsecond;
- bigstring bs;
+ hdlhashnode hnode;
tyvaluerecord val;
- hdlhashnode hnode;
*nodetoken = nil; /*default*/
#ifdef fldebug
-
- setstringlength (bstoken, 0);
-
+
+ setstringlength (bstoken, 0);
+
#endif
if (!parsepopblanks ()) { /*ran out of text*/
@@ -840,6 +958,7 @@
flsenteol = true; /*we're about to...*/
return (eoltoken);
+
}
chfirst = ch = parsefirstchar (); /*lookahead at the next character*/
@@ -853,6 +972,7 @@
return (0 /*errortoken*/);
return (constanttoken);
+
}
if ((ch == chdoublequote) || (ch == chopencurlyquote)) { /*a string constant*/
@@ -864,14 +984,15 @@
#ifdef fldebug
- texthandletostring (val.data.stringvalue, bstoken); /*8/13*/
-
+ texthandletostring (val.data.stringvalue, bstoken); /*8/13*/
+
#endif
if (!newconstnode (val, nodetoken))
return (0 /*errortoken*/);
return (constanttoken);
+
}
if (isdigit (ch)) {
@@ -883,28 +1004,31 @@
return (0 /*errortoken*/);
return (constanttoken);
+
}
-
+
if (isfirstidentifierchar (ch)) {
register boolean fl;
- parsepopidentifier (bs);
+ Handle h;
+ parsepopidentifier ( &h );
+
#ifdef fldebug
- copystring (bs, bstoken);
-
+ texthandletostring (h, bstoken);
+
#endif
- fl = hashtablelookup (hkeywordtable, bs, &val, &hnode);
+ fl = hashtablelookup (hkeywordtable, h, &val, &hnode);
if (fl)
return ((tokentype) val.data.tokenvalue); /*it's a reserved word*/
+
+ fl = hashtablelookup (hconsttable, h, &val, &hnode);
- fl = hashtablelookup (hconsttable, bs, &val, &hnode);
-
- if (fl) { /*it's a pre-defined constant*/
+ if (fl) { // it's a pre-defined constant
if (!copyvaluerecord (val, &val))
return (0);
@@ -915,17 +1039,26 @@
return (0 /*errortoken*/);
return (constanttoken);
+
}
initvalue (&val, stringvaluetype);
- if (!newtexthandle (bs, &val.data.stringvalue))
- return (0 /*errortoken*/);
+ if ( ! copyhandle ( h, &val.data.stringvalue ) ) {
+ disposehandle ( h );
+
+ return ( 0 ); // errortoken
+
+ }
+
+ disposehandle ( h );
+
if (!newidnode (val, nodetoken))
return (0 /*errortoken*/);
return (identifiertoken);
+
}
parsepopchar (); /*consume the token char*/
@@ -934,8 +1067,8 @@
#ifdef fldebug
- pushchar (chfirst, bstoken);
-
+ pushchar (chfirst, bstoken);
+
#endif
switch (chfirst) {
@@ -969,6 +1102,7 @@
return (GEtoken);
case '+':
+
if (chsecond == '+') {
parsepopchar (); /*consume the second char*/
@@ -980,6 +1114,7 @@
#endif
return (plusplustoken);
+
}
return (addtoken);
@@ -1071,11 +1206,12 @@
#ifdef fldebug
- pushchar ('=', bstoken);
-
+ pushchar ('=', bstoken);
+
#endif
return (GEtoken);
+
}
return (GTtoken);
@@ -1092,18 +1228,21 @@
#endif
return (NEtoken);
+
}
return (nottoken);
+
} /*switch*/
setstringwithchar (chfirst, bstoken);
//assert (ixparsestring <= lenparsestring && hscanstring);
- langparamerror (illegaltokenerror, bstoken); /*all the legal tokens are caught above*/
+ langParamErrBs ( illegaltokenerror, bstoken ); /*all the legal tokens are caught above*/
return (errortoken);
+
} /*langscanner*/
@@ -1121,6 +1260,7 @@
token = langscanner (nodetoken);
return (token);
+
} /*parsegettoken*/
@@ -1341,11 +1481,3 @@
#endif
-
-
-
-
-
-
-
-
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/source/langstartup.c
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/source/langstartup.c 2007-02-25 02:52:04 UTC (rev 1627)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/source/langstartup.c 2007-02-25 04:59:30 UTC (rev 1628)
@@ -70,24 +70,27 @@
} /*initsegment*/
-static boolean newfunctionprocessor (bigstring bsname, langvaluecallback valuecallback, boolean flwindow, hdlhashtable *htable) {
+static boolean newfunctionprocessor ( Handle handleName, langvaluecallback valuecallback, boolean flwindow, hdlhashtable *htable ) {
+
+ //
+ // each of the external function processors register with the system by
+ // calling this routine. we create a new hashtable in the EFP table, and
+ // return a handle to the new table. we also link in a callback routine
+ // that processes the verbs for this EFP. flwindow is also recorded -- it
+ // says whether or not the EFP requires a window be open in order for one
+ // of its verbs to be executed.
+ //
+ // 2007-02-24 creedon: support for long odb item names and file paths
+ //
+ // 1993-06-01 dmb: flwindow parameter is now real. when true, the
+ // valuecallback must respond to being called with a nil
+ // parameter list by determining whether or not a specific
+ // verb requires Frontier to be the current process.
+ //
- /*
- each of the external function processors register with the system by calling
- this routine. we create a new hashtable in the EFP table, and return a
- handle to the new table. we also link in a callback routine that processes the
- verbs for this EFP. flwindow is also recorded -- it says whether or not
- the EFP requires a window be open in order for one of its verbs to be
- executed.
-
- 6/1/93 dmb: flwindow parameter is now real. when true, the valuecallback must
- respond to being called with a nil parameter list by determining whether or not
- a specific verb requires Frontier to be the current process.
- */
-
register hdlhashtable ht;
- if (!tablenewsystemtable (efptable, bsname, htable))
+ if ( ! tablenewsystemtable ( efptable, handleName, htable ) )
return (false);
ht = *htable; /*copy into register*/
@@ -97,86 +100,75 @@
(**ht).valueroutine = valuecallback;
return (true);
+
} /*newfunctionprocessor*/
-static boolean hashinsertcstring (bigstring bs, const tyvaluerecord *v) {
+static boolean langaddcstringkeyword (bigstring bs, short tokennumber) {
- convertcstring (bs);
-
- return (hashinsert (bs, *v));
- } /*hashinsertcstring*/
-
-
-static boolean langaddcstringkeyword (bigstring bs, short tokennumber) {
+ //
+ // 2007-02-24 creedon: support for long odb item names and file paths
+ //
+ Handle h;
tyvaluerecord val;
initvalue (&val, tokenvaluetype);
val.data.tokenvalue = (short) tokennumber;
- return (hashinsertcstring (bs, &val));
- } /*langaddcstringkeyword*/
+ newfilledhandle ( bs, strlen ( bs ), &h );
+ return ( hashinsert ( h, val ) );
+
+ } // langaddcstringkeyword
-boolean langaddkeyword (bigstring bs, short tokennumber) {
+
+boolean langaddkeyword ( const Handle h, short tokennumber ) {
tyvaluerecord val;
- initvalue (&val, tokenvaluetype);
+ initvalue ( &val, tokenvaluetype );
- val.data.tokenvalue = (short) tokennumber;
+ val.data.tokenvalue = ( short ) tokennumber;
- return (hashinsert (bs, val));
- } /*langaddkeyword*/
+ return ( hashinsert ( h, val ) );
-/*
-boolean langaddkeywordlist (hdlhashtable htable, byte * bskeywords[], short ctkeywords) {
+ } // langaddkeyword
- register short i;
- register boolean fl = true;
-
- pushhashtable (htable);
-
- for (i = 0; fl && (i < ctkeywords); i++)
- fl = langaddkeyword ((ptrstring) bskeywords [i], i);
-
- pophashtable ();
-
- return (fl);
- } /%langaddkeywordlist%/
-*/
boolean loadfunctionprocessor (short id, langvaluecallback valuecallback) {
+
+ //
+ // 2007-02-24 creedon: support for long odb item names and file paths
+ //
+ // 2006-04-16 aradke: swap byte-order on Intel Macs
+ //
+ // 2.1b5 dmb: having learning that our use of lots of string literals, and
+ // hence the "Seperate STRS" option in Think C was making us
+ // victim of an '040 instruction cache bug in Think C's run-time
+ // implementation of same, it's time to create the kernel tables
+ // directly from resources. that's what this routine does.
+ //
- /*
- 2.1b5 dmb: having learning that our use of lots of string literals, and
- hence the "Seperate STRS" option in Think C was making us victim of an
- '040 instruction cache bug in Think C's run-time implementation of same,
- it's time to create the kernel tables directly from resources. that's
- what this routine does.
-
- 2006-04-16 aradke: swap byte-order on Intel Macs
- */
-
- bigstring bsname;
+ Handle handleName, hefps;
+ boolean fl = true;
hdlhashtable htable;
- short flwindow;
long ix = 0;
- Handle hefps;
- short ctefps;
- short ctverbs;
- short ixverb = 0;
- boolean fl = true;
+ short ctefps, ctverbs, flwindow, ixverb = 0;
-#ifdef MACVERSION
- hefps = getresourcehandle ('EFP#', id);
-#endif
-#ifdef WIN95VERSION
- hefps = getresourcehandle ('EFP_', id);
-#endif
+ #ifdef MACVERSION
+ hefps = getresourcehandle ('EFP#', id);
+
+ #endif
+
+ #ifdef WIN95VERSION
+
+ hefps = getresourcehandle ('EFP_', id);
+
+ #endif
+
assert (hefps != nil);
if (hefps == nil)
@@ -188,18 +180,21 @@
reztomemshort (ctefps);
while (--ctefps >= 0) {
+
+ if ( ! newtexthandle ( BIGSTRING ( *hefps + ix ), &handleName ) )
+ return ( false );
+
+ ix += gethandlesize ( handleName ) + 1;
- copyrezstring (BIGSTRING (*hefps + ix), bsname);
-
- ix += stringsize (bsname);
-
if (!loadfromhandle (hefps, &ix, 2, &flwindow))
- return (false);
-
+ goto exit;
+
reztomemshort (flwindow);
- if (!newfunctionprocessor (bsname, valuecallback, (boolean) flwindow, &htable))
- return (false);
+ if (!newfunctionprocessor (handleName, valuecallback, (boolean) flwindow, &htable))
+ goto exit;
+
+ disposehandle ( handleName );
if (!loadfromhandle (hefps, &ix, 2, &ctverbs))
return (false);
@@ -209,97 +204,110 @@
pushhashtable (htable);
while (--ctverbs >= 0 && fl) {
+
+ if ( ! newtexthandle ( BIGSTRING ( *hefps + ix ), &handleName ) )
+ return ( false );
+
+ ix += gethandlesize (handleName) + 1;
- copyrezstring (BIGSTRING (*hefps + ix), bsname);
+ fl = langaddkeyword ( handleName, ixverb++ );
- ix += stringsize (bsname);
+ disposehandle ( handleName );
- fl = langaddkeyword ((ptrstring) bsname, ixverb++);
}
- pophashtable ();
+ pophashtable ( );
+
}
- releaseresourcehandle (hefps);
+ releaseresourcehandle ( hefps );
- return (fl);
- } /*loadfunctionprocessor*/
+ return ( fl );
+
+ exit:
+ disposehandle ( handleName );
+
+ return ( false );
+
+ } // loadfunctionprocessor
static boolean initenvironment (hdlhashtable ht) {
+ //
+ // 2007-02-24 creedon: support for long odb item names and file paths
+ //
+ // 2004-11-19 creedon - for Mac, get os build number, full display name, is server
+ //
+
#ifdef MACVERSION
+ OSErr err;
+ UInt32 response;
bigstring bsversion, bsos; /* 2004-11-19 creedon - added bsos*/
boolean isMacOsClassic, isServer; /* 2004-11-19 creedon */
unsigned long x;
- #if TARGET_API_MAC_CARBON == 1 /*PBS 7.028: system.environment.isCarbon*/
-
- /* 2004-11-19 creedon - added hcommand, hreturn, bs, response */
- Handle hcommand, hreturn;
- bigstring bs;
- UInt32 response;
- OSErr err;
-
- #endif
-
gestalt (gestaltSystemVersion, (long *)(&x));
- langassignbooleanvalue (ht, str_isMac, true);
+ langAssignBooleanValueBigstring (ht, str_isMac, true);
- langassignbooleanvalue (ht, str_isWindows, false);
+ langAssignBooleanValueBigstring (ht, str_isWindows, false);
- //langassignstringvalue (ht, str_osFlavor, zerostring);
+ // langassignstringvalue (ht, str_osFlavor, zerostring);
langassignlongvalue (ht, str_osMajorVersion, bcdtolong (x >> 8)); /* 2004-11-19 creedon - convert from bcd for correct display on Mac OS X */
langassignlongvalue (ht, str_osMinorVersion, (x & 0x00f0) >> 4);
- langassignlongvalue (ht, str_osPointVersion, x & 0x0f); /* 2004-11-19 creedon */
+ langassignlongvalue (ht, str_osPointVersion, x & 0x0f); /* 2004-11-19 creedon */
+
getsystemversionstring (bsversion, nil);
- langassignstringvalue (ht, str_osVersionString, bsversion);
+ langassignstringvalue ( ht, NULL, str_osVersionString, NULL, bsversion );
- /* langassignstringvalue (ht, str_osFullNameForDisplay, "\x09" "Macintosh"); 2004-11-19 creedon - moved to later in code*/
+ #if TARGET_API_MAC_CARBON == 1 /*PBS 7.028: system.environment.isCarbon*/
- #if TARGET_API_MAC_CARBON == 1 /*PBS 7.028: system.environment.isCarbon*/
-
- langassignbooleanvalue (ht, str_isCarbon, true);
+ langAssignBooleanValueBigstring (ht, str_isCarbon, true);
- /* 2004-11-19 creedon - get mac os build number, full display name, is server*/
-
- /* get mac os build number */
-
- newtexthandle ("\psw_vers -buildVersion", &hcommand);
+ /* get mac os build number */ {
- newemptyhandle (&hreturn);
-
- unixshellcall (hcommand, hreturn);
-
- texthandletostring (hreturn, bs);
-
- sethandlesize (hreturn, 0);
-
- setstringlength (bs, stringlength (bs) - 1);
-
- langassignstringvalue (ht, str_osBuildNumber, bs); /* get mac os build number */
-
- /* get os full display name */
-
- copystring ((unsigned char *)"sw_vers -productName", bs);
-
- sethandlecontents (bs, stringsize (bs), hcommand);
-
- unixshellcall (hcommand, hreturn);
-
- texthandletostring (hreturn, bsos);
-
- setstringlength (bsos, stringlength (bsos) - 1); /* get os full display name */
-
- disposehandle (hcommand);
- disposehandle (hreturn); /* get mac os build number and full display name*/
-
+ Handle hcommand, hreturn;
+ bigstring bs;
+
+ newtexthandle ("\psw_vers -buildVersion", &hcommand);
+
+ newemptyhandle (&hreturn);
+
+ unixshellcall (hcommand, hreturn);
+
+ texthandletostring (hreturn, bs);
+
+ sethandlesize (hreturn, 0);
+
+ setstringlength (bs, stringlength (bs) - 1);
+
+ langassignstringvalue ( ht, NULL, str_osBuildNumber, NULL, bs ); /* get mac os build number */
+
+ /* get os full display name */ {
+
+ copystring ((unsigned char *)"sw_vers -productName", bs);
+
+ sethandlecontents (bs, stringsize (bs), hcommand);
+
+ unixshellcall (hcommand, hreturn);
+
+ texthandletostring (hreturn, bsos);
+
+ setstringlength (bsos, stringlength (bsos) - 1);
+
+ }
+
+ disposehandle (hcommand);
+ disposehandle (hreturn);
+
+ }
+
/* 2004-11-19 creedon - is mac os classic */
/* This needs to be checked on Mac OS Classic as well as Mac OS 9 proper. */
@@ -310,17 +318,15 @@
else
isMacOsClassic = false;
- /* 2004-11-19 creedon - is server */
-
if (equalstrings (bsos, "\pMac OS X Server"))
isServer = true;
else
isServer = false; /* is server */
-
+
#else
+
+ langAssignBooleanValueBigstring (ht, str_isCarbon, false);
- langassignbooleanvalue (ht, str_isCarbon, false);
-
copystring (BIGSTRING ("\x06" "Mac OS"), bsos); /* 2004-11-19 creedon - Mac OS, used to be Macintosh*/
isMacOsClassic = true; /* 2004-11-19 creedon */
@@ -329,11 +335,11 @@
#endif
- langassignbooleanvalue (ht, str_isMacOsClassic, isMacOsClassic); /* 2004-11-19 creedon */
+ langAssignBooleanValueBigstring (ht, str_isMacOsClassic, isMacOsClassic); /* 2004-11-19 creedon */
- langassignstringvalue (ht, str_osFullNameForDisplay, bsos); /* 2004-11-19 creedon - changed "\x06" "Mac OS" to bsos. a calculated value */
+ langassignstringvalue ( ht, NULL, str_osFullNameForDisplay, NULL, bsos ); /* 2004-11-19 creedon - changed "\x06" "Mac OS" to bsos. a calculated value */
- langassignbooleanvalue (ht, str_isServer, isServer); /* 2004-11-19 creedon */
+ langAssignBooleanValueBigstring (ht, str_isServer, isServer); /* 2004-11-19 creedon */
#endif
@@ -350,9 +356,9 @@
copystring (BIGSTRING ("\x08" "Windows "), bsos);
- langassignbooleanvalue (ht, str_isMac, false);
+ langAssignBooleanValueBigstring (ht, str_isMac, false);
- langassignbooleanvalue (ht, str_isWindows, true);
+ langAssignBooleanValueBigstring (ht, str_isWindows, true);
if (osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
copystring (BIGSTRING ("\x02" "NT"), bsflavor);
@@ -371,7 +377,7 @@
pushstring (bsflavor, bsos);
- langassignstringvalue (ht, str_osFlavor, bsflavor);
+ langassignstringvalue ( ht, NULL, str_osFlavor, NULL, bsflavor );
langassignlongvalue (ht, str_osMajorVersion, osinfo.dwMajorVersion);
@@ -381,17 +387,17 @@
getsystemversionstring (bsversion, bsservicepack);
- langassignstringvalue (ht, str_osVersionString, bsversion);
+ langassignstringvalue ( ht, NULL, str_osVersionString, NULL, bsversion );
- langassignstringvalue (ht, str_winServicePackNumber, bsservicepack);
+ langassignstringvalue ( ht, NULL, str_winServicePackNumber, NULL, bsservicepack );
- langassignstringvalue (ht, str_osFullNameForDisplay, bsos);
+ langassignstringvalue ( ht, NULL, str_osFullNameForDisplay, NULL, bsos );
- langassignbooleanvalue (ht, str_isCarbon, false); /*7.0b28: isCarbon is false on Windows.*/
+ langAssignBooleanValueBigstring (ht, str_isCarbon, false); /*7.0b28: isCarbon is false on Windows.*/
- langassignbooleanvalue (ht, str_isMacOsClassic, false); /* 2006-02-18 aradke */
+ langAssignBooleanValueBigstring (ht, str_isMacOsClassic, false); /* 2006-02-18 aradke */
- langassignbooleanvalue (ht, str_isServer, isServer); /* 2004-11-19 creedon */
+ langAssignBooleanValueBigstring (ht, str_isServer, isServer); /* 2004-11-19 creedon */
#endif
@@ -399,155 +405,163 @@
#ifdef PIKE
#ifndef OPMLEDITOR
- langassignbooleanvalue (ht, str_isPike, true);
+ langAssignBooleanValueBigstring (ht, str_isPike, true);
- langassignbooleanvalue (ht, str_isRadio, true); /*7.0b37 PBS: system.environment.isRadio*/
- langassignbooleanvalue (ht, str_isOpmlEditor, false); /*2005-04-06 dluebbert: system.environment.isOPML*/
- langassignbooleanvalue (ht, str_isFrontier, false); /*2005-04-06 dluebbert: system.environment.isFrontier*/
+ langAssignBooleanValueBigstring (ht, str_isRadio, true); /*7.0b37 PBS: system.environment.isRadio*/
+ langAssignBooleanValueBigstring (ht, str_isOpmlEditor, false); /*2005-04-06 dluebbert: system.environment.isOPML*/
+ langAssignBooleanValueBigstring (ht, str_isFrontier, false); /*2005-04-06 dluebbert: system.environment.isFrontier*/
#else // OPMLEDITOR
- langassignbooleanvalue (ht, str_isPike, false);
+ langAssignBooleanValueBigstring (ht, str_isPike, false);
- langassignbooleanvalue (ht, str_isRadio, false); /*7.0b37 PBS: system.environment.isRadio*/
- langassignbooleanvalue (ht, str_isOpmlEditor, true); /*2005-04-06 dluebbert: system.environment.isOPML*/
- langassignbooleanvalue (ht, str_isFrontier, false); /*2005-04-06 dluebbert: system.environment.isFrontier*/
+ langAssignBooleanValueBigstring (ht, str_isRadio, false); /*7.0b37 PBS: system.environment.isRadio*/
+ langAssignBooleanValueBigstring (ht, str_isOpmlEditor, true); /*2005-04-06 dluebbert: system.environment.isOPML*/
+ langAssignBooleanValueBigstring (ht, str_isFrontier, false); /*2005-04-06 dluebbert: system.environment.isFrontier*/
#endif // OPMLEDITOR
#else //!PIKE
- langassignbooleanvalue (ht, str_isPike, false);
+ langAssignBooleanValueBigstring (ht, str_isPike, false);
- langassignbooleanvalue (ht, str_isRadio, false); /*7.0b37 PBS: system.environment.isRadio*/
- langassignbooleanvalue (ht, str_isOpmlEditor, false); /*2005-04-06 dluebbert: system.environment.isOPML*/
- langassignbooleanvalue (ht, str_isFrontier, true); /*2005-04-06 dluebbert: system.environment.isFrontier*/
+ langAssignBooleanValueBigstring (ht, str_isRadio, false); /*7.0b37 PBS: system.environment.isRadio*/
+ langAssignBooleanValueBigstring (ht, str_isOpmlEditor, false); /*2005-04-06 dluebbert: system.environment.isOPML*/
+ langAssignBooleanValueBigstring (ht, str_isFrontier, true); /*2005-04-06 dluebbert: system.environment.isFrontier*/
#endif //!PIKE
return (true);
+
} /*initenvironment*/
-static boolean initCharsetsTable (hdlhashtable cSetsTable)
-{
-#if MACVERSION
- OSStatus err;
- ItemCount ct, actual_ct, i;
-
- err = TECCountAvailableTextEncodings( &ct );
- if ( err != noErr ) {
- return (true); // don't kill the whole startup
- }
-
- TextEncoding enc, encOut;
- TextEncoding availEncodings[ ct ];
- bigstring ianaName, displayName;
- unsigned long lenDisplayName;
- RegionCode reg;
-
- err = TECGetAvailableTextEncodings ( availEncodings, ct, &actual_ct );
- if ( err != noErr )
- return (true); // we don't want to kill the whole startup here
-
- for ( i = 0; i < actual_ct; i++ ) {
- enc = availEncodings[ i ];
+static boolean initCharsetsTable (hdlhashtable cSetsTable) {
+
+ #if MACVERSION
+
+ OSStatus err;
+ ItemCount ct, actual_ct, i;
- /*
- get the internet "iana" name for the encoding
- */
- err = TECGetTextEncodingInternetName( enc, ianaName );
- if ( err != noErr )
- continue;
+ err = TECCountAvailableTextEncodings( &ct );
+ if ( err != noErr ) {
+ return (true); // don't kill the whole startup
+ }
- /*
- now convert the "iana" name back into the canonical encoding value
- (more than one encoding will point to the same iana name,
- this makes sure that we use the right one)
- */
- err = TECGetTextEncodingFromInternetName( &enc, ianaName );
- if ( err != noErr )
- continue;
+ TextEncoding enc, encOut;
+ TextEncoding availEncodings[ ct ];
+ bigstring ianaName, displayName;
+ unsigned long lenDisplayName;
+ RegionCode reg;
- /*
- get the encoding's display name, which is the value of the table cell
- */
- err = GetTextEncodingName( enc, kTextEncodingFullName, verUS, kTextEncodingMacRoman, 255, &lenDisplayName, ®, &encOut, (TextPtr) displayName + 1 );
+ err = TECGetAvailableTextEncodings ( availEncodings, ct, &actual_ct );
if ( err != noErr )
- continue;
+ return (true); // we don't want to kill the whole startup here
- displayName[ 0 ] = (unsigned char) lenDisplayName;
+ for ( i = 0; i < actual_ct; i++ ) {
+ enc = availEncodings[ i ];
+
+ /*
+ get the internet "iana" name for the encoding
+ */
+ err = TECGetTextEncodingInternetName( enc, ianaName );
+ if ( err != noErr )
+ continue;
+
+ /*
+ now convert the "iana" name back into the canonical encoding value
+ (more than one encoding will point to the same iana name,
+ this makes sure that we use the ...
[truncated message content] |