From 03161d425f5afaaca54089a82d337e9e9236288f Mon Sep 17 00:00:00 2001
From: Chris Roberts <cpr420@gmail.com>
Date: Wed, 18 Sep 2013 03:11:28 -0600
Subject: Fix for gcc2


diff --git a/Src/Modules/param_private.c b/Src/Modules/param_private.c
index 86416c5..b8e7c18 100644
--- a/Src/Modules/param_private.c
+++ b/Src/Modules/param_private.c
@@ -79,6 +79,7 @@ static int makeprivate_error = 0;
 static void
 makeprivate(HashNode hn, UNUSED(int flags))
 {
+    struct gsu_closure *gsu;
     Param pm = (Param)hn;
     if (pm->level == locallevel) {
 	if (pm->ename || (pm->node.flags & PM_NORESTORE) ||
@@ -92,7 +93,7 @@ makeprivate(HashNode hn, UNUSED(int flags))
 	    makeprivate_error = 1;
 	    return;
 	}
-	struct gsu_closure *gsu = zhalloc(sizeof(struct gsu_closure));
+	gsu = zhalloc(sizeof(struct gsu_closure));
 	switch (PM_TYPE(pm->node.flags)) {
 	case PM_SCALAR:
 	    gsu->g = (void *)(pm->gsu.s);
diff --git a/Src/Zle/textobjects.c b/Src/Zle/textobjects.c
index c93777b..ce91995 100644
--- a/Src/Zle/textobjects.c
+++ b/Src/Zle/textobjects.c
@@ -61,8 +61,9 @@ selectword(UNUSED(char **args))
 	}
 	/* similarly scan forward over characters of the same class */
 	while (zlecs < zlell) {
+	    int pos;
 	    INCCS();
-	    int pos = zlecs;
+	    pos = zlecs;
 	    /* single newlines within blanks are included */
 	    if (all && !sclass && pos < zlell && zleline[pos] == ZWC('\n'))
 		INCPOS(pos);
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index 581ca49..ebe5a1b 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -1622,10 +1622,11 @@ doisearch(char **args, int dir, int pattern)
 	    else
 		goto ins;
 	} else if (cmd == Th(z_bracketedpaste)) {
+	    size_t pastelen;
 	    char *paste = bracketedstring();
 	    set_isrch_spot(top_spot++, hl, pos, pat_hl, pat_pos, end_pos,
 			   zlemetacs, sbptr, dir, nomatch);
-	    size_t pastelen = strlen(paste);
+	    pastelen = strlen(paste);
 	    if (sbptr + pastelen >= sibuf - FIRST_SEARCH_CHAR - 2) {
 		int oldsize = sibuf;
 		sibuf += (pastelen >= sibuf) ? pastelen + 1 : sibuf;
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index a5ff920..14a885b 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -183,11 +183,12 @@ getvirange(int wf)
 	vilinerange = (visual == 2);
 	region_active = 0;
     } else {
+	Keymap km;
 	virangeflag = 1;
 	wordflag = wf;
 	mark = -1;
 	/* use operator-pending keymap if one exists */
-	Keymap km = openkeymap("viopp");
+	km = openkeymap("viopp");
 	if (km)
 	    selectlocalmap(km);
 	/* Now we need to execute the movement command, to see where it *
diff --git a/Src/params.c b/Src/params.c
index 089a958..0867be9 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -5036,7 +5036,7 @@ arrfixenv(char *s, char **t)
 int
 zputenv(char *str)
 {
-    DPUTS(!str, "Attempt to put null string into environment.");
+    //DPUTS(!str, "Attempt to put null string into environment.");
 #ifdef USE_SET_UNSET_ENV
     /*
      * If we are using unsetenv() to remove values from the
diff --git a/configure.ac b/configure.ac
index 5513e25..a58ccad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -850,7 +850,7 @@ if test x$enable_cap = xyes; then
   AC_CHECK_LIB(cap, cap_get_proc)
 fi
 
-AC_CHECK_LIB(socket, socket)
+AC_CHECK_LIB(network, socket)
 AC_SEARCH_LIBS(gethostbyname2, bind)
 
 case $LIBS in
-- 
2.19.1


From d3f7f23df0647d793bece6670cc95e615ed4e8d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Wed, 11 Jan 2017 18:17:20 +0100
Subject: Haiku rusage fix


diff --git a/Src/jobs.c b/Src/jobs.c
index 73d7f26..58ba389 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1026,7 +1026,7 @@ should_report_time(Job j)
 #endif
     }
 
-#ifdef HAVE_GETRUSAGE
+#if defined(HAVE_GETRUSAGE) && !defined(__HAIKU__)
     if (reportmemory >= 0 &&
 	j->procs->ti.ru_maxrss / 1024 > reportmemory)
 	return 1;
-- 
2.19.1


From beb2648a711e98e64db897f1f4005bd32a98a131 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Thu, 17 Aug 2017 16:16:21 +0200
Subject: Enable dynamic modules on Haiku


diff --git a/configure.ac b/configure.ac
index a58ccad..31cca13 100644
--- a/configure.ac
+++ b/configure.ac
@@ -844,6 +844,7 @@ fi
 
 if test "x$dynamic" = xyes; then
   AC_CHECK_LIB(dl, dlopen)
+  AC_CHECK_LIB(root, dlopen)
 fi
 
 if test x$enable_cap = xyes; then
@@ -2815,7 +2816,8 @@ char *argv[];
     aix*)         DLLDFLAGS="${DLLDFLAGS=-G -bexpall -lc}" ;;
     solaris*|sysv4*|esix*) DLLDFLAGS="${DLLDFLAGS=-G}" ;;
     darwin*)      DLLDFLAGS="${DLLDFLAGS=-bundle -flat_namespace -undefined suppress}" ;;
-    beos*|haiku*) DLLDFLAGS="${DLLDFLAGS=-nostart}" ;;
+    beos*) DLLDFLAGS="${DLLDFLAGS=-nostart}" ;;
+    haiku*) DLLDFLAGS="${DLLDFLAGS=-shared}" ;;
     openbsd*)
       if test x$zsh_cv_sys_elf = xyes; then
 	DLLDFLAGS="${DLLDFLAGS=-shared -fPIC}"
-- 
2.19.1


From 37c853695e36913363546e17d7e9459ff71d8935 Mon Sep 17 00:00:00 2001
From: fbrosson <fbrosson@localhost>
Date: Sat, 14 Apr 2018 18:11:49 +0000
Subject: C89 fixes for gcc2 compatibility


diff --git a/Src/exec.c b/Src/exec.c
index 042ba06..c21f627 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3126,10 +3126,11 @@ execcmd_exec(Estate state, Execcmd_params eparams,
 		}
 		if (exec_argv0) {
 		    char *str, *s;
+		    size_t sz;
 		    exec_argv0 = dupstring(exec_argv0);
 		    remnulargs(exec_argv0);
 		    untokenize(exec_argv0);
-		    size_t sz = strlen(exec_argv0);
+		    sz = strlen(exec_argv0);
 		    str = s = zalloc(5 + 1 + sz + 1);
 		    strcpy(s, "ARGV0=");
 		    s+=6;
diff --git a/Src/init.c b/Src/init.c
index e7e62e2..3d8ecb3 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -1277,8 +1277,9 @@ run_init_scripts(void)
 		sourcehome(".profile");
 
 	    if (interact) {
+		char *s;
 		noerrs = 2;
-		char *s = getsparam("ENV");
+		s = getsparam("ENV");
 		if (s) {
 		    s = dupstring(s);
 		    if (!parsestr(&s)) {
diff --git a/Src/parse.c b/Src/parse.c
index 83383f1..8e783be 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -403,8 +403,9 @@ ecstrcode(char *s)
     unsigned val = hasher(s);
 
     if ((l = strlen(s) + 1) && l <= 4) {
+	wordcode c;
 	t = has_token(s);
-	wordcode c = (t ? 3 : 2);
+	c = (t ? 3 : 2);
 	switch (l) {
 	case 4: c |= ((wordcode) STOUC(s[2])) << 19;
 	case 3: c |= ((wordcode) STOUC(s[1])) << 11;
diff --git a/Src/utils.c b/Src/utils.c
index 32f6008..478b334 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -138,10 +138,11 @@ set_widearray(char *mb_array, Widechar_array wca)
 static void
 zwarning(const char *cmd, const char *fmt, va_list ap)
 {
+    char *prefix;
     if (isatty(2))
 	zleentry(ZLE_CMD_TRASH);
 
-    char *prefix = scriptname ? scriptname : (argzero ? argzero : "");
+    prefix = scriptname ? scriptname : (argzero ? argzero : "");
 
     if (cmd) {
 	if (unset(SHINSTDIN) || locallevel) {
@@ -2802,6 +2803,7 @@ int
 checkrmall(char *s)
 {
     DIR *rmd;
+    const int max_count = 100;
     int count = 0;
     if (!shout)
 	return 1;
@@ -2811,7 +2813,6 @@ checkrmall(char *s)
 	else
 	    s = dyncat("/", s);
     }
-    const int max_count = 100;
     if ((rmd = opendir(unmeta(s)))) {
 	int ignoredots = !isset(GLOBDOTS);
 	char *fname;
-- 
2.19.1


From d4255d3ea9c61387bf5b5f80e60863f73ba42f8f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Sat, 27 Oct 2018 10:36:50 +0200
Subject: Some other function resides in libroot


diff --git a/configure.ac b/configure.ac
index 31cca13..c20c2a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -746,10 +746,12 @@ dnl and might not be compiled into the zsh executable.
 dnl On ReliantUNIX -lc better be the last library, else funny things
 dnl may happen.
 AC_CHECK_LIB(c, printf, [LIBS="$LIBS -lc"])
+AC_CHECK_LIB(root, printf)
 
 AC_CHECK_LIB(m, pow)
 
 AC_CHECK_LIB(rt, clock_gettime)
+AC_CHECK_LIB(root, clock_gettime)
 
 dnl Various features of ncurses depend on having the right header
 dnl (the system's own curses.h may well not be good enough).
-- 
2.19.1


From e764303a114797ed36f8b8c8009cde82f0efc55c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Mon, 18 Feb 2019 13:41:08 +0100
Subject: Build fix for gcc2 from hanya


diff --git a/Src/Modules/nearcolor.c b/Src/Modules/nearcolor.c
index b49ee9a..44313ba 100644
--- a/Src/Modules/nearcolor.c
+++ b/Src/Modules/nearcolor.c
@@ -49,12 +49,12 @@ deltae(Cielab lab1, Cielab lab2)
 static void
 RGBtoLAB(int red, int green, int blue, Cielab lab)
 {
-    double R = red / 255.0;
-    double G = green / 255.0;
-    double B = blue / 255.0;
-    R = 100.0 * (R > 0.04045 ? pow((R + 0.055) / 1.055, 2.4) : R / 12.92);
-    G = 100.0 * (G > 0.04045 ? pow((G + 0.055) / 1.055, 2.4) : G / 12.92);
-    B = 100.0 * (B > 0.04045 ? pow((B + 0.055) / 1.055, 2.4) : B / 12.92);
+    double r = red / 255.0;
+    double g = green / 255.0;
+    double b = blue / 255.0;
+    double R = 100.0 * (r > 0.04045 ? pow((r + 0.055) / 1.055, 2.4) : r / 12.92);
+    double G = 100.0 * (g > 0.04045 ? pow((g + 0.055) / 1.055, 2.4) : g / 12.92);
+    double B = 100.0 * (b > 0.04045 ? pow((b + 0.055) / 1.055, 2.4) : b / 12.92);
 
     /* Observer. = 2 degrees, Illuminant = D65 */
     double X = (R * 0.4124 + G * 0.3576 + B * 0.1805) / 95.047;
-- 
2.19.1

