patch 8.0.0769: build problems with terminal on MS-Windows
Problem: Build problems with terminal on MS-Windows using MSVC.
Solution: Remove stdbool.h dependency. Only use ScreenLinesUC when it was
allocated. Fix typos. (Ken Takata)
diff --git a/src/libvterm/bin/vterm-ctrl.c b/src/libvterm/bin/vterm-ctrl.c
index 14e35cd..2568ee6 100644
--- a/src/libvterm/bin/vterm-ctrl.c
+++ b/src/libvterm/bin/vterm-ctrl.c
@@ -1,10 +1,11 @@
#define _XOPEN_SOURCE 500 /* strdup */
-#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define streq(a,b) (strcmp(a,b)==0)
+#define TRUE 1
+#define FALSE 0
#include <termios.h>
@@ -60,13 +61,14 @@
NULL
};
-static bool seticanon(bool icanon, bool echo)
+static int seticanon(int icanon, int echo)
{
struct termios termios;
+ int ret;
tcgetattr(0, &termios);
- bool ret = (termios.c_lflag & ICANON);
+ ret = (termios.c_lflag & ICANON);
if(icanon) termios.c_lflag |= ICANON;
else termios.c_lflag &= ~ICANON;
@@ -84,16 +86,16 @@
int c;
/* await CSI - 8bit or 2byte 7bit form */
- bool in_esc = false;
+ int in_esc = FALSE;
while((c = getchar())) {
if(c == c1)
break;
if(in_esc && c == (char)(c1 - 0x40))
break;
if(!in_esc && c == 0x1b)
- in_esc = true;
+ in_esc = TRUE;
else
- in_esc = false;
+ in_esc = FALSE;
}
}
@@ -121,7 +123,7 @@
static char *read_dcs()
{
unsigned char dcs[32];
- bool in_esc = false;
+ int in_esc = FALSE;
int i;
await_c1(0x90);
@@ -133,10 +135,10 @@
if(in_esc && c == 0x5c)
break;
if(!in_esc && c == 0x1b)
- in_esc = true;
+ in_esc = TRUE;
else {
dcs[i++] = c;
- in_esc = false;
+ in_esc = FALSE;
}
}
dcs[++i] = 0;
@@ -158,7 +160,7 @@
exit(exitcode);
}
-static bool query_dec_mode(int mode)
+static int query_dec_mode(int mode)
{
char *s = NULL;
@@ -189,12 +191,12 @@
free(s);
if(reply_value == 1 || reply_value == 3)
- return true;
+ return TRUE;
if(reply_value == 2 || reply_value == 4)
- return false;
+ return FALSE;
printf("Unrecognised reply to DECRQM: %d\n", reply_value);
- return false;
+ return FALSE;
} while(1);
}
@@ -247,11 +249,11 @@
} while(1);
}
-bool wasicanon;
+int wasicanon;
void restoreicanon(void)
{
- seticanon(wasicanon, true);
+ seticanon(wasicanon, TRUE);
}
int main(int argc, char *argv[])
@@ -261,7 +263,7 @@
if(argc == 1)
usage(0);
- wasicanon = seticanon(false, false);
+ wasicanon = seticanon(FALSE, FALSE);
atexit(restoreicanon);
while(argi < argc) {