diff options
author | anton <anton@cvs.openbsd.org> | 2017-07-20 08:37:49 +0000 |
---|---|---|
committer | anton <anton@cvs.openbsd.org> | 2017-07-20 08:37:49 +0000 |
commit | 7d21556ed58bb30b6cfd980810e56c2cd8062875 (patch) | |
tree | 66b42d4fcdbbfff5e4d2d46c6188cc11c88f88f0 /usr.bin/vi/cl | |
parent | 1ec1490f31ce53085da033355a2ad4638f264b92 (diff) |
Replace usage of strtol() with strtonum().
ok bentley@ deraadt@ millert@ tb@
Diffstat (limited to 'usr.bin/vi/cl')
-rw-r--r-- | usr.bin/vi/cl/cl_term.c | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/usr.bin/vi/cl/cl_term.c b/usr.bin/vi/cl/cl_term.c index 4551389f394..c8b13f77fde 100644 --- a/usr.bin/vi/cl/cl_term.c +++ b/usr.bin/vi/cl/cl_term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cl_term.c,v 1.27 2016/12/18 06:11:23 krw Exp $ */ +/* $OpenBSD: cl_term.c,v 1.28 2017/07/20 08:37:48 anton Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -18,7 +18,6 @@ #include <bitstring.h> #include <curses.h> -#include <errno.h> #include <limits.h> #include <signal.h> #include <stdio.h> @@ -301,8 +300,7 @@ cl_ssize(SCR *sp, int sigwinch, size_t *rowp, size_t *colp, int *changedp) struct winsize win; size_t col, row; int rval; - long lval; - char *p, *ep; + char *p; /* Assume it's changed. */ if (changedp != NULL) @@ -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; |