Fixes
authorfclaude <fclaude@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Sat, 21 Mar 2009 19:07:26 +0000 (19:07 +0000)
committerfclaude <fclaude@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Sat, 21 Mar 2009 19:07:26 +0000 (19:07 +0000)
git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/XMLTree@263 3cdefd35-fc62-479d-8e8d-bae585ffb9ca

XMLTree.cpp

index 2a1ca71..ae80fc2 100644 (file)
@@ -1041,12 +1041,12 @@ int XMLTree::CloseDocument()
 \r
     // If we found an attribute then "<@>" is present in the tree\r
     // if we didn't then it is not. "<$>" is never present in the tree\r
-               uint max_tag = 0;\r
-               for(uint i=0;i<(uint)npar-1;i++)\r
-                       max_tag = max(max_tag,tags_aux[i]);\r
-               max_tag++;\r
-               tags_aux = (TagType *) urealloc(tags_aux, sizeof(TagType)*(npar + 1));\r
-               tags_aux[npar++] = max_tag;\r
+               //uint max_tag = 0;\r
+               //for(uint i=0;i<(uint)npar-1;i++)\r
+               //      max_tag = max(max_tag,tags_aux[i]);\r
+               //max_tag++;\r
+               //tags_aux = (TagType *) urealloc(tags_aux, sizeof(TagType)*(npar + 1));\r
+               //tags_aux[npar++] = max_tag;\r
     //int ntagsize = found_attributes ? 2*ntagnames-1 : 2*ntagnames - 2;\r
     int ntagsize = 2*ntagnames + 2;\r
 \r
@@ -1253,7 +1253,7 @@ TagType XMLTree::GetTagId(unsigned char *tagname)
     // this should be changed for more efficient processing\r
     for (i=0; i<ntagnames; i++)\r
        if (strcmp((const char *)tagname,(const char *)TagName[i])==0) break; \r
-    if (i==ntagnames) return ntagnames; //(TagType)NULLT; // tagname does not exists in the table\r
+    if (i==ntagnames) return (TagType)-1; //ntagnames; //(TagType)NULLT; // tagname does not exists in the table\r
     else return i;\r
  }\r
 \r
@@ -1263,7 +1263,7 @@ TagType XMLTree::GetTagId(unsigned char *tagname)
 unsigned char *XMLTree::GetTagName(TagType tagid)\r
  {\r
     unsigned char *s;\r
-\r
+               if(tagid==(uint)-1) return NULL;\r
     if (tagid >= ntagnames) return NULL; // invalid tag identifier\r
     s = (unsigned char *)umalloc((strlen((const char *)TagName[tagid])+1)*sizeof(unsigned char));\r
     strcpy((char *)s, (const char *)TagName[tagid]);\r
@@ -1275,6 +1275,7 @@ unsigned char *XMLTree::GetTagName(TagType tagid)
 \r
 const unsigned char *XMLTree::GetTagNameByRef(TagType tagid)\r
  {\r
+               if(tagid==(uint)-1) return NULL;\r
     if (tagid >= ntagnames) return NULL; // invalid tag identifier\r
     return ((const unsigned char*)  TagName[tagid]);\r
  }\r