From 0b6499e1a9868539583d776f2c0c6251b38a02e6 Mon Sep 17 00:00:00 2001
From: Luke <noryb009@gmail.com>
Date: Thu, 26 Dec 2013 01:39:15 +0000
Subject: [PATCH] Fix building on Haiku

---
 configure.ac | 2 +-
 src/sarray.c | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index fb5ca0c..88b52c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
 AC_PREREQ([2.50])
 AC_INIT([leptonica], [1.69], [dan.bloomberg@gmail.com])
 AC_CONFIG_AUX_DIR([config])
-AM_CONFIG_HEADER([config_auto.h:config/config.h.in])
+AC_CONFIG_HEADERS([config_auto.h:config/config.h.in])
 AC_CONFIG_SRCDIR([src/adaptmap.c])
 
 AC_CONFIG_MACRO_DIR([m4])
diff --git a/src/sarray.c b/src/sarray.c
index c21bf3b..b212bf8 100644
--- a/src/sarray.c
+++ b/src/sarray.c
@@ -131,6 +131,7 @@
 #include <string.h>
 #ifndef _WIN32
 #include <dirent.h>     /* unix only */
+#include <sys/stat.h>
 #endif  /* ! _WIN32 */
 #include "allheaders.h"
 
@@ -1831,6 +1832,7 @@ l_int32         len;
 SARRAY         *safiles;
 DIR            *pdir;
 struct dirent  *pdirentry;
+struct stat     s;
 
     PROCNAME("getFilenamesInDirectory");
 
@@ -1847,7 +1849,8 @@ struct dirent  *pdirentry;
          * define _BSD_SOURCE in the CC command, because the DT_DIR
          * flag is non-standard.  */
 #if !defined(__SOLARIS__)
-        if (pdirentry->d_type == DT_DIR)
+        stat(pdirentry->d_name, &s);
+        if(S_ISDIR(s.st_mode))
             continue;
 #endif
 
-- 
1.8.3.4

