From 42bd871af32376ab68070ee949c6a4ea30d6c5f8 Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Sun, 7 Mar 2010 19:35:46 +0000
Subject: [PATCH] 2010-03-07 Chris Allegretta <chrisa@asty.org>         *
 configure.ac, nano.c (handle_sigwinch): Create check for whether LINES and   
        COLS can safely be redefined.  Fixes compilation issues with cygwin,
 and likely           with newer versions of ncurses, fixes Savannah bug 28984
 repoted by Andy Koppe           and Eric Oliver via mailing list.         *
 winio.c (get_mouseinput) - fix stray semicolon in code, also reported in     
      bug 28984.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4484 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog    |  8 ++++++++
 configure.ac | 15 +++++++++++++++
 src/nano.c   |  2 ++
 src/winio.c  |  2 +-
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 95061b7a..89db5d74 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-03-07 Chris Allegretta <chrisa@asty.org>
+	* configure.ac, nano.c (handle_sigwinch): Create check for whether LINES and
+	  COLS can safely be redefined.  Fixes compilation issues with cygwin, and likely
+	  with newer versions of ncurses, fixes Savannah bug 28984 repoted by Andy Koppe
+          and Eric Oliver via mailing list.
+	* winio.c (get_mouseinput) - fix stray semicolon in code, also reported in
+	  bug 28984.
+
 GNU nano 2.2.3 - 2010.02.11
 2010-01-28 Chris Allegretta <chrisa@asty.org>
 	* move.c (do_page_up, do_page_down): Fix for smooth mode not preserving cusor 
diff --git a/configure.ac b/configure.ac
index 7f60a9b9..2dcb5bca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -569,6 +569,21 @@ int main(void)
     fi
 #fi
 
+AC_MSG_CHECKING([whether LINES and COLS can be redefined])
+AC_TRY_RUN([
+#include <curses.h>
+int main(void)
+{
+    LINES = 80;
+    COLS = 25;
+    return 0;
+}], 
+AC_DEFINE(REDEFINIG_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug])
+AC_MSG_RESULT(yes),
+AC_MSG_RESULT(no),
+AC_MSG_WARN([*** Can't check for macro redefinability when cross-compiling]))
+
+
 # Check for groff html support
 AC_MSG_CHECKING([for HTML support in groff])
 groff -t -mandoc -Thtml </dev/null >/dev/null
diff --git a/src/nano.c b/src/nano.c
index 3e085486..a6abd26d 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1263,8 +1263,10 @@ RETSIGTYPE handle_sigwinch(int signal)
      * otherwise.  However, COLS and LINES are curses global variables,
      * and in some cases curses has already updated them.  But not in
      * all cases.  Argh. */
+#ifdef REDEFINIG_MACROS_OK
     COLS = win.ws_col;
     LINES = win.ws_row;
+#endif
 
     /* If we've partitioned the filestruct, unpartition it now. */
     if (filepart != NULL)
diff --git a/src/winio.c b/src/winio.c
index 05e14960..918c0492 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -1746,7 +1746,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
 	     * wheel is equivalent to moving down three lines. */
 	    for (i = 0; i < 3; i++)
 		unget_kbinput((mevent.bstate & BUTTON4_PRESSED) ?
-			 sc_seq_or(do_up_void, 0) : sc_seq_or(DO_DOWN_VOID, 0);, FALSE,
+			 sc_seq_or(DO_UP_VOID, 0) : sc_seq_or(DO_DOWN_VOID, 0), FALSE,
 			FALSE);
 
 	    return 1;
-- 
GitLab