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  <[email protected]>
+
+       * tests/test-vasprintf.c: Test %08lx.
+
 2010-04-20  Eric Blake  <[email protected]>
 
        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