From: Bruno Haible <bruno@clisp.org>
Date: Mon, 1 Jul 2024 15:33:17 +0000 (+0200)
Subject: Avoid some possibly wrong configure test results.
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=498a9ac874b9ec489d74665ea57c22cf72bb9926;p=gnulib.git

Avoid some possibly wrong configure test results.

Reported by Arsen Arsenović <arsen@gentoo.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-07/msg00000.html>.

* m4/printf.m4 (gl_PRINTF_DIRECTIVE_N): Include necessary header file
for _exit().
(gl_SNPRINTF_DIRECTIVE_N): Likewise.
* m4/memmem.m4 (gl_FUNC_MEMMEM): Update comment.
* m4/sleep.m4 (gl_FUNC_SLEEP): Likewise.
* m4/strcasestr.m4 (gl_FUNC_STRCASESTR): Likewise.
* m4/strstr.m4 (gl_FUNC_STRSTR): Likewise.
* m4/wcsstr.m4 (gl_FUNC_WCSSTR): Likewise.
---

diff --git a/ChangeLog b/ChangeLog
index 684afe712d..abdba4716b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-07-01  Bruno Haible  <bruno@clisp.org>
+
+	Avoid some possibly wrong configure test results.
+	Reported by Arsen Arsenović <arsen@gentoo.org> in
+	<https://lists.gnu.org/archive/html/bug-gnulib/2024-07/msg00000.html>.
+	* m4/printf.m4 (gl_PRINTF_DIRECTIVE_N): Include necessary header file
+	for _exit().
+	(gl_SNPRINTF_DIRECTIVE_N): Likewise.
+	* m4/memmem.m4 (gl_FUNC_MEMMEM): Update comment.
+	* m4/sleep.m4 (gl_FUNC_SLEEP): Likewise.
+	* m4/strcasestr.m4 (gl_FUNC_STRCASESTR): Likewise.
+	* m4/strstr.m4 (gl_FUNC_STRSTR): Likewise.
+	* m4/wcsstr.m4 (gl_FUNC_WCSSTR): Likewise.
+
 2024-07-01  Bruno Haible  <bruno@clisp.org>
 
 	doc: Update regarding stable branches.
diff --git a/m4/memmem.m4 b/m4/memmem.m4
index a9bc277813..e6b1d91cbb 100644
--- a/m4/memmem.m4
+++ b/m4/memmem.m4
@@ -1,5 +1,5 @@
 # memmem.m4
-# serial 29
+# serial 30
 dnl Copyright (C) 2002-2004, 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -102,7 +102,7 @@ static void quit (int sig) { _exit (sig + 128); }
     char *haystack = (char *) malloc (2 * m + 1);
     char *needle = (char *) malloc (m + 1);
     /* Failure to compile this test due to missing alarm is okay,
-       since all such platforms (mingw) also lack memmem.  */
+       since all such platforms (mingw, MSVC) also lack memmem.  */
     signal (SIGALRM, quit);
     alarm (5);
     /* Check for quadratic performance.  */
diff --git a/m4/printf.m4 b/m4/printf.m4
index 1363fe19e4..a6daa1a62c 100644
--- a/m4/printf.m4
+++ b/m4/printf.m4
@@ -1,5 +1,5 @@
 # printf.m4
-# serial 94
+# serial 95
 dnl Copyright (C) 2003, 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -897,8 +897,12 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
         [AC_LANG_SOURCE([[
 #include <signal.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
+#if defined _WIN32 && !defined __CYGWIN__
+# include <stdlib.h>
+#else
+# include <unistd.h>
+#endif
 #ifdef _MSC_VER
 #include <crtdbg.h>
 #include <inttypes.h>
@@ -1717,6 +1721,11 @@ AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N],
 #include <signal.h>
 #include <stdio.h>
 #include <string.h>
+#if defined _WIN32 && !defined __CYGWIN__
+# include <stdlib.h>
+#else
+# include <unistd.h>
+#endif
 #if HAVE_SNPRINTF
 # define my_snprintf snprintf
 #else
diff --git a/m4/sleep.m4 b/m4/sleep.m4
index 06f58b2860..ec8764bd2a 100644
--- a/m4/sleep.m4
+++ b/m4/sleep.m4
@@ -1,5 +1,5 @@
 # sleep.m4
-# serial 13
+# serial 14
 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -33,7 +33,7 @@ handle_alarm (int sig)
 }
 ]], [[
     /* Failure to compile this test due to missing alarm is okay,
-       since all such platforms (mingw) also lack sleep.  */
+       since all such platforms (mingw, MSVC) also lack sleep.  */
     unsigned int pentecost = 50 * 24 * 60 * 60; /* 50 days.  */
     unsigned int remaining;
     signal (SIGALRM, handle_alarm);
diff --git a/m4/strcasestr.m4 b/m4/strcasestr.m4
index d254871677..811e680ff5 100644
--- a/m4/strcasestr.m4
+++ b/m4/strcasestr.m4
@@ -1,5 +1,5 @@
 # strcasestr.m4
-# serial 28
+# serial 29
 dnl Copyright (C) 2005, 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -98,7 +98,7 @@ static void quit (int sig) { _exit (sig + 128); }
     char *haystack = (char *) malloc (2 * m + 2);
     char *needle = (char *) malloc (m + 2);
     /* Failure to compile this test due to missing alarm is okay,
-       since all such platforms (mingw) also lack strcasestr.  */
+       since all such platforms (mingw, MSVC) also lack strcasestr.  */
     signal (SIGALRM, quit);
     alarm (5);
     /* Check for quadratic performance.  */
diff --git a/m4/strstr.m4 b/m4/strstr.m4
index 957ed2e307..d19559aa25 100644
--- a/m4/strstr.m4
+++ b/m4/strstr.m4
@@ -1,5 +1,5 @@
 # strstr.m4
-# serial 24
+# serial 25
 dnl Copyright (C) 2008-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -95,7 +95,7 @@ static void quit (int sig) { _exit (sig + 128); }
     char *haystack = (char *) malloc (2 * m + 2);
     char *needle = (char *) malloc (m + 2);
     /* Failure to compile this test due to missing alarm is okay,
-       since all such platforms (mingw) also have quadratic strstr.  */
+       since all such platforms (mingw, MSVC) also have quadratic strstr.  */
     signal (SIGALRM, quit);
     alarm (5);
     /* Check for quadratic performance.  */
diff --git a/m4/wcsstr.m4 b/m4/wcsstr.m4
index eb43b9f354..20dd8406cc 100644
--- a/m4/wcsstr.m4
+++ b/m4/wcsstr.m4
@@ -1,5 +1,5 @@
 # wcsstr.m4
-# serial 3
+# serial 4
 dnl Copyright (C) 2011-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -34,7 +34,7 @@ static void quit (int sig) { _exit (sig + 128); }
     wchar_t *haystack = (wchar_t *) malloc ((2 * m + 2) * sizeof (wchar_t));
     wchar_t *needle = (wchar_t *) malloc ((m + 2) * sizeof (wchar_t));
     /* Failure to compile this test due to missing alarm is okay,
-       since all such platforms (mingw) also have quadratic strstr.  */
+       since all such platforms (mingw, MSVC) also have quadratic wcsstr.  */
     signal (SIGALRM, quit);
     alarm (5);
     /* Check for quadratic performance.  */