commit e438c14aed0144e9b4089480278ad1630605a2b1
parent 869354f878ec5eea53d6448a2541f94caae1b72d
Author: Morel BĂ©renger <berengermorel76@gmail.com>
Date: Wed, 12 Aug 2020 21:09:51 +0200
fix inf.loop and not showing str starting with ctrl char
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/btl/src/utils.cpp b/btl/src/utils.cpp
@@ -29,7 +29,8 @@ int esc_fputs( const char *s, FILE *stream )
{
chunk_end = std::find_if( chunk_start, str_end, []( const char c ){ return c < 0x20 || c == '\\'; } );
assert( chunk_end - chunk_start >= 0 );
- if( !fwrite( chunk_start, static_cast<size_t>( chunk_end - chunk_start ), 1, stream ) )
+ sz = static_cast<size_t>( chunk_end - chunk_start );
+ if( sz != 0 && !fwrite( chunk_start, sz, 1, stream ) )
{
return INT_MAX;
}
@@ -51,6 +52,7 @@ int esc_fputs( const char *s, FILE *stream )
{
return INT_MAX;
}
+ ++chunk_end;
}
chunk_start = chunk_end;
} while( chunk_start != str_end );