]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
glob: Fix test failure on Cygwin.
authorBruno Haible <bruno@clisp.org>
Wed, 15 Oct 2025 13:16:59 +0000 (15:16 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 15 Oct 2025 13:16:59 +0000 (15:16 +0200)
* m4/glob.m4 (gl_GLOB): Add a second test case.
* doc/posix-functions/glob.texi: Mention Cygwin.

ChangeLog
doc/posix-functions/glob.texi
m4/glob.m4

index 56efbc382003932692374bf5906b2d8272c11850..e42473c1d430bde84ba6a26330abcf29721b929f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-10-15  Bruno Haible  <bruno@clisp.org>
+
+       glob: Fix test failure on Cygwin.
+       * m4/glob.m4 (gl_GLOB): Add a second test case.
+       * doc/posix-functions/glob.texi: Mention Cygwin.
+
 2025-10-15  Bruno Haible  <bruno@clisp.org>
 
        glob tests: Improve maintainability.
index c74f62f9671b2906e7be281643aa5da74c84cee6..d3cc89442e5189591d5b4fd6a00295398e2592a1 100644 (file)
@@ -26,7 +26,8 @@ every @code{/} following a wildcard character on some platforms, which
 can cause the stack to overflow:
 @c https://sourceware.org/PR30635
 @c https://sourceware.org/PR33537
-glibc 2.42.
+glibc 2.42,
+Cygwin.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 6f086f78c2eb5b68f100f86116c31b0b02ef8aa4..77b1cc8380ab3344058ac7c76fb572919f7e77a5 100644 (file)
@@ -1,5 +1,5 @@
 # glob.m4
-# serial 32
+# serial 33
 dnl Copyright (C) 2005-2007, 2009-2025 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -39,23 +39,35 @@ AC_DEFUN([gl_GLOB],
                  and earlier.  */
               char *p = malloc (10000);
               glob_t g;
-              int res = 0;
+              int result = 0;
               if (p != NULL)
                 {
+                  /* This test fails on glibc <= 2.42 (stack overflow).  */
                   memset (p, '/', 9999);
                   p[9999] = '\0';
-                  res = glob (p, 0, NULL, &g);
+                  if (glob (p, 0, NULL, &g) != 0)
+                    result |= 1;
+                  globfree (&g);
+                  /* This test fails on Cygwin 3.6.4 (return value
+                     GLOB_ABORTED).  */
+                  memset (p, '/', 9997);
+                  p[1] = '*';
+                  strcpy (p + 9997, "sh");
+                  if (glob (p, 0, NULL, &g) != 0)
+                    result |= 2;
                   globfree (&g);
                 }
-              return !(res == 0);
+              return result;
             }]])],
          [gl_cv_glob_overflows_stack=no],
          [gl_cv_glob_overflows_stack=yes],
          [case "$host_os" in
-                               # Guess yes on glibc systems.
-            *-gnu* | gnu*)     gl_cv_glob_overflows_stack="guessing yes" ;;
-                               # If we don't know, obey --enable-cross-guesses.
-            *)                 gl_cv_glob_overflows_stack="$gl_cross_guess_inverted" ;;
+                           # Guess yes on glibc systems.
+            *-gnu* | gnu*) gl_cv_glob_overflows_stack="guessing yes" ;;
+                           # Guess yes on Cygwin.
+            cygwin*)       gl_cv_glob_overflows_stack="guessing yes" ;;
+                           # If we don't know, obey --enable-cross-guesses.
+            *)             gl_cv_glob_overflows_stack="$gl_cross_guess_inverted" ;;
           esac
          ])
       ])