Hi,

Trying to build nano from git on Haiku failed because, among other
things, in the gnulib module glob, a variable is declared after a
bit of code and the gcc-2* compiler on Haiku does not permit that.
(This is on a 32-bit machine.)

Attached is a patch that avoids the issue.  (For my build, I need
only the first hunk, but since a comment on the next function says
to keep the two functions in sync...)

(Please CC; not subscribed.)

Benno
>From 63c8fb5f56210989ba33230c77febbc3323aafa0 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensb...@telfort.nl>
Date: Sat, 1 Jul 2017 18:05:00 +0200
Subject: [PATCH] glob: declare variables at the very start of their scope

* lib/glob.c (convert_dirent, convert_dirent64): Give each fragment
its separate scope, so the functions will compile on Haiku.
---
 lib/glob.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/glob.c b/lib/glob.c
index d4fdc1737..dc0aff693 100644
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -189,8 +189,11 @@ convert_dirent (const struct dirent *source)
       struct readdir_result result = { NULL, };
       return result;
     }
-  struct readdir_result result = READDIR_RESULT_INITIALIZER (source);
-  return result;
+  else
+    {
+      struct readdir_result result = READDIR_RESULT_INITIALIZER (source);
+      return result;
+    }
 }
 
 #ifndef COMPILE_GLOB64
@@ -204,8 +207,11 @@ convert_dirent64 (const struct dirent64 *source)
       struct readdir_result result = { NULL, };
       return result;
     }
-  struct readdir_result result = READDIR_RESULT_INITIALIZER (source);
-  return result;
+  else
+    {
+      struct readdir_result result = READDIR_RESULT_INITIALIZER (source);
+      return result;
+    }
 }
 #endif
 
-- 
2.13.1

Reply via email to