about summary refs log tree commit diff
path: root/stdio-common/tst-printf.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-09-24 20:54:13 +0000
committerUlrich Drepper <drepper@redhat.com>2000-09-24 20:54:13 +0000
commitb3f7c6654e6384333c7347c301b208b7a6ce9560 (patch)
tree8662f7b0e377f5df87a4f8583ea34ecc10c6706b /stdio-common/tst-printf.c
parentd2a99fa30393d4b5f1e5260ce8a28fa0648c6eb2 (diff)
downloadglibc-b3f7c6654e6384333c7347c301b208b7a6ce9560.tar.gz
glibc-b3f7c6654e6384333c7347c301b208b7a6ce9560.tar.xz
glibc-b3f7c6654e6384333c7347c301b208b7a6ce9560.zip
Update.
2000-09-24  Ulrich Drepper  <drepper@redhat.com>

	* stdio-common/vfprintf.c (process_arg): Handle %hhn.
	Add missing case in va_arg handling for numbers.
	* stdio-common/tst-printf.c (main): Add tests for %hhu and %hhn
	handling.  Reported by Joseph S. Myers <jsm28@cam.ac.uk>.
Diffstat (limited to 'stdio-common/tst-printf.c')
-rw-r--r--stdio-common/tst-printf.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/stdio-common/tst-printf.c b/stdio-common/tst-printf.c
index 5afa471fca..f0f0e55bc4 100644
--- a/stdio-common/tst-printf.c
+++ b/stdio-common/tst-printf.c
@@ -20,6 +20,7 @@
 #include </usr/include/stdio.h>
 #define EXIT_SUCCESS 0
 #else
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -262,10 +263,32 @@ I am ready for my first lesson today.";
     puts ("");
   }
 
+  printf ("printf (\"%%hhu\", %u) = %hhu\n", UCHAR_MAX + 2, UCHAR_MAX + 2);
+  printf ("printf (\"%%hu\", %u) = %hu\n", USHRT_MAX + 2, USHRT_MAX + 2);
+
   puts ("--- Should be no further output. ---");
   rfg1 ();
   rfg2 ();
 
+  {
+    char bytes[7];
+    char buf[20];
+
+    memset (bytes, '\xff', sizeof bytes);
+    sprintf (buf, "foo%hhn\n", &bytes[3]);
+    if (bytes[0] != '\xff' || bytes[1] != '\xff' || bytes[2] != '\xff'
+	|| bytes[4] != '\xff' || bytes[5] != '\xff' || bytes[6] != '\xff')
+      {
+	puts ("%hhn overwrite more bytes");
+	result = 1;
+      }
+    if (bytes[3] != 3)
+      {
+	puts ("%hhn wrote incorrect value");
+	result = 1;
+      }
+  }
+
   return result != 0;
 }