summaryrefslogtreecommitdiff
path: root/libc/stdio/vfwprintf.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2018-08-30 16:00:42 -0700
committerElliott Hughes <enh@google.com>2018-08-30 16:00:42 -0700
commit654cd8331b3dafb2027a3062104c6e9934af1935 (patch)
tree82562a68054fbcbe65259cd594290278ca94f8fc /libc/stdio/vfwprintf.cpp
parent003521af4760215c9c3b8ba80c88dd3b3c87ab67 (diff)
Add the %m GNU extension to printf/wprintf.
And remove the local hack from syslog(3). Bug: http://b/112776560 Test: ran tests Change-Id: I5807e729a978df26187ea0ee255bba4ca74220c8
Diffstat (limited to 'libc/stdio/vfwprintf.cpp')
-rw-r--r--libc/stdio/vfwprintf.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/libc/stdio/vfwprintf.cpp b/libc/stdio/vfwprintf.cpp
index 1c3b80d99..19cce17e6 100644
--- a/libc/stdio/vfwprintf.cpp
+++ b/libc/stdio/vfwprintf.cpp
@@ -43,6 +43,7 @@
#include "printf_common.h"
int FUNCTION_NAME(FILE* fp, const CHAR_TYPE* fmt0, va_list ap) {
+ int caller_errno = errno;
int n, n2;
CHAR_TYPE* cp; /* handy char pointer (short term usage) */
CHAR_TYPE sign; /* sign prefix (' ', '+', '-', or \0) */
@@ -436,6 +437,16 @@ int FUNCTION_NAME(FILE* fp, const CHAR_TYPE* fmt0, va_list ap) {
break;
case 'n':
__fortify_fatal("%%n not allowed on Android");
+ case 'm':
+ free(convbuf);
+ convbuf = helpers::mbsconv(strerror(caller_errno), prec);
+ if (convbuf == nullptr) {
+ fp->_flags |= __SERR;
+ goto error;
+ } else {
+ cp = convbuf;
+ }
+ goto string;
case 'O':
flags |= LONGINT;
__BIONIC_FALLTHROUGH;
@@ -474,6 +485,7 @@ int FUNCTION_NAME(FILE* fp, const CHAR_TYPE* fmt0, va_list ap) {
cp = convbuf;
}
}
+ string:
if (prec >= 0) {
size = CHAR_TYPE_STRNLEN(cp, prec);
} else {