From af9ea5df04bde4af537dea7768abcf62b2f484fb Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Thu, 16 Jan 2014 21:07:29 +0100 Subject: [PATCH] Add %m support to vprintf_callback(3). --- libc/stdio/vprintf_callback.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libc/stdio/vprintf_callback.cpp b/libc/stdio/vprintf_callback.cpp index 21c37870..255190c2 100644 --- a/libc/stdio/vprintf_callback.cpp +++ b/libc/stdio/vprintf_callback.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014. This file is part of the Sortix C Library. @@ -393,10 +393,14 @@ size_t vprintf_callback(size_t (*callback)(void*, const char*, size_t), else written++; } - else if ( *format == 's' && (format++, true) ) + else if ( *format == 'm' || *format == 's' ) { + char conversion = *format++; + const char* string; - if ( length == LENGTH_DEFAULT ) + if ( conversion == 'm' ) + string = strerror(errno), conversion = 's'; + else if ( length == LENGTH_DEFAULT ) string = va_arg(parameters, const char*); else if ( length == LENGTH_LONG ) {