From d6131f9798b5d923eb50479bed5d02a155583dd8 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Tue, 31 Mar 2015 10:55:28 +0300
Subject: Haiku patch


diff --git a/src/sarray1.c b/src/sarray1.c
index 8142699..0761ee6 100644
--- a/src/sarray1.c
+++ b/src/sarray1.c
@@ -132,6 +132,7 @@
 #include <string.h>
 #ifndef _WIN32
 #include <dirent.h>     /* unix only */
+#include <sys/stat.h>
 #endif  /* ! _WIN32 */
 #include "allheaders.h"
 
@@ -1852,6 +1853,7 @@ l_int32         len;
 SARRAY         *safiles;
 DIR            *pdir;
 struct dirent  *pdirentry;
+struct stat     s;
 
     PROCNAME("getFilenamesInDirectory");
 
@@ -1870,7 +1872,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
 
-- 
2.7.0


From c412c6398e5352a074f5d88565aec1a313bc6c50 Mon Sep 17 00:00:00 2001
From: Sergei Reznikov <diver@gelios.net>
Date: Tue, 31 Mar 2015 10:56:57 +0300
Subject: gcc2 fixes


diff --git a/prog/recogtest1.c b/prog/recogtest1.c
index 55556cc..a301765 100644
--- a/prog/recogtest1.c
+++ b/prog/recogtest1.c
@@ -126,6 +126,7 @@ SARRAY    *sa, *satext;
          *             requiring retention of 20% of templates in each class
          *  0.9, 0.01 : remove most based on matching; saved 1 in each class */
     fprintf(stderr, "Remove outliers\n");
+{
     static const l_float32  MinScore[] = {0.6, 0.7, 0.9};
     static const l_int32  MinTarget[] = {4, 5, 4};
     static const l_int32  MinSize[] = {3, 2, 3};
@@ -140,6 +141,7 @@ SARRAY    *sa, *satext;
         pixaDestroy(&pixa3);
     }
     pixaDestroy(&pixa2);
+}
 #endif
 
 #if 1
diff --git a/src/compare.c b/src/compare.c
index 8a34b89..564dd38 100644
--- a/src/compare.c
+++ b/src/compare.c
@@ -3365,6 +3365,7 @@ l_int32   *tab;
 l_float32  maxscore, score;
 FPIX      *fpix;
 PIX       *pix3, *pix4;
+char  buf[128];
 
     PROCNAME("pixBestCorrelation");
 
@@ -3411,7 +3412,6 @@ PIX       *pix3, *pix4;
 
     if (debugflag > 0) {
         lept_mkdir("lept/comp");
-        char  buf[128];
         pix3 = fpixDisplayMaxDynamicRange(fpix);
         pix4 = pixExpandReplicate(pix3, 20);
         snprintf(buf, sizeof(buf), "/tmp/lept/comp/correl_%d.png",
diff --git a/src/map.c b/src/map.c
index 71b3923..c2311f2 100644
--- a/src/map.c
+++ b/src/map.c
@@ -106,13 +106,14 @@
 L_AMAP *
 l_amapCreate(l_int32  keytype)
 {
+    L_AMAP *m;
     PROCNAME("l_amapCreate");
 
     if (keytype != L_INT_TYPE && keytype != L_UINT_TYPE &&
         keytype != L_FLOAT_TYPE)
         return (L_AMAP *)ERROR_PTR("invalid keytype", procName, NULL);
 
-    L_AMAP *m = (L_AMAP *)LEPT_CALLOC(1, sizeof(L_AMAP));
+    m = (L_AMAP *)LEPT_CALLOC(1, sizeof(L_AMAP));
     m->keytype = keytype;
     return m;
 }
@@ -182,13 +183,14 @@ l_amapSize(L_AMAP  *m)
 L_ASET *
 l_asetCreate(l_int32  keytype)
 {
+    L_ASET *s;
     PROCNAME("l_asetCreate");
 
     if (keytype != L_INT_TYPE && keytype != L_UINT_TYPE &&
         keytype != L_FLOAT_TYPE)
         return (L_ASET *)ERROR_PTR("invalid keytype", procName, NULL);
 
-    L_ASET *s = (L_ASET *)LEPT_CALLOC(1, sizeof(L_ASET));
+    s = (L_ASET *)LEPT_CALLOC(1, sizeof(L_ASET));
     s->keytype = keytype;
     return s;
 }
diff --git a/src/rbtree.c b/src/rbtree.c
index 4092b7d..4fa878d 100644
--- a/src/rbtree.c
+++ b/src/rbtree.c
@@ -131,13 +131,14 @@ static void verify_properties(L_RBTREE *t);
 L_RBTREE *
 l_rbtreeCreate(l_int32  keytype)
 {
+    L_RBTREE *t;
     PROCNAME("l_rbtreeCreate");
 
     if (keytype != L_INT_TYPE && keytype != L_UINT_TYPE &&
         keytype != L_FLOAT_TYPE && keytype)
         return (L_RBTREE *)ERROR_PTR("invalid keytype", procName, NULL);
 
-    L_RBTREE *t = (L_RBTREE *)LEPT_CALLOC(1, sizeof(L_RBTREE));
+    t = (L_RBTREE *)LEPT_CALLOC(1, sizeof(L_RBTREE));
     t->keytype = keytype;
     verify_properties(t);
     return t;
@@ -154,12 +155,13 @@ RB_TYPE *
 l_rbtreeLookup(L_RBTREE  *t,
                RB_TYPE    key)
 {
+    node *n;
     PROCNAME("l_rbtreeLookup");
 
     if (!t)
         return (RB_TYPE *)ERROR_PTR("tree is null\n", procName, NULL);
 
-    node *n = lookup_node(t, key);
+    n = lookup_node(t, key);
     return n == NULL ? NULL : &n->value;
 }
 
diff --git a/src/readbarcode.c b/src/readbarcode.c
index a2e6300..aa03767 100644
--- a/src/readbarcode.c
+++ b/src/readbarcode.c
@@ -733,11 +733,13 @@ NUMA      *nas, *nax, *nay, *nad;
 
     if (debugflag) {
         lept_mkdir("lept/barcode");
+        {
         GPLOT *gplot = gplotCreate("/tmp/lept/barcode/signal", GPLOT_PNG,
                                    "Pixel values", "dist in pixels", "value");
         gplotAddPlot(gplot, nax, nay, GPLOT_LINES, "plot 1");
         gplotMakeOutput(gplot);
         gplotDestroy(&gplot);
+        }
     }
 
         /* Locate the crossings.  Run multiple times with different
diff --git a/src/recogident.c b/src/recogident.c
index 19d06dd..a621268 100644
--- a/src/recogident.c
+++ b/src/recogident.c
@@ -742,6 +742,7 @@ l_float32   maxscore, score;
 l_float32  *ycent1;
 FPIX       *fpix;
 PIX        *pixt, *pixt1, *pixt2;
+char  buf[128];
 
     PROCNAME("pixCorrelationBestShift");
 
@@ -830,7 +831,6 @@ PIX        *pixt, *pixt1, *pixt2;
 
     if (debugflag > 0) {
         lept_mkdir("lept/recog");
-        char  buf[128];
         pixt1 = fpixDisplayMaxDynamicRange(fpix);
         pixt2 = pixExpandReplicate(pixt1, 5);
         snprintf(buf, sizeof(buf), "/tmp/lept/recog/junkbs_%d.png", debugflag);
-- 
2.7.0

