Hi,
Fairly straightforward, replace usage of strtol with strtonum.
No intended functional change.

Comments? OK?

Index: cl/cl_term.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/cl/cl_term.c,v
retrieving revision 1.27
diff -u -p -r1.27 cl_term.c
--- cl/cl_term.c        18 Dec 2016 06:11:23 -0000      1.27
+++ cl/cl_term.c        19 Jul 2017 19:44:03 -0000
@@ -18,7 +18,6 @@
 
 #include <bitstring.h>
 #include <curses.h>
-#include <errno.h>
 #include <limits.h>
 #include <signal.h>
 #include <stdio.h>
@@ -301,7 +300,6 @@ cl_ssize(SCR *sp, int sigwinch, size_t *
        struct winsize win;
        size_t col, row;
        int rval;
-       long lval;
        char *p, *ep;
 
        /* Assume it's changed. */
@@ -396,28 +394,12 @@ noterm:   if (row == 0)
         * deleting the LINES and COLUMNS environment variables from their
         * dot-files.
         */
-       if ((p = getenv("LINES")) != NULL) {
-               errno = 0;
-               lval = strtol(p, &ep, 10);
-               if (p[0] == '\0' || *ep != '\0')
-                       ;
-               else if ((errno == ERANGE && (lval == LONG_MAX || lval ==
-                   LONG_MIN)) || (lval > INT_MAX || lval < 1))
-                       ;
-               else
-                       row = lval;
-       }
-       if ((p = getenv("COLUMNS")) != NULL) {
-               errno = 0;
-               lval = strtol(p, &ep, 10);
-               if (p[0] == '\0' || *ep != '\0')
-                       ;
-               else if ((errno == ERANGE && (lval == LONG_MAX || lval ==
-                   LONG_MIN)) || (lval > INT_MAX || lval < 1))
-                       ;
-               else
-                       col = lval;
-       }
+       if ((p = getenv("LINES")) != NULL &&
+           (rval = strtonum(p, 1, INT_MAX, NULL)) > 0)
+               row = rval;
+       if ((p = getenv("COLUMNS")) != NULL &&
+           (rval = strtonum(p, 1, INT_MAX, NULL)) > 0)
+               col = rval;
 
        if (rowp != NULL)
                *rowp = row;

Reply via email to