diff --git a/expat/xmlwf/xmlwf.c b/expat/xmlwf/xmlwf.c
index 81f06063..1f35d2d4 100755
--- a/expat/xmlwf/xmlwf.c
+++ b/expat/xmlwf/xmlwf.c
@@ -241,6 +241,18 @@ void metaLocation(XML_Parser parser)
XML_GetCurrentColumnNumber(parser));
}
+static
+void metaStartDocument(XML_Parser parser)
+{
+ fputts(T("\n"), XML_GetUserData(parser));
+}
+
+static
+void metaEndDocument(XML_Parser parser)
+{
+ fputts(T("\n"), XML_GetUserData(parser));
+}
+
static
void metaStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
{
@@ -526,7 +538,6 @@ int tmain(int argc, XML_Char **argv)
switch (outputType) {
case 'm':
XML_UseParserAsHandlerArg(parser);
- fputts(T("\n"), fp);
XML_SetElementHandler(parser, metaStartElement, metaEndElement);
XML_SetProcessingInstructionHandler(parser, metaProcessingInstruction);
XML_SetCommentHandler(parser, metaComment);
@@ -534,6 +545,7 @@ int tmain(int argc, XML_Char **argv)
XML_SetCharacterDataHandler(parser, metaCharacterData);
XML_SetUnparsedEntityDeclHandler(parser, metaUnparsedEntityDecl);
XML_SetNotationDeclHandler(parser, metaNotationDecl);
+ metaStartDocument(parser);
break;
case 'c':
XML_UseParserAsHandlerArg(parser);
@@ -564,7 +576,7 @@ int tmain(int argc, XML_Char **argv)
result = XML_ProcessFile(parser, argv[i], processFlags);
if (outputDir) {
if (outputType == 'm')
- fputts(T("\n"), fp);
+ metaEndDocument(parser);
fclose(fp);
if (!result)
tremove(outName);