[master] 945d2e1 Switch to 'ansi.sys' terminal type, that seems the lowest common denomintor.

Poul-Henning Kamp phk at FreeBSD.org
Fri Jan 12 17:55:07 UTC 2018


commit 945d2e1ea50f52fde10f9b31d55031c58ffc88d8
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Jan 12 17:54:21 2018 +0000

    Switch to 'ansi.sys' terminal type, that seems the lowest common denomintor.

diff --git a/bin/varnishtest/tests/u00009.vtc b/bin/varnishtest/tests/u00009.vtc
index 13b931c..89e6ea7 100644
--- a/bin/varnishtest/tests/u00009.vtc
+++ b/bin/varnishtest/tests/u00009.vtc
@@ -18,4 +18,4 @@ client c1 {
 	rxresp
 } -run
 
-process p1 -need-bytes 300 -screen_dump -write {q} -wait
+process p1 -need-bytes 200 -screen_dump -write {q} -wait
diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c
index 6a2a476..4b90c2f 100644
--- a/bin/varnishtest/vtc.c
+++ b/bin/varnishtest/vtc.c
@@ -727,14 +727,14 @@ test_term(struct vtclog *vl)
 	FILE *p;
 	int a, b;
 
-	p = popen("tput -T ansi clear 2>&1", "r");
+	p = popen("tput -T ansi.sys clear 2>&1", "r");
 	if (p == NULL)
 		return (0);
 	a = fgetc(p);
 	b = fgetc(p);
 	if (a == 0x1b && b == '[')
 		return (1);
-	vtc_log(vl, 3, "No 'ansi' terminfo entry.");
+	vtc_log(vl, 3, "No 'ansi.sys' terminfo entry.");
 	return (0);
 }
 
diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c
index 24e3e74..0325b94 100644
--- a/bin/varnishtest/vtc_process.c
+++ b/bin/varnishtest/vtc_process.c
@@ -406,7 +406,7 @@ process_start(struct process *p)
 	p->pid = fork();
 	assert(p->pid >= 0);
 	if (p->pid == 0) {
-		AZ(setenv("TERM", "ansi", 1));
+		AZ(setenv("TERM", "ansi.sys", 1));
 		AZ(unsetenv("TERMCAP"));
 		assert(dup2(slave, STDIN_FILENO) == STDIN_FILENO);
 		assert(dup2(slave, STDOUT_FILENO) == STDOUT_FILENO);
diff --git a/bin/varnishtest/vtc_term.c b/bin/varnishtest/vtc_term.c
index 34caa30..6b89a03 100644
--- a/bin/varnishtest/vtc_term.c
+++ b/bin/varnishtest/vtc_term.c
@@ -63,6 +63,19 @@ term_clear(const struct term *tp)
 	}
 }
 
+static void
+term_scroll(const struct term *tp)
+{
+	int i;
+	char *l;
+
+	l = tp->vram[0];
+	for(i = 0; i < tp->nlin -1; i++)
+		tp->vram[i] = tp->vram[i + 1];
+	tp->vram[i] = l;
+	memset(l, ' ', tp->ncol);
+}
+
 void
 Term_Dump(const struct term *tp)
 {
@@ -77,23 +90,38 @@ term_escape(struct term *tp, int c, int n)
 {
 	int i;
 
-	c = tolower(c);
 	for (i = 0; i < NTERMARG; i++)
 		if (!tp->arg[i])
 			tp->arg[i] = 1;
 	switch(c) {
+	case 'B':
+		if (tp->arg[0] > tp->nlin)
+			vtc_fatal(tp->vl, "ANSI B[%d] outside vram",
+			    tp->arg[0]);
+		tp->line += tp->arg[0];
+		while (tp->line >= tp->nlin) {
+			term_scroll(tp);
+			tp->line--;
+		}
+		break;
 	case 'h':
+		// Ignore screen mode selection
+		break;
+	case 'H':
 		if (tp->arg[0] > tp->nlin || tp->arg[1] > tp->ncol)
 			vtc_fatal(tp->vl, "ANSI H[%d,%d] outside vram",
 			    tp->arg[0], tp->arg[1]);
 		tp->line = tp->arg[0] - 1;
 		tp->col = tp->arg[1] - 1;
 		break;
-	case 'j':
+	case 'J':
 		if (tp->arg[0] != 2)
 			vtc_fatal(tp->vl, "ANSI J[%d]", tp->arg[0]);
 		term_clear(tp);
 		break;
+	case 'm':
+		// Ignore Graphic Rendition settings
+		break;
 	default:
 		for (i = 0; i < n; i++)
 			vtc_log(tp->vl, 4, "ANSI arg %d", tp->arg[i]);
@@ -103,19 +131,6 @@ term_escape(struct term *tp, int c, int n)
 }
 
 static void
-term_scroll(const struct term *tp)
-{
-	int i;
-	char *l;
-
-	l = tp->vram[0];
-	for(i = 0; i < tp->nlin -1; i++)
-		tp->vram[i] = tp->vram[i + 1];
-	tp->vram[i] = l;
-	memset(l, ' ', tp->ncol);
-}
-
-static void
 term_char(struct term *tp, char c)
 {
 	assert(tp->col < tp->ncol);
@@ -186,6 +201,8 @@ Term_Feed(struct term *tp, const char *b, const char *e)
 			tp->argp = tp->arg;
 			memset(tp->arg, 0, sizeof tp->arg);
 			tp->state = 3;
+			if (*b == '?')
+				b++;
 			break;
 		case 3:
 			if (tp->argp - tp->arg >= NTERMARG)
@@ -202,17 +219,8 @@ Term_Feed(struct term *tp, const char *b, const char *e)
 				b++;
 				continue;
 			}
-			if (islower(*b)) {
-				term_escape(tp, *b++, tp->argp -  tp->arg);
-				tp->state = 2;
-			} else if (isupper(*b)) {
-				term_escape(tp, *b++, tp->argp -  tp->arg);
-				tp->argp = tp->arg;
-				tp->state = 0;
-			} else {
-				vtc_fatal(tp->vl, "ANSI non-letter (0x%02x)",
-				    *b & 0xff);
-			}
+			term_escape(tp, *b++, tp->argp -  tp->arg);
+			tp->state = 0;
 			break;
 		default:
 			WRONG("Wrong ansi state");


More information about the varnish-commit mailing list