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
diff --git a/libc/stdio/vfprintf.cpp b/libc/stdio/vfprintf.cpp
index a14963e..8b247e9 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 @@
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 @@
} else if ((cp = GETARG(char*)) == nullptr) {
cp = const_cast<char*>("(null)");
}
+ string:
if (prec >= 0) {
size = CHAR_TYPE_STRNLEN(cp, prec);
} else {