From 1ec2570c4e742b7efe9f83a78c001a890f8e6dc3 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Mon, 23 Mar 2015 17:20:54 +0000
Subject: Haiku patch


diff --git a/src/files.c b/src/files.c
index bd07597..ee8a350 100644
--- a/src/files.c
+++ b/src/files.c
@@ -1220,11 +1220,11 @@ void do_insertfile(
 
 #if !defined(DISABLE_MULTIBUFFER) && !defined(DISABLE_HISTORIES)
 	    if (ISSET(MULTIBUFFER)) {
+		ssize_t savedposline, savedposcol;
 		/* Update the screen to account for the current
 		 * buffer. */
 		display_buffer();
 
-		ssize_t savedposline, savedposcol;
 		if (ISSET(POS_HISTORY) &&
 #ifndef NANO_TINY
 			!execute &&
diff --git a/src/text.c b/src/text.c
index dd72308..59c904d 100644
--- a/src/text.c
+++ b/src/text.c
@@ -395,11 +395,12 @@ void undo_cut(undo *u)
 /* Redo a cut, or undo an uncut. */
 void redo_cut(undo *u)
 {
+    filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
+
     /* If we cut the magicline, we may as well not crash. :/ */
     if (!u->cutbuffer)
 	return;
 
-    filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
     cutbuffer = NULL;
     cutbottom = NULL;
 
@@ -430,6 +431,7 @@ void redo_cut(undo *u)
 /* Undo the last thing(s) we did. */
 void do_undo(void)
 {
+    filestruct *f;
     undo *u = openfile->current_undo;
     filestruct *t = 0;
     size_t len = 0;
@@ -440,7 +442,7 @@ void do_undo(void)
 	return;
     }
 
-    filestruct *f = fsfromline(u->mark_begin_lineno);
+    f = fsfromline(u->mark_begin_lineno);
     if (!f) {
 	statusbar(_("Internal error: can't match line %d.  Please save your work."), u->mark_begin_lineno);
 	return;
@@ -526,6 +528,7 @@ void do_undo(void)
 	break;
     case INSERT:
 	undidmsg = _("text insert");
+	{
 	filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
 	cutbuffer = NULL;
 	cutbottom = NULL;
@@ -544,6 +547,7 @@ void do_undo(void)
 	cutbuffer = oldcutbuffer;
 	cutbottom = oldcutbottom;
 	openfile->mark_set = FALSE;
+	}
 	break;
     case REPLACE:
 	undidmsg = _("text replace");
@@ -570,6 +574,7 @@ void do_undo(void)
 /* Redo the last thing(s) we undid. */
 void do_redo(void)
 {
+    filestruct *f;
     undo *u = openfile->undotop;
     size_t len = 0;
     char *data, *redidmsg = NULL;
@@ -585,7 +590,7 @@ void do_redo(void)
 	return;
     }
 
-    filestruct *f = fsfromline(u->mark_begin_lineno);
+    f = fsfromline(u->mark_begin_lineno);
     if (!f) {
 	statusbar(_("Internal error: can't match line %d.  Please save your work."), u->mark_begin_lineno);
 	return;
@@ -1069,6 +1074,7 @@ fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno =
 	    free_filestruct(u->cutbuffer);
 	u->cutbuffer = copy_filestruct(cutbuffer);
 	if (u->mark_set) {
+	    ssize_t line;
 	    /* If the "marking" operation was from right-->left or
 	     * bottom-->top, then swap the mark points. */
 	    if ((u->lineno == u->mark_begin_lineno && u->begin < u->mark_begin_x)
@@ -1077,7 +1083,7 @@ fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno =
 		u->begin = u->mark_begin_x;
 		u->mark_begin_x = x_loc;
 
-		ssize_t line = u->lineno;
+		line = u->lineno;
 		u->lineno = u->mark_begin_lineno;
 		u->mark_begin_lineno = line;
 	    } else
@@ -1151,6 +1157,8 @@ bool do_wrap(filestruct *line)
 	/* The next line, minus indentation. */
     size_t next_line_len = 0;
 	/* The length of next_line. */
+	size_t old_x;
+	filestruct * oldLine;
 
     /* There are three steps.  First, we decide where to wrap.  Then, we
      * create the new wrap line.  Finally, we clean up. */
@@ -1204,8 +1212,8 @@ bool do_wrap(filestruct *line)
     add_undo(SPLIT_BEGIN);
 #endif
 
-    size_t old_x = openfile->current_x;
-    filestruct * oldLine = openfile->current;
+    old_x = openfile->current_x;
+    oldLine = openfile->current;
     openfile->current = line;
 
     /* Step 2, making the new wrap line.  It will consist of indentation
@@ -2664,7 +2672,11 @@ const char *do_alt_speller(char *tempfile_name)
     ssize_t current_y_save = openfile->current_y;
     ssize_t lineno_save = openfile->current->lineno;
     struct stat spellfileinfo;
+#ifdef __HAIKU__
+    time_t timestamp;
+#else
     __time_t timestamp;
+#endif
     pid_t pid_spell;
     char *ptr;
     static int arglen = 3;
-- 
1.8.3.4

