bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tests/test-vasprintf.c: Test %08lx.


From: Simon Josefsson
Subject: [PATCH] tests/test-vasprintf.c: Test %08lx.
Date: Wed, 21 Apr 2010 13:21:52 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux)

I've pushed the patch below since it demonstrates a bug in gnulib's
printf code under Windows.

gnulib-tool --create-testdir --avoid string-c++-tests --dir m --with-tests 
vasprintf
cd m
./configure --host=i586-mingw32msvc --build=i686-pc-linux-gnu
make check

For some reason 'asprintf (&tmp, "%08lx", 1)' yields '61fdec00003039'.
I haven't started debugging the printf code yet, but will get to it...

/Simon

---
 ChangeLog              |    4 ++++
 tests/test-vasprintf.c |   20 ++++++++++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ddc0d09..64948d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-04-21  Simon Josefsson  <address@hidden>
+
+       * tests/test-vasprintf.c: Test %08lx.
+
 2010-04-20  Eric Blake  <address@hidden>
 
        tests: be robust to ignored SIGPIPE
diff --git a/tests/test-vasprintf.c b/tests/test-vasprintf.c
index e5dc3cd..e5676f4 100644
--- a/tests/test-vasprintf.c
+++ b/tests/test-vasprintf.c
@@ -56,6 +56,16 @@ test_vasprintf ()
       ASSERT (strcmp (result, "12345") == 0);
       free (result);
     }
+
+  for (repeat = 0; repeat <= 8; repeat++)
+    {
+      char *result;
+      int retval = my_asprintf (&result, "%08lx", 12345);
+      ASSERT (retval == 8);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "00003039") == 0);
+      free (result);
+    }
 }
 
 static void
@@ -72,6 +82,16 @@ test_asprintf ()
       ASSERT (strcmp (result, "12345") == 0);
       free (result);
     }
+
+  for (repeat = 0; repeat <= 8; repeat++)
+    {
+      char *result;
+      int retval = asprintf (&result, "%08lx", 12345);
+      ASSERT (retval == 8);
+      ASSERT (result != NULL);
+      ASSERT (strcmp (result, "00003039") == 0);
+      free (result);
+    }
 }
 
 int
-- 
1.7.0.4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]