[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] lib/xstrtol.c: Fix xstrtol() on EINVAL (invalid base)
From: |
Bruno Haible |
Subject: |
Re: [PATCH] lib/xstrtol.c: Fix xstrtol() on EINVAL (invalid base) |
Date: |
Mon, 05 Aug 2024 21:35:13 +0200 |
> 2024-07-29 Bruno Haible <bruno@clisp.org>
>
> xstrtol, xstrtoll tests: Avoid test failure after 2024-07-25 change.
> * tests/test-xstrtol.c (main): Update expected test results.
I had tested this in a small testdir. But in a testdir of all of gnulib,
it still fails on musl libc, macOS, NetBSD, OpenBSD, Solaris 11, mingw.
The cause is that the gnulib strtol replacement works like the glibc
implementation.
Fixed as follows:
2024-08-05 Bruno Haible <bruno@clisp.org>
xstrtol, xstrtoll tests: Fix test failures.
* tests/test-xstrtol.c (is_GNULIB_strtol): New macro.
(main): Use it in the expected test results.
* tests/test-xstrtoll.c (is_GNULIB_strtol): New macro.
diff --git a/tests/test-xstrtol.c b/tests/test-xstrtol.c
index cbb394912e..31eff39318 100644
--- a/tests/test-xstrtol.c
+++ b/tests/test-xstrtol.c
@@ -28,6 +28,7 @@
# define __xstrtol xstrtol
# define __strtol_t long int
# define __spec "ld"
+# define is_GNULIB_strtol GNULIB_defined_strtol_function
#endif
/* Don't show the program name in error messages. */
@@ -75,7 +76,7 @@ main (int argc, char **argv)
char *endp = NULL;
__strtol_t val = -17;
strtol_error s_err = __xstrtol (input, &endp, -1, &val, "k");
-# if !(defined __GLIBC__ || defined __CYGWIN__)
+# if !(defined __GLIBC__ || defined __CYGWIN__ || is_GNULIB_strtol)
ASSERT (s_err == LONGINT_OK);
ASSERT (endp == input + 1);
ASSERT (val == 1024);
diff --git a/tests/test-xstrtoll.c b/tests/test-xstrtoll.c
index 47a552ebff..8da0e3bed1 100644
--- a/tests/test-xstrtoll.c
+++ b/tests/test-xstrtoll.c
@@ -1,4 +1,5 @@
#define __xstrtol xstrtoll
#define __strtol_t long long int
#define __spec "lld"
+#define is_GNULIB_strtol GNULIB_defined_strtoll_function
#include "test-xstrtol.c"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH] lib/xstrtol.c: Fix xstrtol() on EINVAL (invalid base),
Bruno Haible <=