richter 00/12/21 21:48:57
Modified: . Tag: Embperl2c epdom.c
Log:
Embperl 2 - fixed a bug within the second request and the hidden metacommand
Revision Changes Path
No revision
No revision
1.4.2.23 +158 -139 embperl/Attic/epdom.c
Index: epdom.c
===================================================================
RCS file: /home/cvs/embperl/Attic/epdom.c,v
retrieving revision 1.4.2.22
retrieving revision 1.4.2.23
diff -u -r1.4.2.22 -r1.4.2.23
--- epdom.c 2000/12/20 07:32:36 1.4.2.22
+++ epdom.c 2000/12/22 05:48:56 1.4.2.23
@@ -1088,7 +1088,146 @@
*/
+/* ------------------------------------------------------------------------ */
+/* */
+/* Node_cloneNode */
+/* */
+/* clone a node */
+/* bDeep = 1 clone childs also */
+/* bDeep = 0 clone no childs */
+/* bDeep = -1 clone no attributes and no childs */
+/* */
+/* ------------------------------------------------------------------------ */
+
+
+tNodeData * Node_selfCloneNode (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNodeData * pNode,
+ /*in*/ int bDeep)
+
+ {
+ int len = sizeof (tNodeData) + (bDeep == -1?0:pNode -> numAttr *
sizeof (tAttrData)) ;
+ tNode xNewNode ;
+ tNodeData * pNew ;
+
+ if ((pNew = dom_malloc (len)) == NULL)
+ return NULL ;
+
+ numNodes++ ;
+
+ memcpy (pNew, pNode, len) ;
+ xNewNode = ArrayAdd (&pDomTree -> pLookup, 1) ;
+ pDomTree -> pLookup[xNewNode] = pNew ;
+ pNew -> xNdx = xNewNode ;
+ pNew -> bFlags &= ~nflgModified ;
+ pNew -> xDomTree = pDomTree -> xNdx ;
+
+ if (pNew -> nText)
+ NdxStringRefcntInc (pNew -> nText) ;
+
+ if (bDeep == -1)
+ pNew -> numAttr = 0 ;
+ else
+ {
+ tAttrData * pAttr = (tAttrData * )(pNew + 1) ;
+ int n = pNew -> numAttr ;
+
+ while (n)
+ {
+ xNewNode = ArrayAdd (&pDomTree -> pLookup, 1) ;
+ pDomTree -> pLookup[xNewNode] = pAttr ;
+ pAttr -> xNdx = xNewNode ;
+ if (pAttr -> xName)
+ NdxStringRefcntInc (pAttr -> xName) ;
+ if (pAttr -> xValue && (pAttr -> bFlags & aflgAttrValue))
+ NdxStringRefcntInc (pAttr -> xValue) ;
+ n-- ;
+ pAttr++ ;
+ }
+ }
+ if (bDeep < 1)
+ pNew -> xChilds = 0 ;
+
+ return pNew ;
+ }
+
+
+
+
+tNode Node_cloneNode (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNode xNode,
+ /*in*/ int bDeep)
+
+ {
+ tNodeData * pNew = Node_selfCloneNode (pDomTree, Node_self (pDomTree, xNode),
bDeep) ;
+
+ if (pNew)
+ return pNew -> xNdx ;
+
+ return 0 ;
+ }
+
+/* ------------------------------------------------------------------------ */
+/* */
+/* Node_selfCondCloneNode */
+/* */
+/* clone a node if it's part of a different DomTree in preparation for */
+/* a change */
+/* */
+/* ------------------------------------------------------------------------ */
+
+
+tNodeData * Node_selfCondCloneNode (/*in*/ tDomTree * pDomTree,
+ /*in*/ tNodeData * pNode)
+
+ {
+ int len ;
+ tNodeData * pNew ;
+ tAttrData * pAttr ;
+ int n ;
+ void * * pLookup ;
+ tNode xNdx ;
+
+ if (pNode -> xDomTree == pDomTree -> xNdx)
+ return pNode ;
+
+ pLookup = pDomTree -> pLookup ;
+ len = sizeof (tNodeData) + pNode -> numAttr * sizeof (tAttrData) ;
+ xNdx = pNode -> xNdx ;
+
+ if ((pLookup[xNdx] = pNew = dom_malloc (len)) == NULL)
+ return NULL ;
+ numNodes++ ;
+
+ memcpy (pNew, pNode, len) ;
+
+ pNew -> bFlags &= ~nflgModified ;
+ pNew -> xDomTree = pDomTree -> xNdx ;
+
+ if (pNew -> nText)
+ NdxStringRefcntInc (pNew -> nText) ;
+
+ pAttr = (tAttrData * )(pNew + 1) ;
+ n = pNew -> numAttr ;
+
+ while (n)
+ {
+ pLookup[pAttr -> xNdx] = pAttr ;
+ if (pAttr -> xName)
+ NdxStringRefcntInc (pAttr -> xName) ;
+ if (pAttr -> xValue && (pAttr -> bFlags & aflgAttrValue))
+ NdxStringRefcntInc (pAttr -> xValue) ;
+ n-- ;
+ pAttr++ ;
+ }
+
+ return pNew ;
+ }
+
+
+
+
+
/* ------------------------------------------------------------------------ */
/* */
/* Node_newAndAppend */
@@ -1221,6 +1360,25 @@
tIndex xText ;
pParent = Node_self (pDomTree, xParent) ;
+
+ /* --- clone node if it doesn't live in the current DomTree -- */
+ if (pParent)
+ {
+ if (pParent -> nType == ntypAttr)
+ {
+ tNodeData * pNode = Attr_selfNode (((tAttrData *)pParent)) ;
+
+ if (pNode -> xDomTree != pDomTree -> xNdx)
+ pNode = Node_selfCondCloneNode (pDomTree, pNode) ;
+
+ pParent = Node_self (pDomTree, xParent) ;
+ }
+ else
+ {
+ if (pParent -> xDomTree != pDomTree -> xNdx)
+ pParent = Node_selfCondCloneNode (pDomTree, pParent) ;
+ }
+ }
if (nType == ntypAttr)
{ /* add new attribute to node */
@@ -1425,145 +1583,6 @@
Node_selfRemoveChild (pDomTree, xParent, Node_self (pDomTree, xChild)) ;
return 0 ;
}
-
-
-/* ------------------------------------------------------------------------ */
-/* */
-/* Node_cloneNode */
-/* */
-/* clone a node */
-/* bDeep = 1 clone childs also */
-/* bDeep = 0 clone no childs */
-/* bDeep = -1 clone no attributes and no childs */
-/* */
-/* ------------------------------------------------------------------------ */
-
-
-tNodeData * Node_selfCloneNode (/*in*/ tDomTree * pDomTree,
- /*in*/ tNodeData * pNode,
- /*in*/ int bDeep)
-
- {
- int len = sizeof (tNodeData) + (bDeep == -1?0:pNode -> numAttr *
sizeof (tAttrData)) ;
- tNode xNewNode ;
- tNodeData * pNew ;
-
- if ((pNew = dom_malloc (len)) == NULL)
- return NULL ;
-
- numNodes++ ;
-
- memcpy (pNew, pNode, len) ;
- xNewNode = ArrayAdd (&pDomTree -> pLookup, 1) ;
- pDomTree -> pLookup[xNewNode] = pNew ;
- pNew -> xNdx = xNewNode ;
- pNew -> bFlags &= ~nflgModified ;
- pNew -> xDomTree = pDomTree -> xNdx ;
-
- if (pNew -> nText)
- NdxStringRefcntInc (pNew -> nText) ;
-
- if (bDeep == -1)
- pNew -> numAttr = 0 ;
- else
- {
- tAttrData * pAttr = (tAttrData * )(pNew + 1) ;
- int n = pNew -> numAttr ;
-
- while (n)
- {
- xNewNode = ArrayAdd (&pDomTree -> pLookup, 1) ;
- pDomTree -> pLookup[xNewNode] = pAttr ;
- pAttr -> xNdx = xNewNode ;
- if (pAttr -> xName)
- NdxStringRefcntInc (pAttr -> xName) ;
- if (pAttr -> xValue && (pAttr -> bFlags & aflgAttrValue))
- NdxStringRefcntInc (pAttr -> xValue) ;
- n-- ;
- pAttr++ ;
- }
- }
- if (bDeep < 1)
- pNew -> xChilds = 0 ;
-
- return pNew ;
- }
-
-
-
-
-tNode Node_cloneNode (/*in*/ tDomTree * pDomTree,
- /*in*/ tNode xNode,
- /*in*/ int bDeep)
-
- {
- tNodeData * pNew = Node_selfCloneNode (pDomTree, Node_self (pDomTree, xNode),
bDeep) ;
-
- if (pNew)
- return pNew -> xNdx ;
-
- return 0 ;
- }
-
-/* ------------------------------------------------------------------------ */
-/* */
-/* Node_selfCondCloneNode */
-/* */
-/* clone a node if it's part of a different DomTree in preparation for */
-/* a change */
-/* */
-/* ------------------------------------------------------------------------ */
-
-
-tNodeData * Node_selfCondCloneNode (/*in*/ tDomTree * pDomTree,
- /*in*/ tNodeData * pNode)
-
- {
- int len ;
- tNodeData * pNew ;
- tAttrData * pAttr ;
- int n ;
- void * * pLookup ;
- tNode xNdx ;
-
- if (pNode -> xDomTree == pDomTree -> xNdx)
- return pNode ;
-
- pLookup = pDomTree -> pLookup ;
- len = sizeof (tNodeData) + pNode -> numAttr * sizeof (tAttrData) ;
- xNdx = pNode -> xNdx ;
-
- if ((pLookup[xNdx] = pNew = dom_malloc (len)) == NULL)
- return NULL ;
-
- numNodes++ ;
-
- memcpy (pNew, pNode, len) ;
-
- pNew -> bFlags &= ~nflgModified ;
- pNew -> xDomTree = pDomTree -> xNdx ;
-
- if (pNew -> nText)
- NdxStringRefcntInc (pNew -> nText) ;
-
- pAttr = (tAttrData * )(pNew + 1) ;
- n = pNew -> numAttr ;
-
- while (n)
- {
- pLookup[pAttr -> xNdx] = pAttr ;
- if (pAttr -> xName)
- NdxStringRefcntInc (pAttr -> xName) ;
- if (pAttr -> xValue && (pAttr -> bFlags & aflgAttrValue))
- NdxStringRefcntInc (pAttr -> xValue) ;
- n-- ;
- pAttr++ ;
- }
-
- return pNew ;
- }
-
-
/* ------------------------------------------------------------------------ */
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]