Don't flush the XML printing buffer if nothing was printed.
authorKim Nguyễn <kn@lri.fr>
Wed, 2 May 2012 12:24:36 +0000 (14:24 +0200)
committerKim Nguyễn <kn@lri.fr>
Wed, 2 May 2012 12:24:36 +0000 (14:24 +0200)
src/nodeSet.ml

index 944f85c..0828029 100644 (file)
@@ -200,8 +200,10 @@ module Mat : S with type t = Tree.node mat =
          Unix.close
       in
       ignore (Unix.write fd "<xml_result>\n" 0 13);
-      iter (fun node -> Tree.print_xml v node fd) l;
-      Tree.flush v fd;
+      if l.length > 0 then begin
+       iter (fun node -> Tree.print_xml v node fd) l;
+       Tree.flush v fd;
+      end;
       ignore (Unix.write fd "</xml_result>\n" 0 14);
       finish fd