From d95172ba479aacb5fc702e0f81d72df3938badd8 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Mon, 30 Mar 2015 08:11:18 +0300 Subject: [PATCH] Print entire substring instead of each character --- tinyxml2.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index af8ba5f..ebf2865 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -2066,8 +2066,11 @@ void XMLPrinter::PrintString( const char* p, bool restricted ) // entity, and keep looking. if ( flag[(unsigned char)(*q)] ) { while ( p < q ) { - Print( "%c", *p ); - ++p; + const size_t delta = q - p; + // %.*s accepts type int as "precision" + const int toPrint = ( INT_MAX < delta ) ? INT_MAX : delta; + Print( "%.*s", toPrint, p ); + p += toPrint; } for( int i=0; i