X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=XMLTree.cpp;h=21658e99c323c4aaaff8b72e385d8580542bddf4;hb=d1f17224ed40165c284145ffbfcc1bd42882f825;hp=92360a432535065f46769245eadee9f98515c005;hpb=a9846746dc7a55764591fcc273fd48c6049df962;p=SXSI%2FXMLTree.git diff --git a/XMLTree.cpp b/XMLTree.cpp index 92360a4..21658e9 100644 --- a/XMLTree.cpp +++ b/XMLTree.cpp @@ -311,8 +311,10 @@ treeNode XMLTree::Parent(treeNode x) fprintf(stderr, "Error: data structure has not been constructed properly\n"); exit(1); } - - return parent(Par, x); + if (x == Root()) + return NULLT; + else + return parent(Par, x); } // Child(x,i): returns the i-th child of node x, assuming it exists. @@ -345,7 +347,9 @@ treeNode XMLTree::NextSibling(treeNode x) fprintf(stderr, "Error: data structure has not been constructed properly\n"); exit(1); } - + if (x == Root()) + return NULLT; + return next_sibling(Par, x); }