From 6cda2e02c865fdbe7e96cbcca41d4484fc15d1a4 Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Wed, 23 Mar 2016 19:42:03 +0100 Subject: [PATCH] Issue #383 - correct another byte-by-byte output to message file. As in the previous case these messages are already valid utf-8 text, and thus, if output on a byte-by-byte basis, must not use WriteChar, except for the EOL char. Of course this output can be to either a user ouput file, if configured, otherwise stderr. --- src/message.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/message.c b/src/message.c index 6de12bc..8252c2d 100755 --- a/src/message.c +++ b/src/message.c @@ -368,23 +368,26 @@ void tidy_out( TidyDocImpl* doc, ctmbstr msg, ... ) { if ( !cfgBool(doc, TidyQuiet) ) { + TidyOutputSink *outp = &doc->errout->sink; ctmbstr cp; enum { sizeBuf=2048 }; char *buf = (char *)TidyDocAlloc(doc,sizeBuf); + byte b; va_list args; va_start( args, msg ); TY_(tmbvsnprintf)(buf, sizeBuf, msg, args); va_end( args ); -#if !defined(NDEBUG) && defined(_MSC_VER) - add_std_out(0); -#endif for ( cp=buf; *cp; ++cp ) - TY_(WriteChar)( *cp, doc->errout ); -#if !defined(NDEBUG) && defined(_MSC_VER) - add_std_out(1); -#endif + { + b = (*cp & 0xff); + if (b == (byte)'\n') + TY_(WriteChar)( b, doc->errout ); /* for EOL translation */ + else + outp->putByte( outp->sinkData, b ); /* #383 - no encoding */ + } + TidyDocFree(doc, buf); } }