more changes
authorfclaude <fclaude@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Sun, 8 Mar 2009 08:54:43 +0000 (08:54 +0000)
committerfclaude <fclaude@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Sun, 8 Mar 2009 08:54:43 +0000 (08:54 +0000)
git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/XMLTree@220 3cdefd35-fc62-479d-8e8d-bae585ffb9ca

XMLTree.cpp

index 6fee8f4..057a117 100644 (file)
@@ -862,18 +862,21 @@ 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
     int ntagsize = found_attributes ? 2*ntagnames-1 : 2*ntagnames - 2;\r
+               tags_aux = (TagType *) urealloc(tags_aux, sizeof(TagType)*(npar + 1));\r
+               tags_aux[npar++] = max_tag;\r
 \r
                static_bitsequence_builder * bmb = new static_bitsequence_builder_brw32(20);\r
                alphabet_mapper *am = new alphabet_mapper_none();\r
-               wt_coder * wc = new wt_coder_huff((uint*)tags_aux,npar-1,am);\r
-               Tags = new static_sequence_wvtree((uint*)tags_aux,npar-1,wc ,bmb, am);\r
+               wt_coder * wc = new wt_coder_huff((uint*)tags_aux,npar,am);\r
+               Tags = new static_sequence_wvtree((uint*)tags_aux,npar,wc ,bmb, am);\r
     //Tags = new static_sequence_gmr((uint *) tags_aux, (uint) npar-1,ntagsize, bmb, ssb);\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
                tags_blen = bits(max_tag);\r
-               tags_len = (uint)npar-1;\r
+               tags_len = (uint)npar;\r
                tags_fix = new uint[uint_len(tags_blen,tags_len)];\r
                for(uint i=0;i<(uint)npar-1;i++)\r
                        set_field(tags_fix,tags_blen,i,tags_aux[i]);\r
@@ -1061,7 +1064,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 (TagType)NULLT; // tagname does not exists in the table\r
+    if (i==ntagnames) return ntagnames; //(TagType)NULLT; // tagname does not exists in the table\r
     else return i;\r
  }\r
 \r