Project

General

Profile

Submit #2791 ยป patch-nvi.txt

dclink, 02/21/2015 10:29 AM

 
1
diff --git a/contrib/nvi/cl/cl_term.c b/contrib/nvi/cl/cl_term.c
2
index d851930..9514408 100644
3
--- a/contrib/nvi/cl/cl_term.c
4
+++ b/contrib/nvi/cl/cl_term.c
5
@@ -355,7 +355,7 @@ cl_ssize(SCR *sp, int sigwinch, size_t *rowp, size_t *colp, int *changedp)
6
 	struct winsize win;
7
 	size_t col, row;
8
 	int rval;
9
-	char *p;
10
+	char *p, *rowptr, *colptr;
11
 
12
 	/* Assume it's changed. */
13
 	if (changedp != NULL)
14
@@ -447,10 +447,16 @@ noterm:	if (row == 0)
15
 	 * deleting the LINES and COLUMNS environment variables from their
16
 	 * dot-files.
17
 	 */
18
-	if ((p = getenv("LINES")) != NULL)
19
-		row = strtol(p, NULL, 10);
20
-	if ((p = getenv("COLUMNS")) != NULL)
21
-		col = strtol(p, NULL, 10);
22
+	if ((p = getenv("LINES")) != NULL) {
23
+		row = strtol(p, &rowptr, 10);
24
+		if (rowptr != '\0' || errno != 0)
25
+			row = 24;
26
+	}
27
+	if ((p = getenv("COLUMNS")) != NULL) {
28
+		col = strtol(p, &colptr, 10);
29
+		if (colptr != '\0' || errno != 0)
30
+			col = 80;
31
+	}
32
 
33
 	if (rowp != NULL)
34
 		*rowp = row;
    (1-1/1)