X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=XMLTree.cpp;fp=XMLTree.cpp;h=9be500ee993f4af9a0565a2513c64d23bf902531;hb=b9205dab05e219c2ac3ce7cf5fe0107267d60535;hp=06aaba0517bf1128628a685fcaa49dc2e9ff6c31;hpb=5b9867b52a3886096fff41d35f6aea3b18936fb7;p=SXSI%2FXMLTree.git diff --git a/XMLTree.cpp b/XMLTree.cpp index 06aaba0..9be500e 100644 --- a/XMLTree.cpp +++ b/XMLTree.cpp @@ -107,6 +107,7 @@ XMLTree::XMLTree( pb * const par, uint npar, vector * const TN, TagIdM uint *empty_texts_bmp, TagType *tags, TextCollection * const TC, bool dis_tc) { + buffer = 0; // creates the data structure for the tree topology Par = (bp *)umalloc(sizeof(bp)); STARTTIMER(); @@ -248,6 +249,7 @@ void XMLTree::Save(int fd) // a pointer to the loaded data structure XMLTree *XMLTree::Load(int fd, bool load_tc,int sample_factor) { + FILE *fp; char buffer[1024]; XMLTree *XML_Tree; @@ -947,7 +949,8 @@ void XMLTree::Print(int fd,treeNode x, bool no_text){ int newfd = dup(fd); stream = fdopen(newfd,"wa"); - + if (buffer == 0) + buffer = new string(); FILE* fp = stream; treeNode fin = fast_find_close(Par,x); @@ -970,8 +973,7 @@ void XMLTree::Print(int fd,treeNode x, bool no_text){ if (first_idx != NULLT) current_text = GetText(MyText(first_idx)); int read = 0; - - std::stack st; + std::vector st; while (n <= fin){ if (fast_inspect(Par,n)){ if (tag == PCDATA_TAG_ID ) { @@ -987,13 +989,12 @@ void XMLTree::Print(int fd,treeNode x, bool no_text){ } else { - myfputc('<',fp); tagstr = (uchar*) GetTagNameByRef(tag); myfputs((const char*) tagstr ,fp); n++; if (fast_inspect(Par,n)) { - st.push(tagstr); + st.push_back(tagstr); tag = Tag(n); if (tag == ATTRIBUTE_TAG_ID){ n++; @@ -1001,10 +1002,11 @@ void XMLTree::Print(int fd,treeNode x, bool no_text){ while (fast_inspect(Par,n)){ if (no_text) { myfputc('<',fp); - myfputs((const char*) &(GetTagNameByRef(Tag(n))[3]),fp); + const uchar * tmp = &(GetTagNameByRef(Tag(n))[3]); + myfputs((const char*) tmp,fp); myfputc('>',fp); myfputs("<$@/>',fp); n+= 4; } @@ -1040,14 +1042,14 @@ void XMLTree::Print(int fd,treeNode x, bool no_text){ else do { myfputs("', fp); - st.pop(); + st.pop_back(); n++; }while (!fast_inspect(Par,n) && !st.empty()); tag=Tag(n); }; - myfputc('\n',fp); + //myfputc('\n',fp); mybufferflush(fp); fflush(fp); fclose(fp);