diff options
author | Elliott Hughes <enh@google.com> | 2018-08-30 16:00:42 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2018-08-30 16:00:42 -0700 |
commit | 654cd8331b3dafb2027a3062104c6e9934af1935 (patch) | |
tree | 82562a68054fbcbe65259cd594290278ca94f8fc /libc/stdio/vfprintf.cpp | |
parent | 003521af4760215c9c3b8ba80c88dd3b3c87ab67 (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/vfprintf.cpp')
-rw-r--r-- | libc/stdio/vfprintf.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libc/stdio/vfprintf.cpp b/libc/stdio/vfprintf.cpp index a14963eb5..8b247e961 100644 --- a/libc/stdio/vfprintf.cpp +++ b/libc/stdio/vfprintf.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) */ @@ -451,6 +452,9 @@ int FUNCTION_NAME(FILE* fp, const CHAR_TYPE* fmt0, va_list ap) { break; case 'n': __fortify_fatal("%%n not allowed on Android"); + case 'm': + cp = strerror(caller_errno); + goto string; case 'O': flags |= LONGINT; __BIONIC_FALLTHROUGH; @@ -493,6 +497,7 @@ int FUNCTION_NAME(FILE* fp, const CHAR_TYPE* fmt0, va_list ap) { } else if ((cp = GETARG(char*)) == nullptr) { cp = const_cast<char*>("(null)"); } + string: if (prec >= 0) { size = CHAR_TYPE_STRNLEN(cp, prec); } else { |