[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XTF v2 v2 2/4] lib: always append CR after LF in vsnprintf()
The explicit LFCR sequence guarantees proper line by line formatting in the output. The '\n' character alone on some terminals is not automatically converted to LFCR. Signed-off-by: Pawel Wieczorkiewicz <wipawel@xxxxxxxxx> --- Changed since v1: * Emit CRLF instead of LFCR common/libc/vsnprintf.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common/libc/vsnprintf.c b/common/libc/vsnprintf.c index a49fd30..b9a4fab 100644 --- a/common/libc/vsnprintf.c +++ b/common/libc/vsnprintf.c @@ -284,7 +284,17 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) /* Put regular characters into the destination. */ if ( *fmt != '%' ) { + /* + * The '\n' character alone on some terminals is not automatically + * converted to CRLF. + * The explicit CRLF sequence guarantees proper line by line + * formatting in the output. + */ + if ( *fmt == '\n' && str < end ) + PUT('\r'); + PUT(*fmt); + continue; } -- 2.16.6 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |