Eli Schwartz wrote:
> Bisected, and landed on:
> 
> 
> 043355371a76de8ea7d06f79a69fde905af7cc45 is the first bad commit
> commit 043355371a76de8ea7d06f79a69fde905af7cc45
> Author:     Paul Eggert <[email protected]>
> AuthorDate: Fri Sep 6 22:32:54 2024
> Commit:     Paul Eggert <[email protected]>
> CommitDate: Mon Sep 16 01:50:38 2024
> 
>     X == -1 → X < 0

Oh, I see. On Haiku, system-defined errno values are not positive (as
demanded by POSIX), but negative [1]. Since there's no chance that this
will change (because changing errno values would mean that all programs
need to be recompiled), we need to bite the sour apple and revert to
== -1 for errno values.

With the attached patch, the tests concat-git-diff and remember-backup-files
now pass. The only remaining test failure is preserve-mode-and-timestamp,
for which we have an explanation.

Bruno

[1] https://www.gnu.org/software/gnulib/manual/html_node/errno_002eh.html
>From bf04a5939e74c97884a9d4568364a99001172179 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Wed, 5 Feb 2025 21:37:45 +0100
Subject: [PATCH] Fix two test failures on Haiku.

On Haiku, all error numbers are negative, see
<https://www.gnu.org/software/gnulib/manual/html_node/errno_002eh.html>.

Bisected by Eli Schwartz <[email protected]>.

This partially reverts commit 043355371a76de8ea7d06f79a69fde905af7cc45.

* src/inp.c (get_input_file): Don't assume that all system-defined errno values
are positive.
* src/patch.c (main): Likewise.
* src/safe.c (read_symlink): Likewise.
* src/util.c (move_file): Likewise.
---
 src/inp.c   | 2 +-
 src/patch.c | 2 +-
 src/safe.c  | 2 +-
 src/util.c  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/inp.c b/src/inp.c
index dd6f1aa..5dc3854 100644
--- a/src/inp.c
+++ b/src/inp.c
@@ -85,7 +85,7 @@ get_input_file (char *filename, char const *outname, mode_t file_type)
     char *diffbuf;
     char *getbuf;
 
-    if (inerrno < 0)
+    if (inerrno == -1)
       inerrno = stat_file (filename, &instat);
 
     /* Perhaps look for RCS or SCCS versions.  */
diff --git a/src/patch.c b/src/patch.c
index fc41452..6c460f7 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -291,7 +291,7 @@ main (int argc, char **argv)
 
 	  if (! strcmp (inname, outname))
 	    {
-	      if (inerrno < 0)
+	      if (inerrno == -1)
 		inerrno = stat_file (inname, &instat);
 	      outstat = instat;
 	      outerrno = inerrno;
diff --git a/src/safe.c b/src/safe.c
index a2b3931..2fcf412 100644
--- a/src/safe.c
+++ b/src/safe.c
@@ -340,7 +340,7 @@ static struct symlink *read_symlink(int dirfd, const char *name)
     {
       char *end;
 
-      if (cwd_stat_errno < 0)
+      if (cwd_stat_errno == -1)
 	{
 	  cwd_stat_errno = stat (".", &cwd_stat) == 0 ? 0 : errno;
 	  if (cwd_stat_errno)
diff --git a/src/util.c b/src/util.c
index bcbd020..d0facb4 100644
--- a/src/util.c
+++ b/src/util.c
@@ -573,7 +573,7 @@ move_file (struct outfile *outfrom, struct stat const *fromst,
 	      bool to_dir_known_to_exist = false;
 
 	      if (errno == ENOENT
-		  && (to_errno < 0 || to_errno == ENOENT))
+		  && (to_errno == -1 || to_errno == ENOENT))
 		{
 		  makedirs (to);
 		  to_dir_known_to_exist = true;
-- 
2.43.0

  • Re: patch-2.7.... Eli Schwartz
    • Re: patch... Bug reports, suggestions, general discussion for GNU patch.
      • Re: p... Eli Schwartz
        • R... Bug reports, suggestions, general discussion for GNU patch.
          • ... Eli Schwartz
            • ... Bug reports, suggestions, general discussion for GNU patch.
          • ... Bug reports, suggestions, general discussion for GNU patch.
          • ... Paul Eggert
            • ... Andreas Grünbacher
            • ... Bug reports, suggestions, general discussion for GNU patch.

Reply via email to