And this patch makes use of strnul() in the tests, where suitable.

2026-03-01  Bruno Haible  <[email protected]>

        tests: Use strnul.
        * tests/test-dfa-match-aux.c (main): Use strnul.
        * tests/test-pthread-rwlock-waitqueue.c (reader_func, writer_func):
        Likewise.
        * tests/test-strtold.h (test_function): Likewise.
        * tests/test-xstrtold.c (main): Likewise.
        * modules/dfa-tests (Depends-on): Add strnul.
        * modules/pthread-rwlock-extra-tests (Depends-on): Likewise.
        * modules/c-strtold-tests (Depends-on): Likewise.
        * modules/strtold-tests (Depends-on): Likewise.
        * modules/xstrtold-tests (Depends-on): Likewise.

diff --git a/tests/test-dfa-match-aux.c b/tests/test-dfa-match-aux.c
index 1331c0ab33..918ccba132 100644
--- a/tests/test-dfa-match-aux.c
+++ b/tests/test-dfa-match-aux.c
@@ -67,7 +67,7 @@ main (int argc, char **argv)
   dfacomp (argv[1], strlen (argv[1]), dfa, 0);
 
   beg = argv[2];
-  end = argv[2] + strlen (argv[2]);
+  end = strnul (argv[2]);
   allow_nl = argc > 3 && atoi (argv[3]);
 
   p = dfaexec (dfa, beg, end, allow_nl, NULL, NULL);
diff --git a/tests/test-pthread-rwlock-waitqueue.c 
b/tests/test-pthread-rwlock-waitqueue.c
index a81103cb02..f4163c7c55 100644
--- a/tests/test-pthread-rwlock-waitqueue.c
+++ b/tests/test-pthread-rwlock-waitqueue.c
@@ -111,7 +111,7 @@ reader_func (void *arg)
       abort ();
     }
   ASSERT (pthread_rwlock_wrlock (&sprintf_lock) == 0);
-  sprintf (l->result + strlen (l->result), " %s", l->name);
+  sprintf (strnul (l->result), " %s", l->name);
   ASSERT (pthread_rwlock_unlock (&sprintf_lock) == 0);
   if (l->wait_after > 0)
     {
@@ -150,7 +150,7 @@ writer_func (void *arg)
       abort ();
     }
   ASSERT (pthread_rwlock_wrlock (&sprintf_lock) == 0);
-  sprintf (l->result + strlen (l->result), " %s", l->name);
+  sprintf (strnul (l->result), " %s", l->name);
   ASSERT (pthread_rwlock_unlock (&sprintf_lock) == 0);
   if (l->wait_after > 0)
     {
diff --git a/tests/test-strtold.h b/tests/test-strtold.h
index 240a4f5760..5c8d88c8a4 100644
--- a/tests/test-strtold.h
+++ b/tests/test-strtold.h
@@ -525,7 +525,7 @@ test_function (long double (*my_strtold) (const char *, 
char **))
     errno = 0;
     result = my_strtold (input, &ptr);
     ASSERT (0.0L < result && result <= LDBL_MIN);
-    ASSERT (ptr == input + strlen (input));
+    ASSERT (ptr == strnul (input));
 #if !defined _MSC_VER
     ASSERT (errno == ERANGE);
 #endif
@@ -541,7 +541,7 @@ test_function (long double (*my_strtold) (const char *, 
char **))
     errno = 0;
     result = my_strtold (input, &ptr);
     ASSERT (-LDBL_MIN <= result && result < 0.0L);
-    ASSERT (ptr == input + strlen (input));
+    ASSERT (ptr == strnul (input));
 #if !defined _MSC_VER
     ASSERT (errno == ERANGE);
 #endif
diff --git a/tests/test-xstrtold.c b/tests/test-xstrtold.c
index 182171843d..77cf67e43a 100644
--- a/tests/test-xstrtold.c
+++ b/tests/test-xstrtold.c
@@ -664,7 +664,7 @@ main ()
     bool ok = xstrtold (input, &ptr, &result, strtold);
     ASSERT (ok);
     ASSERT (0.0L < result && result <= LDBL_MIN);
-    ASSERT (ptr == input + strlen (input));
+    ASSERT (ptr == strnul (input));
     ASSERT (errno == 0);
   }
   {
@@ -678,7 +678,7 @@ main ()
     bool ok = xstrtold (input, &ptr, &result, strtold);
     ASSERT (ok);
     ASSERT (-LDBL_MIN <= result && result < 0.0L);
-    ASSERT (ptr == input + strlen (input));
+    ASSERT (ptr == strnul (input));
     ASSERT (errno == 0);
   }
 
diff --git a/modules/c-strtold-tests b/modules/c-strtold-tests
index c8760b00f0..285fbf6a28 100644
--- a/modules/c-strtold-tests
+++ b/modules/c-strtold-tests
@@ -18,6 +18,7 @@ setlocale
 thread
 nanosleep
 strtold
+strnul
 
 configure.ac:
 gt_LOCALE_FR
diff --git a/modules/dfa-tests b/modules/dfa-tests
index 8ae462bda6..b28040c76b 100644
--- a/modules/dfa-tests
+++ b/modules/dfa-tests
@@ -13,6 +13,7 @@ unistd-h
 regex
 setlocale
 test-framework-sh
+strnul
 
 configure.ac:
 
diff --git a/modules/pthread-rwlock-extra-tests 
b/modules/pthread-rwlock-extra-tests
index 1fedd57f9e..c829a199af 100644
--- a/modules/pthread-rwlock-extra-tests
+++ b/modules/pthread-rwlock-extra-tests
@@ -10,6 +10,7 @@ extensions
 pthread-thread
 nanosleep
 bool
+strnul
 
 configure.ac:
 
diff --git a/modules/strtold-tests b/modules/strtold-tests
index 25bf5b7eaa..1105fb13f6 100644
--- a/modules/strtold-tests
+++ b/modules/strtold-tests
@@ -14,6 +14,7 @@ float-h
 isnanl-nolibm
 signbit-no-c++
 setlocale
+strnul
 
 configure.ac:
 gt_LOCALE_FR
diff --git a/modules/xstrtold-tests b/modules/xstrtold-tests
index a39d26f8e8..c961d4cb4a 100644
--- a/modules/xstrtold-tests
+++ b/modules/xstrtold-tests
@@ -8,6 +8,7 @@ strtold
 float-h
 isnanl-nolibm
 signbit-no-c++
+strnul
 
 configure.ac:
 




Reply via email to