make_pair("#things", new Clone { }),
};
- process_file("../xml/clone.xml", argv[1], &master_directive);
+ xmlDocPtr doc = process_file("../xml/clone.xml", &master_directive);
+ output_to_fd_and_free(doc, 1);
return(0);
}
}),
};
- process_file("../xml/clone.xml", argv[1], &master_directive);
+ xmlDocPtr doc = process_file("../xml/clone.xml", &master_directive);
+ output_to_fd_and_free(doc, 1);
return(0);
}
}, { "odd", "even" } }),
};
- process_file("../xml/clone.xml", argv[1], &master_directive);
+ xmlDocPtr doc = process_file("../xml/clone.xml", &master_directive);
+ output_to_fd_and_free(doc, 1);
return(0);
}
}, { "odd", "even" } }),
};
- process_file("../xml/clone.xml", argv[1], &master_directive);
+ xmlDocPtr doc = process_file("../xml/clone.xml", &master_directive);
+ output_to_fd_and_free(doc, 1);
return(0);
}
}),
};
- process_file("../xml/clone.xml", argv[1], &master_directive);
+ xmlDocPtr doc = process_file("../xml/clone.xml", &master_directive);
+ output_to_fd_and_free(doc, 1);
return(0);
}
make_pair("#moretest", new Replace("bar")),
};
- process_file("../xml/namespace.xml", argv[1], &master_directive);
+ xmlDocPtr doc = process_file("../xml/namespace.xml", &master_directive);
+ output_to_fd_and_free(doc, 1);
return(0);
}
make_pair("#hello", new Replace("Replaced.")),
};
- process_file("../xml/namespace2.xml", argv[1], &master_directive);
+ xmlDocPtr doc = process_file("../xml/namespace2.xml", &master_directive);
+ output_to_fd_and_free(doc, 1);
return(0);
}
int main(int argc, char **argv)
{
Substitute master_directive = {};
- process_file("../xml/passthru.xml", argv[1], &master_directive);
+ xmlDocPtr doc = process_file("../xml/passthru.xml", &master_directive);
+ output_to_fd_and_free(doc, 1);
return(0);
}
make_pair("#hello", new Replace("Hello world!")),
};
- process_file("../xml/simple.xml", argv[1], &master_directive);
+ xmlDocPtr doc = process_file("../xml/simple.xml", &master_directive);
+ output_to_fd_and_free(doc, 1);
return(0);
}
}),
};
- process_file("../xml/structure.xml", argv[1], &master_directive);
+ xmlDocPtr doc = process_file("../xml/structure.xml", &master_directive);
+ output_to_fd_and_free(doc, 1);
return(0);
}
}
}
-void process_file(const string &input_filename,
- const string &output_filename,
- Directive *root_directive)
+xmlDocPtr process_file(const string &input_filename,
+ Directive *root_directive)
{
LIBXML_TEST_VERSION
xmlDocPtr doc = xmlParseFile(input_filename.c_str());
root_directive->process(xmlDocGetRootElement(doc), true);
- xmlSaveFile(output_filename.c_str(), doc);
- xmlFreeDoc(doc);
-
xmlCleanupParser();
xmlMemoryDump();
+ return doc;
+}
+
+void output_to_fd_and_free(xmlDocPtr doc, int fd)
+{
+ xmlOutputBufferPtr buf = xmlOutputBufferCreateFd(fd, NULL);
+ xmlSaveFileTo(buf, doc, NULL);
+ xmlFreeDoc(doc);
}
const std::vector<std::string> &alternatives);
};
-void process_file(const std::string &input_filename,
- const std::string &output_filename,
- Directive *root_directive);
+xmlDocPtr process_file(const std::string &input_filename,
+ Directive *root_directive);
+
+void output_to_fd_and_free(xmlDocPtr doc, int fd);
#endif // !defined(_XML_TEMPLATE_H)
ruby -I../ruby ../ruby/$T.rb > $TEMPFILE
fi
if [ "$L" = "c++0x" ]; then
- ( cd ../c++0x && make -s $T ) && ../c++0x/$T $TEMPFILE
+ ( cd ../c++0x && make -s $T ) && ../c++0x/$T > $TEMPFILE
fi
perl ./xml-diff.pl $TEMPFILE reference/$T.xml