Project

General

Profile

Submit #2791 ยป patch-nvi.txt

dclink, 02/21/2015 10:29 AM

 
diff --git a/contrib/nvi/cl/cl_term.c b/contrib/nvi/cl/cl_term.c
index d851930..9514408 100644
--- a/contrib/nvi/cl/cl_term.c
+++ b/contrib/nvi/cl/cl_term.c
@@ -355,7 +355,7 @@ cl_ssize(SCR *sp, int sigwinch, size_t *rowp, size_t *colp, int *changedp)
struct winsize win;
size_t col, row;
int rval;
- char *p;
+ char *p, *rowptr, *colptr;
/* Assume it's changed. */
if (changedp != NULL)
@@ -447,10 +447,16 @@ noterm: if (row == 0)
* deleting the LINES and COLUMNS environment variables from their
* dot-files.
*/
- if ((p = getenv("LINES")) != NULL)
- row = strtol(p, NULL, 10);
- if ((p = getenv("COLUMNS")) != NULL)
- col = strtol(p, NULL, 10);
+ if ((p = getenv("LINES")) != NULL) {
+ row = strtol(p, &rowptr, 10);
+ if (rowptr != '\0' || errno != 0)
+ row = 24;
+ }
+ if ((p = getenv("COLUMNS")) != NULL) {
+ col = strtol(p, &colptr, 10);
+ if (colptr != '\0' || errno != 0)
+ col = 80;
+ }
if (rowp != NULL)
*rowp = row;
    (1-1/1)