Mailing List Archive

cvs commit: embperl/Embperl Tokens.pm
richter 00/05/16 05:44:25

Modified: . Tag: Embperl2 Embperl.xs ep.h epcomp.c epdat.h
epdom.c epdom.h epeval.c epmain.c epparse.c test.pl
Embperl Tag: Embperl2 Tokens.pm
Log:
- Embperl 2 - Cacheing

Revision Changes Path
No revision


No revision


1.26.2.3 +13 -11 embperl/Embperl.xs

Index: Embperl.xs
===================================================================
RCS file: /home/cvs/embperl/Embperl.xs,v
retrieving revision 1.26.2.2
retrieving revision 1.26.2.3
diff -u -r1.26.2.2 -r1.26.2.3
--- Embperl.xs 2000/05/15 06:32:52 1.26.2.2
+++ Embperl.xs 2000/05/16 12:44:20 1.26.2.3
@@ -607,29 +607,31 @@


void
-embperl_Node_replaceChildWithCDATA (xOldChild,sText)
+embperl_Node_replaceChildWithCDATA (xDomTree, xOldChild,sText)
+ int xDomTree
int xOldChild
SV * sText
CODE:
IV l ;
char * s = SvPV (sText, l) ;
- Node_replaceChildWithCDATA (-1, xOldChild, s, l) ;
+ Node_replaceChildWithCDATA (DomTree_self(xDomTree), -1, xOldChild, s, l) ;


void
-embperl_Node_removeChild (xChild)
+embperl_Node_removeChild (xDomTree, xChild)
+ int xDomTree
int xChild
CODE:
- Node_removeChild (-1, xChild) ;
+ Node_removeChild (DomTree_self (xDomTree), -1, xChild) ;


-void
-Node_parentNode (xChild)
- int xChild
-
-void
-Node_firstChild (xChild)
- int xChild
+#void
+#Node_parentNode (xChild)
+# int xChild
+#
+#void
+#Node_firstChild (xChild)
+# int xChild






1.23.2.2 +13 -0 embperl/ep.h

Index: ep.h
===================================================================
RCS file: /home/cvs/embperl/ep.h,v
retrieving revision 1.23.2.1
retrieving revision 1.23.2.2
diff -u -r1.23.2.1 -r1.23.2.2
--- ep.h 2000/05/15 06:32:52 1.23.2.1
+++ ep.h 2000/05/16 12:44:20 1.23.2.2
@@ -235,6 +235,11 @@
void NewEscMode (/*i/o*/ register req * r,
SV * pSV) ;

+int AddMagicAV (/*i/o*/ register req * r,
+ /*in*/ char * sVarName,
+ /*in*/ MGVTBL * pVirtTab) ;
+
+
/* ---- from epio.c ----- */


@@ -441,6 +446,11 @@
/*in*/ int nFilepos,
/*out*/ SV ** pRet) ;

+int EvalStore (/*i/o*/ register req * r,
+ /*in*/ const char * sArg,
+ /*in*/ int nFilepos,
+ /*out*/ SV ** pRet) ;
+
int EvalTrans (/*i/o*/ register req * r,
/*in*/ char * sArg,
/*in*/ int nFilepos,
@@ -473,3 +483,6 @@

int SetupDebugger (/*i/o*/ register req * r) ;

+
+
+extern struct tTokenTable DefaultTokenTable ;



1.1.2.6 +100 -19 embperl/Attic/epcomp.c

Index: epcomp.c
===================================================================
RCS file: /home/cvs/embperl/Attic/epcomp.c,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- epcomp.c 2000/05/15 06:32:53 1.1.2.5
+++ epcomp.c 2000/05/16 12:44:20 1.1.2.6
@@ -18,6 +18,7 @@
struct tEmbperlCmd
{
const char * sPerlCode ;
+ int bRemoveNode ;
} ;

char * pCode = NULL ;
@@ -63,6 +64,7 @@
nMaxEmbperlCmd = nNodeName ;

pEmbperlCmds[nNodeName].sPerlCode = GetHashValueStr (pHash, "perlcode", "") ;
+ pEmbperlCmds[nNodeName].bRemoveNode = GetHashValueInt (pHash, "removenode", 0) ;

if (r -> bDebug & dbgParse)
lprintf (r, "[%d]EPCOMP: InitItem %s (#%d) perlcode=%s\n", r -> nPid, Ndx2String(nNodeName), nNodeName, pEmbperlCmds[nNodeName].sPerlCode) ;
@@ -82,14 +84,15 @@
/* ------------------------------------------------------------------------ */


-embperl_CompileNode (/*in*/ tNode xNode)
+embperl_CompileNode (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNode xNode)


{
tNode xChildNode ;

int valid = 1 ;
- struct tNodeData * pNode = Node_self (xNode) ;
+ struct tNodeData * pNode = Node_self (pDomTree, xNode) ;
tStringIndex nNdx = Node_selfNodeNameNdx (pNode) ;

if (nNdx <= nMaxEmbperlCmd)
@@ -116,7 +119,7 @@
if (p[1] == '#')
{
int nChildNo = atoi (&p[2]) ;
- struct tNodeData * pChildNode = Node_selfNthChild (pNode, nChildNo) ;
+ struct tNodeData * pChildNode = Node_selfNthChild (pDomTree, pNode, nChildNo) ;

if (pChildNode)
StringAdd (&pCode, Node_selfNodeName(pChildNode), 0) ;
@@ -128,7 +131,7 @@
if (p[2] == 'n')
{
char s [20] ;
- int l = sprintf (s, "%u", pNode -> xNdx) ;
+ int l = sprintf (s, "$_ep_DomTree,%u", pNode -> xNdx) ;
StringAdd (&pCode, s, l) ;
}
}
@@ -138,7 +141,7 @@

if (p[1] == '!' || p[1] == '*')
{
- sVal = Element_selfGetAttribut (pNode, p + 2, q - p - 2) ;
+ sVal = Element_selfGetAttribut (pDomTree, pNode, p + 2, q - p - 2) ;
if ((sVal && p[1] == '!') || (!sVal && p[1] == '*') )
{
valid = 0 ;
@@ -146,7 +149,7 @@
}
}
else
- sVal = Element_selfGetAttribut (pNode, p + 1, q - p - 1) ;
+ sVal = Element_selfGetAttribut (pDomTree, pNode, p + 1, q - p - 1) ;

if (sVal)
{
@@ -171,21 +174,24 @@
{
StringAdd (&pProg, pCode, ArrayGetSize (pCode)) ;
StringAdd (&pProg, sPerlCode, 0) ;
+ StringAdd (&pProg, "\n", 1) ;
}
}
+ if (pCmd -> bRemoveNode)
+ Node_selfRemoveChild(pDomTree, -1, pNode) ;
}
}




- xChildNode = Node_firstChild (xNode) ;
+ xChildNode = Node_firstChild (pDomTree, xNode) ;

while (xChildNode)
{
- embperl_CompileNode (xChildNode) ;
+ embperl_CompileNode (pDomTree, xChildNode) ;

- xChildNode = Node_nextSibling (xChildNode) ;
+ xChildNode = Node_nextSibling (pDomTree, xChildNode) ;
}

}
@@ -199,24 +205,99 @@
/* ------------------------------------------------------------------------ */


-embperl_CompileDocument (/*in*/ tNode xDocument)
+embperl_CompileDocument (/*i/o*/ register req * r)


{
- SV * pSV ;
+ int rc ;
+ SV * pSV ;
+ SV ** ppSV ;
+ tNode xNode ;
+ tDomTree * pDomTree ;
+ clock_t cl1 = clock () ;
+ clock_t cl2 ;
+
+ /* Already Parsed ? */
+
+ ppSV = hv_fetch(r -> Buf.pFile -> pCacheHash, "SRCDOM", 6, 1) ;
+ if (ppSV == NULL)
+ return rcHashError ;
+
+ if (*ppSV != NULL && SvTYPE (*ppSV) == SVt_PV)
+ {
+ strncpy (r -> errdat1, SvPV(*ppSV, na), sizeof (r -> errdat1) - 1) ;
+ LogError (r, rcEvalErr) ;
+ return rcEvalErr ;
+ }

- tNode xNode = Node_firstChild (xDocument) ;
+ if (*ppSV == NULL || SvTYPE (*ppSV) != SVt_IV)
+ {
+ if ((rc = ParseFile (r)) != ok)
+ return rc ;
+
+ *ppSV = newSViv(r -> xCurrDomTree) ;
+ SvREFCNT_inc (*ppSV) ;
+ pDomTree = r -> pCurrDomTree ;
+
+ xNode = Node_firstChild (pDomTree, r -> xDocument) ;
+
+ StringNew (&pProg, 8192) ;
+ StringAdd (&pProg, "my $_ep_DomTree = $_[1]; print LOG \"ARGS = @_\\n\" ; \n", 0) ;
+
+ while (xNode)
+ {
+ embperl_CompileNode (pDomTree, xNode) ;
+
+ xNode = Node_nextSibling (pDomTree, xNode) ;
+ }

- StringNew (&pProg, 8192) ;
+ StringAdd (&pProg, "", 1) ;

+ if ((rc = EvalStore (r, pProg, 0, &pSV)) != ok)
+ return rc ;

- while (xNode)
+ cl2 = clock () ;
+#ifdef CLOCKS_PER_SEC
+ if (r -> bDebug)
+ {
+ lprintf (r, "[%d]PERF: Compile Start Time: %d ms \n", r -> nPid, ((cl1 - r -> startclock) * 1000 / CLOCKS_PER_SEC)) ;
+ lprintf (r, "[%d]PERF: Compile End Time: %d ms \n", r -> nPid, ((cl2 - r -> startclock) * 1000 / CLOCKS_PER_SEC)) ;
+ lprintf (r, "[%d]PERF: Compile Time: %d ms \n", r -> nPid, ((cl2 - cl1) * 1000 / CLOCKS_PER_SEC)) ;
+ }
+#endif
+ }
+ else
{
- embperl_CompileNode (xNode) ;
+ pDomTree = DomTree_self (SvIV (*ppSV)) ;
+ r -> xDocument = pDomTree -> xDocument ;
+ if ((rc = EvalStore (r, pProg, 0, &pSV)) != ok)
+ return rc ;
+ }
+
+
+ cl1 = clock () ;
+
+ if (!(r -> xCurrDomTree = DomTree_clone (pDomTree, &(r -> pCurrDomTree))))
+ return 1 ;

- xNode = Node_nextSibling (xNode) ;
+ if (pSV)
+ {
+ SV * args[2] ;
+ args[0] = r -> pReqSV ;
+ args[1] = newSViv (r -> xCurrDomTree) ;
+ CallStoredCV (r, pProg, (CV *)pSV, 2, args, 0, &pSV) ;
+ SvREFCNT_dec (args[1]) ;
}

- StringAdd (&pProg, "", 1) ;
- Eval (pCurrReq, pProg, 0, &pSV) ;
- }
\ No newline at end of file
+ cl2 = clock () ;
+#ifdef CLOCKS_PER_SEC
+ if (r -> bDebug)
+ {
+ lprintf (r, "[%d]PERF: Run Start Time: %d ms \n", r -> nPid, ((cl1 - r -> startclock) * 1000 / CLOCKS_PER_SEC)) ;
+ lprintf (r, "[%d]PERF: Run End Time: %d ms \n", r -> nPid, ((cl2 - r -> startclock) * 1000 / CLOCKS_PER_SEC)) ;
+ lprintf (r, "[%d]PERF: Run Time: %d ms \n", r -> nPid, ((cl2 - cl1) * 1000 / CLOCKS_PER_SEC)) ;
+ }
+#endif
+
+ return ok ;
+ }



1.17.2.2 +5 -1 embperl/epdat.h

Index: epdat.h
===================================================================
RCS file: /home/cvs/embperl/epdat.h,v
retrieving revision 1.17.2.1
retrieving revision 1.17.2.2
diff -u -r1.17.2.1 -r1.17.2.2
--- epdat.h 2000/05/15 06:32:53 1.17.2.1
+++ epdat.h 2000/05/16 12:44:20 1.17.2.2
@@ -261,7 +261,11 @@
int bExit ; /* We should exit the page */


- tNode xDocument ;
+ tNode xDocument ;
+ tIndex xCurrDomTree ;
+ tDomTree * pCurrDomTree ;
+ struct tTokenTable * pTokenTable ;
+

/* --- Source in memory --- */




1.1.2.10 +174 -61 embperl/Attic/epdom.c

Index: epdom.c
===================================================================
RCS file: /home/cvs/embperl/Attic/epdom.c,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- epdom.c 2000/05/15 06:32:53 1.1.2.9
+++ epdom.c 2000/05/16 12:44:20 1.1.2.10
@@ -18,12 +18,10 @@
HV * pStringTableHash ; /* Hash to translate strings to index number */
const char * * pStringTableArray ; /* Array with pointers to strings */

+tDomTree * pDomTrees ;

-struct tNodeData * * pNodeLookup ;
-struct tNodePad * * pPadLookup ;
+int nInitialNodePadSize = 196 ;

-int nInitialNodePadSize = 128 ;
-
int nMemUsage = 0 ;
int numNodes = 0 ;
int numAttr = 0 ;
@@ -61,7 +59,34 @@
return ok ;
}

+/* ------------------------------------------------------------------------ */
+/* */
+/* ArrayClone */
+/* */
+/* Create a new dynamic array as exact copy of old one */
+/* */
+/* ------------------------------------------------------------------------ */
+
+int ArrayClone (/*in*/ const tArray * pOrgArray,
+ /*out*/ const tArray * pNewArray)
+

+ {
+ struct tArrayCtrl * pNew ;
+ struct tArrayCtrl * pCtrl = ((struct tArrayCtrl *)(*(void * *)pOrgArray)) - 1 ;
+ int size = pCtrl -> nFill * pCtrl -> nElementSize + sizeof (struct tArrayCtrl) ;
+
+ if ((pNew = dom_malloc (size)) == NULL)
+ return 0 ;
+
+ memcpy (pNew, pCtrl, size) ;
+ *(void * *)pNewArray = (struct tArray *)(pNew + 1) ;
+ pNew -> nMax = pCtrl -> nFill ;
+
+ return ok ;
+ }
+
+
/* ------------------------------------------------------------------------ */
/* */
/* ArrayAdd */
@@ -301,15 +326,67 @@
ArrayNew (&pStringTableArray, 128, sizeof (char *)) ;
String2Ndx ("", 0) ;

- ArrayNew (&pNodeLookup, 128, sizeof (struct tNodeData *)) ;
- ArrayAdd (&pNodeLookup, 1) ;
- pNodeLookup[0] = NULL ;
- ArrayNew (&pPadLookup, 128, sizeof (struct tNodePad *)) ;
- ArrayAdd (&pPadLookup, 1) ;
- pPadLookup[0] = NULL ;
+ ArrayNew (&pDomTrees, 16, sizeof (tDomTree)) ;
+ ArrayAdd (&pDomTrees, 1) ;
+ memset (&pDomTrees[0], 0, sizeof (tDomTree)) ;
}

+/* ------------------------------------------------------------------------ */
+/* */
+/* DomTree_new */
+/* */
+/* */
+/* */
+/* ------------------------------------------------------------------------ */
+
+int DomTree_new (tDomTree * * pNewLookup)
+
+ {
+ tDomTree * pDomTree ;
+ int n ;
+
+ n = ArrayAdd (&pDomTrees, 1) ;
+ pDomTree = DomTree_self (n) ;

+ ArrayNew (&pDomTree -> pLookup, 128, sizeof (struct tNodeData *)) ;
+ ArrayAdd (&pDomTree -> pLookup, 1) ;
+
+ pDomTree -> xNdx = n ;
+ pDomTree -> pLookup[0] = NULL ;
+
+ *pNewLookup = pDomTree ;
+
+ return n ;
+ }
+
+/* ------------------------------------------------------------------------ */
+/* */
+/* DomTree_new */
+/* */
+/* */
+/* */
+/* ------------------------------------------------------------------------ */
+
+int DomTree_clone (/*in*/ tDomTree * pOrgDomTree,
+ /*out*/tDomTree * * pNewDomTree)
+
+ {
+ tDomTree * pDomTree ;
+ int n ;
+
+ n = ArrayAdd (&pDomTrees, 1) ;
+ pDomTree = DomTree_self (n) ;
+ pDomTree -> xNdx = n ;
+
+ ArrayClone (pOrgDomTree, &pDomTree -> pLookup) ;
+
+ *pNewDomTree = pDomTree ;
+
+ return n ;
+ }
+
+
+
int mydie (char * msg)
{
puts (msg) ;
@@ -389,13 +466,14 @@
/* ------------------------------------------------------------------------ */


-static struct tNodePad * NewPad (/*in*/ tIndex xParent)
+static struct tNodePad * NewPad (/*in*/ tDomTree * pDomTree,
+ /*in*/ tIndex xParent)

{
- tIndex xNdx = ArrayAdd (&pPadLookup, 1) ;
+ tIndex xNdx = ArrayAdd (&pDomTree -> pLookup, 1) ;
struct tNodePad * pChilds ;

- if ((pPadLookup [xNdx] = pChilds = dom_malloc (nInitialNodePadSize)) == NULL)
+ if ((pDomTree -> pLookup[xNdx] = pChilds = dom_malloc (nInitialNodePadSize)) == NULL)
return NULL ;

pChilds -> nType = ntypPad ;
@@ -425,7 +503,7 @@



-tNode Node_appendChild (/*i/o*/ register req * r,
+tNode Node_appendChild (/*in*/ tDomTree * pDomTree,
/*in*/ tNodeType nType,
/*in*/ const char * sText,
/*in*/ int nTextLen,
@@ -433,10 +511,10 @@
/*in*/ int nLevel)

{
- struct tNodeData * pParent = pNodeLookup [xParent] ;
+ struct tNodeData * pParent = Node_self (pDomTree, xParent) ;

- if (r -> bDebug & dbgParse)
- lprintf (r, "[%d]PARSE: AddNode: +%02d parent=%d %*s type=%d text=%*.*s (#%d)\n", r -> nPid, nLevel, xParent, nLevel * 2, "", nType, nTextLen, nTextLen, sText, sText?String2Ndx (sText, nTextLen):-1) ;
+ if (pCurrReq -> bDebug & dbgParse)
+ lprintf (pCurrReq, "[%d]PARSE: AddNode: +%02d parent=%d %*s type=%d text=%*.*s (#%d)\n", pCurrReq -> nPid, nLevel, xParent, nLevel * 2, "", nType, nTextLen, nTextLen, sText, sText?String2Ndx (sText, nTextLen):-1) ;

if (nType == ntypAttr)
{
@@ -452,30 +530,30 @@
}
if (((tUInt8 *)pNew) - ((tUInt8 *)pPad) + sizeof (struct tAttrData) > pPad -> nMax)
{ /* pad full -> move into new pad */
- struct tNodePad * pNext = NewPad (pPad -> xParent) ;
+ struct tNodePad * pNext = NewPad (pDomTree, pPad -> xParent) ;
int nNodeSize = ((tUInt8 *)pNew) - ((tUInt8 *)pParent) ;
struct tNodeData * pNewParent = (struct tNodeData * )(pNext + 1) ;
- lprintf (r, "[%d]PARSE: NewPad Extent Attr: %d -> %d\n", r -> nPid, pPad -> xParent, pNext -> xNdx) ;
+ /* lprintf (pCurrReq, "[%d]PARSE: NewPad Extent Attr: %d -> %d\n", pCurrReq -> nPid, pPad -> xParent, pNext -> xNdx) ; */

if (nNodeSize + sizeof (struct tNodePad) >= nInitialNodePadSize)
- mydie ("pad too small for attr -> make room") ;
+ mydie ("pad too small for attpCurrReq -> make room") ;

pNext -> xPrev = pPad -> xNdx ;
pPad -> xNext = pNext -> xNdx ;
- pPadLookup[pPad->xFirst] -> xLast = pNext -> xNdx ;
+ ((struct tNodePad *)(pDomTree -> pLookup[pPad->xFirst])) -> xLast = pNext -> xNdx ;
pNext -> xFirst = pPad->xFirst ;

memcpy (pNewParent, pParent, nNodeSize) ;
pNewParent -> nPadOffset = pNext -> nFill ;
- pNodeLookup [xParent] = pParent = pNewParent ;
+ pDomTree -> pLookup[xParent] = pParent = pNewParent ;
pNew = ((struct tAttrData * )(pParent + 1)) + pParent -> numAttr ;
pPad -> nFill -= nNodeSize ;
pNext -> nFill += nNodeSize ;
pPad = pNext ;
}

- xNdx = ArrayAdd (&pNodeLookup, 1) ;
- pNodeLookup[xNdx] = (struct tNodeData *)pNew ;
+ xNdx = ArrayAdd (&pDomTree -> pLookup, 1) ;
+ pDomTree -> pLookup[xNdx] = (struct tNodeData *)pNew ;

pNew -> xName = String2Ndx (sText, nTextLen) ;
pNew -> xValue = 0 ;
@@ -489,7 +567,7 @@
}
else if (nType == ntypAttrValue)
{
- struct tAttrData * pNew = (struct tAttrData * )pNodeLookup[xParent] ; // ((struct tAttrData * )pParent + 1) + (pParent -> numAttr - 1);
+ struct tAttrData * pNew = (struct tAttrData * )pDomTree -> pLookup[xParent] ; // ((struct tAttrData * )pParent + 1) + (pParent -> numAttr - 1);
pNew -> xValue = String2Ndx (sText, nTextLen) ;
return 1 ;
}
@@ -501,29 +579,29 @@

if (pParent && pParent -> nType == ntypAttr)
{
- pChilds = NewPad (xParent) ;
- lprintf (r, "[%d]PARSE: NewPad NewAttrChild: %d -> %d\n", r -> nPid, xParent, pChilds -> xNdx) ;
+ pChilds = NewPad (pDomTree, xParent) ;
+ /* lprintf (pCurrReq, "[%d]PARSE: NewPad NewAttrChild: %d -> %d\n", pCurrReq -> nPid, xParent, pChilds -> xNdx) ; */

((struct tAttrData *)pParent) -> xValue = pChilds -> xNdx ;
}
else if (!pParent || !pParent -> xChilds)
{
- pChilds = NewPad (xParent) ;
- lprintf (r, "[%d]PARSE: NewPad NewChild: %d -> %d\n", r -> nPid, xParent, pChilds -> xNdx) ;
+ pChilds = NewPad (pDomTree, xParent) ;
+ /* lprintf (pCurrReq, "[%d]PARSE: NewPad NewChild: %d -> %d\n", pCurrReq -> nPid, xParent, pChilds -> xNdx) ; */

if (pParent)
pParent -> xChilds = pChilds -> xNdx ;
}
else
{
- struct tNodePad * pFirst = pChilds = pPadLookup [pParent -> xChilds] ;
+ struct tNodePad * pFirst = pChilds = NodePad_self (pDomTree, pParent -> xChilds) ;
if (pChilds -> xLast)
- pChilds = pPadLookup [pChilds -> xLast] ;
+ pChilds = NodePad_self (pDomTree, pChilds -> xLast) ;

if (pChilds -> nFill + sizeof (struct tNodeData) > pChilds -> nMax)
{ /* pad full -> make room */
- struct tNodePad * pNext = NewPad (xParent) ;
- lprintf (r, "[%d]PARSE: NewPad Extent Childs: %d -> %d\n", r -> nPid, xParent, pNext -> xNdx) ;
+ struct tNodePad * pNext = NewPad (pDomTree, xParent) ;
+ /* lprintf (pCurrReq, "[%d]PARSE: NewPad Extent Childs: %d -> %d\n", pCurrReq -> nPid, xParent, pNext -> xNdx) ; */

pNext -> xPrev = pChilds -> xNdx ;
pChilds -> xNext = pNext -> xNdx ;
@@ -536,8 +614,8 @@

pNew = (struct tNodeData *)(((tUInt8 *)pChilds) + pChilds -> nFill) ;

- xNdx = ArrayAdd (&pNodeLookup, 1) ;
- pNodeLookup[xNdx] = pNew ;
+ xNdx = ArrayAdd (&pDomTree -> pLookup, 1) ;
+ pDomTree -> pLookup[xNdx] = pNew ;

pNew -> nText = String2Ndx (sText, nTextLen) ;
pNew -> nType = nType ;
@@ -565,11 +643,12 @@



-tNode Node_removeChild (/*in*/ tNode xNode,
- /*in*/ tNode xChild)
+tNode Node_removeChild (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNode xNode,
+ /*in*/ tNode xChild)

{
- struct tNodeData * pChild = pNodeLookup [xChild] ;
+ struct tNodeData * pChild = Node_self (pDomTree, xChild) ;
struct tNodePad * pPad = (struct tNodePad * )(((tUInt8 *)pChild) - pChild -> nPadOffset) ;

if (xNode != -1 && pPad -> xParent != xNode)
@@ -581,6 +660,32 @@
return xChild ;
}

+/* ------------------------------------------------------------------------ */
+/* */
+/* Node_removeChild */
+/* */
+/* Remove a child node */
+/* */
+/* ------------------------------------------------------------------------ */
+
+
+
+struct tNodeData * Node_selfRemoveChild (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNode xNode,
+ /*in*/ struct tNodeData * pChild)
+
+ {
+ struct tNodePad * pPad = (struct tNodePad * )(((tUInt8 *)pChild) - pChild -> nPadOffset) ;
+
+ if (xNode != -1 && pPad -> xParent != xNode)
+ return 0 ;
+
+ pChild -> bFlags = 0 ;
+ pPad -> numChilds-- ;
+
+ return pChild ;
+ }
+

/* ------------------------------------------------------------------------ */
/* */
@@ -592,13 +697,14 @@



-tNode Node_replaceChildWithCDATA (/*in*/ tNode xNode,
+tNode Node_replaceChildWithCDATA (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNode xNode,
/*in*/ tNode xOldChild,
/*in*/ const char * sText,
/*in*/ int nTextLen)

{
- struct tNodeData * pOldChild = pNodeLookup [xOldChild] ;
+ struct tNodeData * pOldChild = Node_self (pDomTree, xOldChild) ;

pOldChild -> nType = ntypCDATA ;
pOldChild -> nText = String2Ndx(sText, nTextLen) ;
@@ -618,10 +724,11 @@
/* ------------------------------------------------------------------------ */


-tNode Node_parentNode (/*in*/ tNode xNode)
+tNode Node_parentNode (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNode xNode)

{
- struct tNodeData * pNode = pNodeLookup [xNode] ;
+ struct tNodeData * pNode = Node_self (pDomTree, xNode) ;
struct tNodePad * pPad = (struct tNodePad * )(((tUInt8 *)pNode) - pNode -> nPadOffset) ;
/* lprintf (pCurrReq, "[%d]PARSE: parentNode: %d -> %d\n", pCurrReq -> nPid, xNode, pPad -> xParent) ; */
return pPad -> xParent ;
@@ -636,10 +743,11 @@
/* ------------------------------------------------------------------------ */


-tNode Node_firstChild (/*in*/ tNode xNode)
+tNode Node_firstChild (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNode xNode)

{
- struct tNodePad * pPad = pPadLookup[pNodeLookup [xNode] -> xChilds] ;
+ struct tNodePad * pPad = NodePad_self (pDomTree, Node_self (pDomTree, xNode) -> xChilds) ;
if (pPad == NULL)
return 0 ;

@@ -656,11 +764,12 @@
/* ------------------------------------------------------------------------ */


-struct tNodeData * Node_selfNthChild (/*in*/ struct tNodeData * pNode,
+struct tNodeData * Node_selfNthChild (/*in*/ tDomTree * pDomTree,
+ /*in*/ struct tNodeData * pNode,
/*in*/ int nChildNo)

{
- struct tNodePad * pPad = pPadLookup[pNode -> xChilds] ;
+ struct tNodePad * pPad = pDomTree -> pLookup[pNode -> xChilds] ;
struct tNodeData * pChildNode ;

if (pPad == NULL)
@@ -669,7 +778,7 @@
while (nChildNo >= pPad -> numChilds && pPad -> xNext)
{
nChildNo -= pPad -> numChilds ;
- pPad = pPadLookup[pPad -> xNext] ;
+ pPad = pDomTree -> pLookup[pPad -> xNext] ;
}

if (nChildNo < 0)
@@ -698,10 +807,11 @@
/* ------------------------------------------------------------------------ */


-tNode Node_nextSibling (/*in*/ tNode xNode)
+tNode Node_nextSibling (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNode xNode)

{
- struct tNodeData * pNode = pNodeLookup[xNode] ;
+ struct tNodeData * pNode = pDomTree -> pLookup[xNode] ;
struct tNodePad * pPad = (struct tNodePad * )(((tUInt8 *)pNode) - pNode -> nPadOffset) ;

int nOffset = sizeof (struct tNodeData) + sizeof (struct tAttrData) * pNode -> numAttr ;
@@ -711,13 +821,13 @@
if (!pPad -> xNext)
return 0 ;

- pPad = pPadLookup[pPad -> xNext] ;
+ pPad = pDomTree -> pLookup[pPad -> xNext] ;
return ((struct tNodeData *)(pPad + 1)) -> xNdx ;
}

pNode = (struct tNodeData *)(((tUInt8 *)pNode) + nOffset) ;
if (!pNode -> bFlags)
- return Node_nextSibling (pNode -> xNdx) ;
+ return Node_nextSibling (pDomTree, pNode -> xNdx) ;

return pNode -> xNdx ;
}
@@ -734,16 +844,17 @@
/* ------------------------------------------------------------------------ */


-void Node_toString (/*i/o*/ register req * r,
- /*in*/ tNode xNode)
+void Node_toString (/*in*/ tDomTree * pDomTree,
+ /*i/o*/ register req * r,
+ /*in*/ tNode xNode)


{
- xNode = Node_firstChild (xNode) ;
+ xNode = Node_firstChild (pDomTree, xNode) ;

while (xNode)
{
- struct tNodeData * pNode = Node_self (xNode) ;
+ struct tNodeData * pNode = Node_self (pDomTree, xNode) ;

if (pNode -> nType == ntypTag || pNode -> nType == ntypStartTag)
{
@@ -751,7 +862,7 @@
struct tAttrData * pAttr = (struct tAttrData *)(pNode + 1) ;

oputc (r, '<') ;
- oputs (r, Node_nodeName (xNode)) ;
+ oputs (r, Node_selfNodeName (pNode)) ;

while (n--)
{
@@ -770,7 +881,7 @@
oputs (r, Node_selfNodeName (pNode)) ;


- Node_toString (r, xNode) ;
+ Node_toString (pDomTree, r, xNode) ;

if (pNode -> nType == ntypStartTag)
{
@@ -779,7 +890,7 @@
oputc (r, '>') ;
}

- xNode = Node_nextSibling (xNode) ;
+ xNode = Node_nextSibling (pDomTree, xNode) ;
}

}
@@ -794,11 +905,12 @@
/* ------------------------------------------------------------------------ */


-void NodeList_toString (/*in*/ tNode xNode)
+void NodeList_toString (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNode xNode)


{
- xNode = Node_firstChild (xNode) ;
+ xNode = Node_firstChild (pDomTree, xNode) ;



@@ -862,7 +974,8 @@



-const char * Element_selfGetAttribut (/*in*/ struct tNodeData * pNode,
+const char * Element_selfGetAttribut (/*in*/ tDomTree * pDomTree,
+ /*in*/ struct tNodeData * pNode,
/*in*/ const char * sAttrName,
/*in*/ int nAttrNameLen)




1.1.2.7 +52 -14 embperl/Attic/epdom.h

Index: epdom.h
===================================================================
RCS file: /home/cvs/embperl/Attic/epdom.h,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- epdom.h 2000/05/15 06:32:54 1.1.2.6
+++ epdom.h 2000/05/16 12:44:21 1.1.2.7
@@ -38,7 +38,6 @@
typedef tIndex tAttr ;


-
struct tNodePad
{
tNodeType nType ;
@@ -53,6 +52,7 @@
tUInt16 nMax ;
} ;

+typedef struct tNodePad tNodePad ;

struct tNodeData
{
@@ -65,6 +65,7 @@
tUInt16 numAttr ;
} ;

+typedef struct tNodeData tNodeData ;

struct tAttrData
{
@@ -75,6 +76,7 @@
tIndex xValue ;
} ;

+typedef struct tAttrData tAttrData ;


/*
@@ -93,9 +95,20 @@
ntypAttrValue = 6,
} ;

+
+struct tDomTree
+ {
+ void * * pLookup ; /* table for converting tNode, tNodePad and tAttr to pointers */
+ tIndex xNdx ; /* Index of Dom Tree */
+ tNode xDocument ; /* root document node */
+ } ;
+
+typedef struct tDomTree tDomTree ;
+
+

-extern struct tNodeData * * pNodeLookup ;
-extern struct tNodePad * * pPadLookup ;
+
+extern tDomTree * pDomTrees ; /* Array with all Dom Trees */
extern const char * * pStringTableArray ; /* Array with pointers to strings */


@@ -120,7 +133,7 @@



-tNode Node_appendChild (/*i/o*/ register req * r,
+tNode Node_appendChild (/*in*/ tDomTree * pDomTree,
/*in*/ tNodeType nType,
/*in*/ const char * sText,
/*in*/ int nTextLen,
@@ -128,30 +141,55 @@
/*in*/ int nLevel) ;


-tNode Node_parentNode (/*in*/ tNode xNode) ;
+tNode Node_parentNode (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNode xNode) ;


-tNode Node_firstChild (/*in*/ tNode xNode) ;
+tNode Node_firstChild (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNode xNode) ;

-struct tNodeData * Node_selfNthChild (/*in*/ struct tNodeData * pNode,
+struct tNodeData * Node_selfNthChild (/*in*/ tDomTree * pDomTree,
+ /*in*/ struct tNodeData * pNode,
/*in*/ int nChildNo) ;


-tNode Node_nextSibling (/*in*/ tNode xNode) ;
+tNode Node_nextSibling (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNode xNode) ;

+#define DomTree_self(xDomTree) (&pDomTrees[xDomTree])
+#define NodePad_self(pDomTree,xNode) ((struct tNodePad *)(pDomTree -> pLookup[xNode]))

-#define Node_self(xNode) (pNodeLookup[xNode])
+#define Node_self(pDomTree,xNode) ((struct tNodeData *)(pDomTree -> pLookup[xNode]))

-#define Node_selfNodeNameNdx(pNode) (pNode -> nText) ;
-#define Node_selfNodeName(pNode) (pStringTableArray[pNode -> nText])
-#define Node_nodeName(pNode) (pStringTableArray[Node_self (xNode) -> nText])
+#define Node_selfNodeNameNdx(pNode) (pNode -> nText) ;
+#define Node_selfNodeName(pNode) (pStringTableArray[pNode -> nText])
+#define Node_nodeName(pDomTree,pNode) (pStringTableArray[Node_self (pDomTree,xNode) -> nText])

-void Node_toString (/*i/o*/ register req * r,
+void Node_toString (/*in*/ tDomTree * pDomTree,
+ /*i/o*/ register req * r,
/*in*/ tNode xNode) ;

+struct tNodeData * Node_selfRemoveChild (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNode xNode,
+ /*in*/ struct tNodeData * pChild) ;
+
+tNode Node_removeChild (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNode xNode,
+ /*in*/ tNode xChild) ;
+
+tNode Node_replaceChildWithCDATA (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNode xNode,
+ /*in*/ tNode xOldChild,
+ /*in*/ const char * sText,
+ /*in*/ int nTextLen) ;
+
+
+
+


-const char * Element_selfGetAttribut (/*in*/ struct tNodeData * pNode,
+const char * Element_selfGetAttribut (/*in*/ tDomTree * pDomTree,
+ /*in*/ struct tNodeData * pNode,
/*in*/ const char * sAttrName,
/*in*/ int nAttrNameLen) ;




1.20.2.2 +191 -0 embperl/epeval.c

Index: epeval.c
===================================================================
RCS file: /home/cvs/embperl/epeval.c,v
retrieving revision 1.20.2.1
retrieving revision 1.20.2.2
diff -u -r1.20.2.1 -r1.20.2.2
--- epeval.c 2000/05/15 06:32:54 1.20.2.1
+++ epeval.c 2000/05/16 12:44:21 1.20.2.2
@@ -440,6 +440,139 @@

/* -------------------------------------------------------------------------------
*
+* Call an already evaled PERL Statement
+*
+* in sArg Statement to eval (only used for logging)
+* in pSub CV which should be called
+* in numArgs number of arguments
+* in pArgs args for subroutine
+* out pRet pointer to SV contains the eval return
+*
+------------------------------------------------------------------------------- */
+
+
+int CallStoredCV (/*i/o*/ register req * r,
+ /*in*/ const char * sArg,
+ /*in*/ CV * pSub,
+ /*in*/ int numArgs,
+ /*in*/ SV ** pArgs,
+ /*in*/ int flags,
+ /*out*/ SV ** pRet)
+ {
+ int num ;
+ SV * pSVErr ;
+
+ dSP; /* initialize stack pointer */
+
+ EPENTRY (CallCV) ;
+
+ if (r -> bDebug & dbgEval)
+ lprintf (r, "[%d]EVAL< %s\n", r -> nPid, sArg) ;
+
+ tainted = 0 ;
+ pCurrReq = r ;
+
+ ENTER ;
+ SAVETMPS ;
+ PUSHMARK(sp); /* remember the stack pointer */
+ for (num = 0; num < numArgs; num++)
+ XPUSHs(pArgs [num]) ; /* push pointer to argument */
+ PUTBACK;
+
+ num = perl_call_sv ((SV *)pSub, flags | G_EVAL | (numArgs?0:G_NOARGS)) ; /* call the function */
+
+ SPAGAIN; /* refresh stack pointer */
+
+ if (r -> bDebug & dbgMem)
+ lprintf (r, "[%d]SVs: %d\n", r -> nPid, sv_count) ;
+ /* pop the return value from stack */
+ if (num == 1)
+ {
+ *pRet = POPs ;
+ if (SvTYPE (*pRet) == SVt_PVMG)
+ { /* variable is magicaly -> fetch value now */
+ SV * pSV = newSVsv (*pRet) ;
+ *pRet = pSV ;
+ }
+ else
+ SvREFCNT_inc (*pRet) ;
+
+ if (r -> bDebug & dbgEval)
+ {
+ if (SvOK (*pRet))
+ lprintf (r, "[%d]EVAL> %s\n", r -> nPid, SvPV (*pRet, na)) ;
+ else
+ lprintf (r, "[%d]EVAL> <undefined>\n", r -> nPid) ;
+ }
+ }
+ else if (num == 0)
+ {
+ *pRet = NULL ;
+ if (r -> bDebug & dbgEval)
+ lprintf (r, "[%d]EVAL> <NULL>\n", r -> nPid) ;
+ }
+ else
+ {
+ *pRet = &sv_undef ;
+ if (r -> bDebug & dbgEval)
+ lprintf (r, "[%d]EVAL> returns %d args instead of one\n", r -> nPid, num) ;
+ }
+
+ PUTBACK;
+ FREETMPS ;
+ LEAVE ;
+
+ if (r -> bExit)
+ {
+ if (*pRet)
+ SvREFCNT_dec (*pRet) ;
+ *pRet = NULL ;
+ return rcExit ;
+ }
+
+ pSVErr = ERRSV ;
+ if (SvTRUE (pSVErr))
+ {
+ STRLEN l ;
+ char * p ;
+
+ if (SvMAGICAL (pSVErr) && mg_find (pSVErr, 'U'))
+ {
+ /* On an Apache::exit call, the function croaks with error having 'U' magic.
+ * When we get this return, we'll just give up and quit this file completely,
+ * without error. */
+
+ /*struct magic * m = SvMAGIC (pSVErr) ;*/
+
+ sv_unmagic(pSVErr,'U');
+ sv_setpv(pSVErr,"");
+
+ r -> bOptions |= optNoUncloseWarn ;
+ r -> bExit = 1 ;
+
+ return rcExit ;
+ }
+
+ p = SvPV (pSVErr, l) ;
+ if (l > sizeof (r -> errdat1) - 1)
+ l = sizeof (r -> errdat1) - 1 ;
+ strncpy (r -> errdat1, p, l) ;
+ if (l > 0 && r -> errdat1[l-1] == '\n')
+ l-- ;
+ r -> errdat1[l] = '\0' ;
+
+ LogError (r, rcEvalErr) ;
+
+ sv_setpv(pSVErr,"");
+
+ return rcEvalErr ;
+ }
+
+
+ return ok ;
+ }
+/* -------------------------------------------------------------------------------
+*
* Eval PERL Statements and setup the correct return value/error message
*
* in sArg Statement to eval
@@ -613,6 +746,64 @@
return CallCV (r, sArg, (CV *)*ppSV, G_SCALAR, pRet) ;
}

+
+/* -------------------------------------------------------------------------------
+*
+* Eval PERL Statements check if it's already compiled
+*
+* in sArg Statement to eval
+* in nFilepos position von eval in file (is used to build an unique key)
+* out pRet pointer to SV contains the eval return
+*
+------------------------------------------------------------------------------- */
+
+int EvalStore (/*i/o*/ register req * r,
+ /*in*/ const char * sArg,
+ /*in*/ int nFilepos,
+ /*out*/ SV ** pRet)
+
+
+ {
+ int rc ;
+ SV ** ppSV ;
+
+
+ EPENTRY (Eval) ;
+
+ r -> numEvals++ ;
+ *pRet = NULL ;
+
+ if (r -> bDebug & dbgCacheDisable)
+ return EvalAllNoCache (r, sArg, pRet) ;
+
+ /* Already compiled ? */
+
+ ppSV = hv_fetch(r -> Buf.pFile -> pCacheHash, (char *)&nFilepos, sizeof (nFilepos), 1) ;
+ if (ppSV == NULL)
+ return rcHashError ;
+
+ if (*ppSV != NULL && SvTYPE (*ppSV) == SVt_PV)
+ {
+ strncpy (r -> errdat1, SvPV(*ppSV, na), sizeof (r -> errdat1) - 1) ;
+ LogError (r, rcEvalErr) ;
+ return rcEvalErr ;
+ }
+
+ if (*ppSV == NULL || SvTYPE (*ppSV) != SVt_PVCV)
+ {
+ if ((rc = EvalOnly (r, sArg, ppSV, G_SCALAR, "")) != ok)
+ {
+ *pRet = NULL ;
+ return rc ;
+ }
+ *pRet = *ppSV ;
+ return ok ;
+ }
+
+ *pRet = *ppSV ;
+ r -> numCacheHits++ ;
+ return ok ;
+ }

/* -------------------------------------------------------------------------------
*



1.65.2.3 +74 -6 embperl/epmain.c

Index: epmain.c
===================================================================
RCS file: /home/cvs/embperl/epmain.c,v
retrieving revision 1.65.2.2
retrieving revision 1.65.2.3
diff -u -r1.65.2.2 -r1.65.2.3
--- epmain.c 2000/05/15 06:32:54 1.65.2.2
+++ epmain.c 2000/05/16 12:44:21 1.65.2.3
@@ -16,6 +16,7 @@
#include "ep.h"
#include "epmacro.h"

+#define EP2 1

/* Version */

@@ -39,6 +40,7 @@
static char sTabMaxColName [] = "HTML::Embperl::maxcol" ;
static char sTabModeName [] = "HTML::Embperl::tabmode" ;
static char sEscModeName [] = "HTML::Embperl::escmode" ;
+static char sTokenHashName [] = "HTML::Embperl::Tokens::Main" ;


static char sDefaultPackageName [] = "HTML::Embperl::DOC::_%d" ;
@@ -1221,7 +1223,44 @@
return ok ;
}

+
+/* ---------------------------------------------------------------------------- */
+/* add magic to array */
+/* */
+/* in sVarName = Name of varibale */
+/* in pVirtTab = pointer to virtual table */
+/* */
+/* ---------------------------------------------------------------------------- */
+
+int AddMagicAV (/*i/o*/ register req * r,
+ /*in*/ char * sVarName,
+ /*in*/ MGVTBL * pVirtTab)
+
+ {
+ SV * pSV ;
+ struct magic * pMagic ;
+
+ EPENTRY (AddMagicAV) ;
+
+
+ pSV = (SV *)perl_get_av (sVarName, TRUE) ;
+ sv_magic (pSV, NULL, 'P', sVarName, strlen (sVarName)) ;
+ pMagic = mg_find (pSV, 0) ;
+
+ if (pMagic)
+ pMagic -> mg_virtual = pVirtTab ;
+ else
+ {
+ LogError (r, rcMagicError) ;
+ return 1 ;
+ }
+
+
+ return ok ;
+ }
+

+
/* ---------------------------------------------------------------------------- */
/* init embperl module */
/* */
@@ -1235,6 +1274,7 @@

{
int rc ;
+ HV * pTokenHash ;

req * r = &InitialReq ;

@@ -1457,6 +1497,25 @@
ADDOPTMG (dbgSession ) ;
ADDOPTMG (dbgImport ) ;

+
+#ifdef EP2
+ DomInit () ;
+ embperl_CompileInit () ;
+
+
+ if ((pTokenHash = perl_get_hv (sTokenHashName, TRUE)) == NULL)
+ {
+ return rcHashError ;
+ }
+ r -> pTokenTable = &DefaultTokenTable ;
+ if (rc = BuildTokenTable (r, pTokenHash , "", r -> pTokenTable))
+ {
+ LogError (r, rc) ;
+ return rc ;
+ }
+#endif
+
+
bInitDone = 1 ;

return rc ;
@@ -2401,10 +2460,13 @@
l -> pLastFreeBuf= r -> pLastFreeBuf ;
}
else
- Node_toString (r, r -> xDocument) ;
-
+ {
+ #ifdef EP2
+ Node_toString (r -> pCurrDomTree, r, r -> xDocument) ;
+ #endif
oCommit (r, NULL) ;
- }
+ }
+ }
}
else
{
@@ -2498,10 +2560,16 @@

r -> Buf.pSourcelinePos = r -> Buf.pCurrPos = r -> Buf.pBuf ;
r -> Buf.pEndPos = r -> Buf.pBuf + nFileSize ;
-
- rc = ParseFile (r) ;

- // rc = EvalMain (r) ;
+#ifdef EP2
+ rc = embperl_CompileDocument (r) ;
+#else
+ {
+ clock_t cl = clock () ;
+ lprintf (r, "[%d]PERF: Time: %d ms ", r -> nPid, ((cl - r -> startclock) * 1000 / CLOCKS_PER_SEC)) ;
+ }
+ rc = EvalMain (r) ;
+#endif

if ((r -> bOptions & optNoUncloseWarn) == 0)
{



1.1.2.11 +40 -31 embperl/Attic/epparse.c

Index: epparse.c
===================================================================
RCS file: /home/cvs/embperl/Attic/epparse.c,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -u -r1.1.2.10 -r1.1.2.11
--- epparse.c 2000/05/15 06:32:54 1.1.2.10
+++ epparse.c 2000/05/16 12:44:22 1.1.2.11
@@ -27,6 +27,7 @@
int nNodeName ; /* index in string table of node name */
enum tNodeType nNodeType ; /* type of the node that should be created */
enum tNodeType nCDataType ; /* type of the node that should be created */
+ int bUnescape ; /* translate input? */
unsigned char * pContains ; /* chars that could becontains in the string */
struct tTokenTable * pFollowedBy ; /* table of tokens that can follow this one */
struct tTokenTable * pInside ; /* table of tokens that can apear inside this one */
@@ -50,6 +51,11 @@
int nLen ;
} ;

+
+
+struct tTokenTable DefaultTokenTable ;
+
+
/* ------------------------------------------------------------------------ */
/* compare tokens */
/* ------------------------------------------------------------------------ */
@@ -270,6 +276,7 @@
p -> sEndText = GetHashValueStr (pHash, "end", pDefEnd) ;
p -> sNodeName = GetHashValueStr (pHash, "nodename", NULL) ;
p -> nNodeType = GetHashValueInt (pHash, "nodetype", ntypTag) ;
+ p -> bUnescape = GetHashValueInt (pHash, "unescape", 0) ;
p -> nCDataType = GetHashValueInt (pHash, "cdatatype", ntypCDATA) ;
if (sContains = GetHashValueStr (pHash, "contains", NULL))
{
@@ -380,12 +387,13 @@
/* ------------------------------------------------------------------------ */

int ParseTokens (/*i/o*/ register req * r,
- /*in */ char * * ppCurr,
- char * pEnd,
- struct tTokenTable * pTokenTable,
+ /*in */ char * * ppCurr,
+ char * pEnd,
+ struct tTokenTable * pTokenTable,
const char * sEndText,
const char * pParentContains,
- enum tNodeType nCDataType,
+ enum tNodeType nCDataType,
+ int bUnescape,
const char * pParentNodeName,
tNode xParentNode,
int level)
@@ -466,8 +474,12 @@
if (pCurrStart < pCurrTokenStart)
{
if (nCDataType)
- if (!(xNewNode = Node_appendChild (r, nCDataType, pCurrStart, pCurrTokenStart - pCurrStart, xParentNode, level)))
+ {
+ if (bUnescape)
+ TransHtml (r, pCurrStart, pCurrTokenStart - pCurrStart) ;
+ if (!(xNewNode = Node_appendChild (r -> pCurrDomTree, nCDataType, pCurrStart, pCurrTokenStart - pCurrStart, xParentNode, level)))
return 1 ;
+ }
pCurrStart = pCurrTokenStart ;
}

@@ -480,16 +492,16 @@
if (pEndCurr)
pCurr = pEndCurr + strlen (pToken -> sEndText) ;
level-- ;
- xParentNode = Node_parentNode (xParentNode) ;
+ xParentNode = Node_parentNode (r -> pCurrDomTree, xParentNode) ;
}
else
{
- if (!(xNewNode = Node_appendChild (r, pToken -> nNodeType, pNodeName, strlen (pNodeName), xParentNode, level)))
+ if (!(xNewNode = Node_appendChild (r -> pCurrDomTree, pToken -> nNodeType, pNodeName, strlen (pNodeName), xParentNode, level)))
return rc ;

if (pInside = pToken -> pInside)
{
- ParseTokens (r, &pCurr, pEnd, pInside, pToken -> sEndText, pToken -> pContains, pToken -> nCDataType, pNodeName, xNewNode, level+1) ;
+ ParseTokens (r, &pCurr, pEnd, pInside, pToken -> sEndText, pToken -> pContains, pToken -> nCDataType, pToken -> bUnescape, pNodeName, xNewNode, level+1) ;
}
else
{
@@ -512,8 +524,13 @@
if (pEndCurr)
{
if (pEndCurr - pCurr && pToken -> nCDataType)
- if (!(xNewNode = Node_appendChild (r, pToken -> nCDataType, pCurr, pEndCurr - pCurr, xNewNode, level+1)))
+ {
+ if (pToken -> bUnescape)
+ TransHtml (r, pCurr, pEndCurr - pCurr) ;
+
+ if (!(xNewNode = Node_appendChild (r -> pCurrDomTree, pToken -> nCDataType, pCurr, pEndCurr - pCurr, xNewNode, level+1)))
return 1 ;
+ }
pCurr = pEndCurr + nSkip ;
}
}
@@ -530,15 +547,17 @@
if (pParentContains && ((pParentContains [*pCurr >> 3] & 1 << (*pCurr & 7)) == 0) )
{
if (pCurr - pCurrStart && nCDataType)
- if (!(xNewNode = Node_appendChild (r, nCDataType, pCurrStart, pCurr - pCurrStart, xParentNode, level)))
+ {
+ if (!(xNewNode = Node_appendChild (r -> pCurrDomTree, nCDataType, pCurrStart, pCurr - pCurrStart, xParentNode, level)))
return 1 ;
+ }
break ;
}
else if (sEndText == NULL ||
(*pCurr == *sEndText && strncmp (pCurr, sEndText, nEndText) == 0))
{
if (pCurr - pCurrStart && nCDataType)
- if (!(xNewNode = Node_appendChild (r, nCDataType, pCurrStart, pCurr - pCurrStart, xParentNode, level)))
+ if (!(xNewNode = Node_appendChild (r -> pCurrDomTree, nCDataType, pCurrStart, pCurr - pCurrStart, xParentNode, level)))
return 1 ;
pCurr += nEndText ;
break ;
@@ -548,7 +567,7 @@
}

if (nCDataType)
- if (!(xNewNode = Node_appendChild (r, nCDataType, pCurrStart, pCurr - pCurrStart, xParentNode, level)))
+ if (!(xNewNode = Node_appendChild (r -> pCurrDomTree, nCDataType, pCurrStart, pCurr - pCurrStart, xParentNode, level)))
return 1 ;

*ppCurr = pCurr ;
@@ -571,38 +590,28 @@
{
char * pStart = r -> Buf.pBuf ;
char * pEnd = r -> Buf.pEndPos ;
- struct tTokenTable pTable ;
- int numTokens ;
- char * sTokenHash = "HTML::Embperl::Tokens::Main" ;
- HV * pTokenHash ;
int rc ;
tNode xDocNode ;

- DomInit () ;
- embperl_CompileInit () ;

- if ((pTokenHash = perl_get_hv ((char *)sTokenHash, TRUE)) == NULL)
- {
- return rcHashError ;
- }
- if (rc = BuildTokenTable (r, pTokenHash , "", &pTable))
- {
- LogError (r, rc) ;
- return rc ;
- }
+ if (!(r -> xCurrDomTree = DomTree_new (&(r -> pCurrDomTree))))
+ return 1 ;

- if (!(xDocNode = Node_appendChild (r, ntypTag, "attr", 3, 0, 0)))
+
+ if (!(xDocNode = Node_appendChild (r -> pCurrDomTree, ntypTag, "attr", 3, 0, 0)))
return 1 ;

- if (!(xDocNode = Node_appendChild (r, ntypTag, "doc", 3, 0, 0)))
+ if (!(xDocNode = Node_appendChild (r -> pCurrDomTree, ntypTag, "doc", 3, 0, 0)))
return 1 ;

- if ((rc = ParseTokens (r, &pStart, pEnd, &pTable, "", NULL, ntypCDATA, "root", xDocNode, 0)) != ok)
+ if ((rc = ParseTokens (r, &pStart, pEnd, r -> pTokenTable, "", NULL, ntypCDATA, 0, "root", xDocNode, 0)) != ok)
return rc ;

+ r -> pCurrDomTree -> xDocument = xDocNode ;
r -> xDocument = xDocNode ;

- return embperl_CompileDocument (xDocNode) ;
+
+ return ok ;
}





1.57.2.5 +2 -1 embperl/test.pl

Index: test.pl
===================================================================
RCS file: /home/cvs/embperl/test.pl,v
retrieving revision 1.57.2.4
retrieving revision 1.57.2.5
diff -u -r1.57.2.4 -r1.57.2.5
--- test.pl 2000/05/15 06:32:55 1.57.2.4
+++ test.pl 2000/05/16 12:44:22 1.57.2.5
@@ -208,7 +208,8 @@
$host = 'localhost' ;
$httpdpid = 0 ;
$defaultdebug = 0x1f85ffd ;
-
+#$defaultdebug = 1 ;
+#$ignoreerror = 1 ;

if ($cmdarg =~ /\?/)
{



No revision


No revision


1.1.2.9 +14 -4 embperl/Embperl/Attic/Tokens.pm

Index: Tokens.pm
===================================================================
RCS file: /home/cvs/embperl/Embperl/Attic/Tokens.pm,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- Tokens.pm 2000/05/15 06:33:03 1.1.2.8
+++ Tokens.pm 2000/05/16 12:44:25 1.1.2.9
@@ -191,33 +191,43 @@
'text' => '[$',
'end' => '$]',
'follow' => \%MetaCmds,
+ 'unescape' => 1,
},
'Embperl output code' => {
'text' => '[+',
'end' => '+]',
+ 'unescape' => 1,
'procinfo' => {
- embperl => { perlcode => 'XML::Embperl::DOM::Node_replaceChildWithCDATA (%$n%, do { %#0% }) ; ' }
+ embperl => { perlcode => 'XML::Embperl::DOM::Node_replaceChildWithCDATA (%$n%, scalar (do { %#0% })) ; ' }
},
},
'Embperl code' => {
'text' => '[-',
'end' => '-]',
+ 'unescape' => 1,
'procinfo' => {
- embperl => { perlcode => '%#0% ; XML::Embperl::DOM::Node_removeChild (%$n%) ; ' }
+ embperl => {
+ perlcode => '%#0%;',
+ removenode => 1,
+ },
},
},
'Embperl startup code' => {
'text' => '[!',
'end' => '!]',
+ 'unescape' => 1,
'procinfo' => {
- embperl => { perlcode => 'if (!$first++) { %#0% } ; XML::Embperl::DOM::Node_removeChild (%$n%) ; ' }
+ embperl => {
+ perlcode => 'if (!$first++) { %#0% } ;',
+ removenode => 1,
+ }
},
},
'Embperl comment' => {
'text' => '[#',
'end' => '#]',
'procinfo' => {
- embperl => { perlcode => 'XML::Embperl::DOM::Node_removeChild (%$n%) ; ' }
+ embperl => { removenode => 1, },
},
},
) ;