> 2024-02-21  Bruno Haible  <br...@clisp.org>
> 
>       *printf-posix: Disable support for the 'n' directive by default.

This produces 24 test failures in libunistring. Fixed as follows:


2024-02-23  Bruno Haible  <br...@clisp.org>

        unistdio/*printf tests: Update expected test results regarding %n.
        * tests/unistdio/test-u8-printf1.h (test_xfunction): If
        NEED_PRINTF_WITH_N_DIRECTIVE is not defined, expect a NULL result in the
        %n test.
        * tests/unistdio/test-u16-printf1.h (test_xfunction): Likewise.
        * tests/unistdio/test-u32-printf1.h (test_xfunction): Likewise.
        * tests/unistdio/test-ulc-printf1.h (test_xfunction): Likewise.

diff --git a/tests/unistdio/test-u16-printf1.h 
b/tests/unistdio/test-u16-printf1.h
index 72655e7202..e501c9e462 100644
--- a/tests/unistdio/test-u16-printf1.h
+++ b/tests/unistdio/test-u16-printf1.h
@@ -1032,12 +1032,16 @@ test_xfunction (uint16_t * (*my_xasprintf) (const char 
*, ...))
     int count = -1;
     uint16_t *result =
       my_xasprintf ("%d %n", 123, &count, 33, 44, 55);
+#if NEED_PRINTF_WITH_N_DIRECTIVE
     static const uint16_t expected[] =
       { '1', '2', '3', ' ', 0 };
     ASSERT (result != NULL);
     ASSERT (u16_strcmp (result, expected) == 0);
     ASSERT (count == 4);
     free (result);
+#else
+    ASSERT (result == NULL);
+#endif
   }
 
   /* Test the support of the POSIX/XSI format strings with positions.  */
diff --git a/tests/unistdio/test-u32-printf1.h 
b/tests/unistdio/test-u32-printf1.h
index 0cebba2819..ae0edc6a63 100644
--- a/tests/unistdio/test-u32-printf1.h
+++ b/tests/unistdio/test-u32-printf1.h
@@ -1032,12 +1032,16 @@ test_xfunction (uint32_t * (*my_xasprintf) (const char 
*, ...))
     int count = -1;
     uint32_t *result =
       my_xasprintf ("%d %n", 123, &count, 33, 44, 55);
+#if NEED_PRINTF_WITH_N_DIRECTIVE
     static const uint32_t expected[] =
       { '1', '2', '3', ' ', 0 };
     ASSERT (result != NULL);
     ASSERT (u32_strcmp (result, expected) == 0);
     ASSERT (count == 4);
     free (result);
+#else
+    ASSERT (result == NULL);
+#endif
   }
 
   /* Test the support of the POSIX/XSI format strings with positions.  */
diff --git a/tests/unistdio/test-u8-printf1.h b/tests/unistdio/test-u8-printf1.h
index 2b762737f1..3e8999b638 100644
--- a/tests/unistdio/test-u8-printf1.h
+++ b/tests/unistdio/test-u8-printf1.h
@@ -786,11 +786,15 @@ test_xfunction (uint8_t * (*my_xasprintf) (const char *, 
...))
     int count = -1;
     uint8_t *result =
       my_xasprintf ("%d %n", 123, &count, 33, 44, 55);
+#if NEED_PRINTF_WITH_N_DIRECTIVE
     static const uint8_t expected[] = "123 ";
     ASSERT (result != NULL);
     ASSERT (u8_strcmp (result, expected) == 0);
     ASSERT (count == 4);
     free (result);
+#else
+    ASSERT (result == NULL);
+#endif
   }
 
   /* Test the support of the POSIX/XSI format strings with positions.  */
diff --git a/tests/unistdio/test-ulc-printf1.h 
b/tests/unistdio/test-ulc-printf1.h
index 7617185a08..49089c1bfd 100644
--- a/tests/unistdio/test-ulc-printf1.h
+++ b/tests/unistdio/test-ulc-printf1.h
@@ -670,10 +670,14 @@ test_xfunction (char * (*my_xasprintf) (const char *, 
...))
     int count = -1;
     char *result =
       my_xasprintf ("%d %n", 123, &count, 33, 44, 55);
+#if NEED_PRINTF_WITH_N_DIRECTIVE
     ASSERT (result != NULL);
     ASSERT (strcmp (result, "123 ") == 0);
     ASSERT (count == 4);
     free (result);
+#else
+    ASSERT (result == NULL);
+#endif
   }
 
   /* Test the support of the POSIX/XSI format strings with positions.  */




Reply via email to