Fix %hhd formats in the printf family.
Found by adapting the simple unit tests for libc logging to test
snprintf too. Fix taken from upstream OpenBSD without updating
the rest of stdio.
Change-Id: Ie339a8e9393a36080147aae4d6665118e5d93647
diff --git a/libc/Android.mk b/libc/Android.mk
index a06032b..273b73e 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -492,7 +492,6 @@
libc_common_cflags := \
-DANDROID_CHANGES \
-D_LIBC=1 \
- -DFLOATING_POINT \
-DINET6 \
-I$(LOCAL_PATH)/private \
-DPOSIX_MISTAKE \
diff --git a/libc/stdio/local.h b/libc/stdio/local.h
index e3a40bc..a175d6f 100644
--- a/libc/stdio/local.h
+++ b/libc/stdio/local.h
@@ -93,3 +93,5 @@
#define FLOCKFILE(fp) do { if (__isthreaded) flockfile(fp); } while (0)
#define FUNLOCKFILE(fp) do { if (__isthreaded) funlockfile(fp); } while (0)
+
+#define FLOATING_POINT
diff --git a/libc/stdio/vfprintf.c b/libc/stdio/vfprintf.c
index 646b6b1..b101145 100644
--- a/libc/stdio/vfprintf.c
+++ b/libc/stdio/vfprintf.c
@@ -451,7 +451,12 @@
goto rflag;
#endif
case 'h':
- flags |= SHORTINT;
+ if (*fmt == 'h') {
+ fmt++;
+ flags |= CHARINT;
+ } else {
+ flags |= SHORTINT;
+ }
goto rflag;
case 'j':
flags |= MAXINT;