Upstreamed in 18f51bcf99101e5bf4c737239c44064227f34db8

ncurses 6.2 - patch 20200229

From 5cb87b2244c1e944e13478b7bb98d0984b7dfdf7 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <anonymous.maarten@gmail.com>
Date: Tue, 17 Mar 2020 15:25:57 +0100
Subject: [PATCH 04/15] fix win32con
---
 ncurses/win32con/gettimeofday.c |  4 ++++
 ncurses/win32con/win_driver.c   | 14 +++++++-------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/ncurses/win32con/gettimeofday.c b/ncurses/win32con/gettimeofday.c
index 8fad9a62..319937c6 100644
--- a/ncurses/win32con/gettimeofday.c
+++ b/ncurses/win32con/gettimeofday.c
@@ -40,6 +40,10 @@ MODULE_ID("$Id: gettimeofday.c,v 1.4 2020/02/02 23:34:34 tom Exp $")
 
 #define JAN1970 116444736000000000LL	/* the value for 01/01/1970 00:00 */
 
+#ifdef _MSC_VER
+#include <winsock2.h>
+#endif
+
 int
 gettimeofday(struct timeval *tv, void *tz GCC_UNUSED)
 {
diff --git a/ncurses/win32con/win_driver.c b/ncurses/win32con/win_driver.c
index 280aa6dc..1bd45bb7 100644
--- a/ncurses/win32con/win_driver.c
+++ b/ncurses/win32con/win_driver.c
@@ -58,7 +58,7 @@
 MODULE_ID("$Id: win_driver.c,v 1.63 2020/02/02 23:34:34 tom Exp $")
 
 #ifndef __GNUC__
-#  error We need GCC to compile for MinGW
+//#  error We need GCC to compile for MinGW
 #endif
 
 #define WINMAGIC NCDRV_MAGIC(NCDRV_WINCONSOLE)
@@ -262,7 +262,7 @@ static BOOL
 con_write16(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, cchar_t *str, int limit)
 {
     int actual = 0;
-    CHAR_INFO ci[limit];
+    CHAR_INFO * ci = (CHAR_INFO*) _alloca(sizeof(CHAR_INFO) * limit);
     COORD loc, siz;
     SMALL_RECT rec;
     int i;
@@ -311,7 +311,7 @@ con_write16(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, cchar_t *str, int limit)
 static BOOL
 con_write8(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, chtype *str, int n)
 {
-    CHAR_INFO ci[n];
+    CHAR_INFO * ci = (CHAR_INFO*) _alloca(sizeof(CHAR_INFO) * n);
     COORD loc, siz;
     SMALL_RECT rec;
     int i;
@@ -510,7 +510,7 @@ wcon_doupdate(TERMINAL_CONTROL_BLOCK * TCB)
 	if ((CurScreen(sp)->_clear || NewScreen(sp)->_clear)) {
 	    int x;
 #if USE_WIDEC_SUPPORT
-	    cchar_t empty[Width];
+	    cchar_t * empty = (cchar_t*) _alloca(sizeof(cchar_t) * Width);
 	    wchar_t blank[2] =
 	    {
 		L' ', L'\0'
@@ -519,7 +519,7 @@ wcon_doupdate(TERMINAL_CONTROL_BLOCK * TCB)
 	    for (x = 0; x < Width; x++)
 		setcchar(&empty[x], blank, 0, 0, 0);
 #else
-	    chtype empty[Width];
+        chtype * empty = (chtype*) _alloca(sizeof(chtype) * Width);
 
 	    for (x = 0; x < Width; x++)
 		empty[x] = ' ';
@@ -675,8 +675,8 @@ wcon_dobeepflash(TERMINAL_CONTROL_BLOCK * TCB,
     int max_cells = (high * wide);
     int i;
 
-    CHAR_INFO this_screen[max_cells];
-    CHAR_INFO that_screen[max_cells];
+    CHAR_INFO * this_screen = (CHAR_INFO*) _alloca(sizeof(CHAR_INFO) * max_cells);
+    CHAR_INFO * that_screen = (CHAR_INFO*) _alloca(sizeof(CHAR_INFO) * max_cells);
     COORD this_size;
     SMALL_RECT this_region;
     COORD bufferCoord;
-- 
2.21.1

