Paul Eggert wrote:
> * tests/test-open.h (test_open): Fail if test takes too long
> because we tried to open a fifo.  Test opening /dev/null,
> /dev/tty and a fifo, with a trailing "/" and with O_DIRECTORY.

The CI reports a failure of these new tests on native Windows (mingw, MSVC):

FAIL: test-open
===============

../../tests/test-open.h:89: assertion 'errno == ENOTDIR || errno == EISDIR || 
errno == EINVAL' failed
FAIL test-open.exe (exit status: 3)

And in a testdir of modules 'open', 'openat', I see a syntax error as well:

../../gllib/open.c: In function »rpl_open«:
../../gllib/open.c:198:5: error: expected »)« before »{« token
     {
     ^

These patches fix things.


2025-06-02  Bruno Haible  <br...@clisp.org>

        open, openat: Fix test failure on native Windows.
        * tests/test-open.h (test_open): Expect a different error code for
        "/dev/null/" on native Windows.

        open: Fix syntax error on native Windows (regression 2025-05-28).
        * lib/open.c (open): Add missing parenthesis.

>From af9ec1a1ef7ccb81727a6963dea6b2bafa0aa2d5 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Mon, 2 Jun 2025 12:50:04 +0200
Subject: [PATCH 1/2] open: Fix syntax error on native Windows (regression
 2025-05-28).

* lib/open.c (open): Add missing parenthesis.
---
 ChangeLog  | 5 +++++
 lib/open.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index e168863f67..9bb85638d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2025-06-02  Bruno Haible  <br...@clisp.org>
+
+	open: Fix syntax error on native Windows (regression 2025-05-28).
+	* lib/open.c (open): Add missing parenthesis.
+
 2025-06-01  Bruno Haible  <br...@clisp.org>
 
 	gettext-h: Avoid warnings from "gcc -Wextra".
diff --git a/lib/open.c b/lib/open.c
index 624572c8dd..3da2dce072 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -194,7 +194,7 @@ open (const char *filename, int flags, ...)
   if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES
       && ((flags & (O_ACCMODE | O_CREAT)) == O_RDONLY
           || (O_SEARCH != O_RDONLY
-              && (flags & (O_ACCMODE | O_CREAT)) == O_SEARCH))
+              && (flags & (O_ACCMODE | O_CREAT)) == O_SEARCH)))
     {
       struct stat statbuf;
       if (check_directory
-- 
2.43.0

>From 1619b78c150e77204844e9bd04521aa59ef87e6f Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Mon, 2 Jun 2025 12:51:55 +0200
Subject: [PATCH 2/2] open, openat: Fix test failure on native Windows.

* tests/test-open.h (test_open): Expect a different error code for
"/dev/null/" on native Windows.
---
 ChangeLog         | 4 ++++
 tests/test-open.h | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 9bb85638d4..51a3822484 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2025-06-02  Bruno Haible  <br...@clisp.org>
 
+	open, openat: Fix test failure on native Windows.
+	* tests/test-open.h (test_open): Expect a different error code for
+	"/dev/null/" on native Windows.
+
 	open: Fix syntax error on native Windows (regression 2025-05-28).
 	* lib/open.c (open): Add missing parenthesis.
 
diff --git a/tests/test-open.h b/tests/test-open.h
index b745a2b08d..1a80af454a 100644
--- a/tests/test-open.h
+++ b/tests/test-open.h
@@ -86,7 +86,11 @@ test_open (int (*func) (char const *, int, ...), bool print)
   /* Cannot open /dev/null with trailing slash or O_DIRECTORY.  */
   errno = 0;
   ASSERT (func ("/dev/null/", O_RDONLY) == -1);
+#if defined _WIN32 && !defined __CYGWIN__
+  ASSERT (errno == ENOENT);
+#else
   ASSERT (errno == ENOTDIR || errno == EISDIR || errno == EINVAL);
+#endif
 
   errno = 0;
   ASSERT (func ("/dev/null", O_RDONLY | O_DIRECTORY) == -1);
-- 
2.43.0

Reply via email to