X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=XMLTree.cpp;fp=XMLTree.cpp;h=06aaba0517bf1128628a685fcaa49dc2e9ff6c31;hb=b443dd155b926655d84a3eadef5be09907d6c5eb;hp=e23a06a12b2a23b209cc28e257f5b73ab537bf61;hpb=b2df171c52f1e6d35a8b131299e4a7f494520333;p=SXSI%2FXMLTree.git diff --git a/XMLTree.cpp b/XMLTree.cpp index e23a06a..06aaba0 100644 --- a/XMLTree.cpp +++ b/XMLTree.cpp @@ -941,6 +941,8 @@ bool XMLTree::IsOpen(treeNode x) { return fast_inspect(Par,x); } //WARNING this uses directly the underlying implementation for plain text + + void XMLTree::Print(int fd,treeNode x, bool no_text){ int newfd = dup(fd); @@ -973,9 +975,9 @@ void XMLTree::Print(int fd,treeNode x, bool no_text){ while (n <= fin){ if (fast_inspect(Par,n)){ if (tag == PCDATA_TAG_ID ) { - // fputs((const char*) (GetText(MyTextUnsafe(n))),fp); + // myfputs((const char*) (GetText(MyTextUnsafe(n))),fp); if (no_text) - fputs("<$/>",fp); + myfputs("<$/>",fp); else{ read = fprintf(fp,"%s",(const char*) current_text); current_text += (read + 1); @@ -986,40 +988,50 @@ void XMLTree::Print(int fd,treeNode x, bool no_text){ } else { - fputc('<',fp); + myfputc('<',fp); tagstr = (uchar*) GetTagNameByRef(tag); - fputs((const char*) tagstr ,fp); + myfputs((const char*) tagstr ,fp); n++; if (fast_inspect(Par,n)) { st.push(tagstr); tag = Tag(n); if (tag == ATTRIBUTE_TAG_ID){ n++; + if (no_text) myfputs("><@@>",fp); while (fast_inspect(Par,n)){ - fputc(' ',fp); - fputs((const char*) &(GetTagNameByRef(Tag(n))[3]),fp); - fputs("=\"",fp); - n++; - if (no_text) - fputs("<$@/>",fp); - else{ - read = fprintf(fp,"%s",(const char*) current_text); - current_text += (read + 1); - //fputs((const char*) GetText(MyTextUnsafe(n)),fp); - fputc('"',fp); + if (no_text) { + myfputc('<',fp); + myfputs((const char*) &(GetTagNameByRef(Tag(n))[3]),fp); + myfputc('>',fp); + myfputs("<$@/>',fp); + n+= 4; + } + else { + myfputc(' ',fp); + myfputs((const char*) &(GetTagNameByRef(Tag(n))[3]),fp); + n++; + myfputs("=\"",fp); + read = fprintf(fp,"%s",(const char*) current_text); + current_text += (read + 1); + //myfputs((const char*) GetText(MyTextUnsafe(n)),fp); + myfputc('"',fp); + n+=3; } - n+=3; //close @$ @@ }; - fputc('>',fp); + if (no_text) + myfputs("",fp); + else myfputc('>',fp); n++; tag=Tag(n); } else { - fputc('>',fp); + myfputc('>',fp); }; } else {// tag - fputs("/>",fp); + myfputs("/>",fp); n++; tag=Tag(n); }; @@ -1027,15 +1039,16 @@ void XMLTree::Print(int fd,treeNode x, bool no_text){ } else do { - fputs("', fp); + myfputs("', fp); st.pop(); n++; }while (!fast_inspect(Par,n) && !st.empty()); tag=Tag(n); }; - fputc('\n',fp); + myfputc('\n',fp); + mybufferflush(fp); fflush(fp); fclose(fp); }