diff options
author | Hakan Olsson <ho@cvs.openbsd.org> | 2002-03-10 13:22:57 +0000 |
---|---|---|
committer | Hakan Olsson <ho@cvs.openbsd.org> | 2002-03-10 13:22:57 +0000 |
commit | 9d543d408db7904749d0f95a1d0c011b7dbbdb77 (patch) | |
tree | f0b7b0916584f216ffd85636b80d1ed2beda8b3a /usr.bin | |
parent | e606444eb9a5c25ffe439dda663c3df1f28d5c5d (diff) |
Better long vs int. millert@ ok.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mg/basic.c | 13 | ||||
-rw-r--r-- | usr.bin/mg/extend.c | 12 |
2 files changed, 12 insertions, 13 deletions
diff --git a/usr.bin/mg/basic.c b/usr.bin/mg/basic.c index 3ace2ab8540..5040fa1403f 100644 --- a/usr.bin/mg/basic.c +++ b/usr.bin/mg/basic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: basic.c,v 1.10 2002/02/16 21:27:49 millert Exp $ */ +/* $OpenBSD: basic.c,v 1.11 2002/03/10 13:22:56 ho Exp $ */ /* * Basic cursor motion commands. @@ -459,24 +459,23 @@ gotoline(f, n) { LINE *clp; int s; - char buf[32]; + char buf[32], *tmp; + long nl; if (!(f & FFARG)) { - char *tmp; - if ((s = ereply("Goto line: ", buf, sizeof(buf))) != TRUE) return s; errno = 0; - n = strtol(buf, &tmp, 10); + nl = strtol(buf, &tmp, 10); if (buf[0] == '\0' || *tmp != '\0') { ewprintf("Invalid number"); return FALSE; } - if ((errno == ERANGE && (n == LONG_MAX || n == LONG_MIN)) || - (n > INT_MAX || n < INT_MIN)) { + if (nl >= INT_MAX || nl <= INT_MIN) { ewprintf("Out of range"); return FALSE; } + n = (int)nl; } if (n >= 0) { clp = lforw(curbp->b_linep); /* "clp" is first line */ diff --git a/usr.bin/mg/extend.c b/usr.bin/mg/extend.c index 12f7702170a..3c509c77fac 100644 --- a/usr.bin/mg/extend.c +++ b/usr.bin/mg/extend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: extend.c,v 1.21 2002/02/16 21:27:49 millert Exp $ */ +/* $OpenBSD: extend.c,v 1.22 2002/03/10 13:22:56 ho Exp $ */ /* * Extended (M-X) commands, rebinding, and startup file processing. @@ -686,8 +686,9 @@ excline(line) PF fp; LINE *lp, *np; int status, c, f, n; - char *funcp; + char *funcp, *tmp; char *argp = NULL; + long nl; #ifdef FKEYS int bind; KEYMAP *curmap; @@ -721,15 +722,14 @@ excline(line) } } if (argp != NULL) { - char *tmp; f = FFARG; errno = 0; - n = strtol(argp, &tmp, 10); + nl = strtol(argp, &tmp, 10); if (*tmp != '\0') return FALSE; - if ((errno == ERANGE && (n == LONG_MAX || n == LONG_MIN)) || - (n > INT_MAX || n < INT_MIN)) + if (nl >= INT_MAX || nl <= INT_MIN) return FALSE; + n = (int)nl; } if ((fp = name_function(funcp)) == NULL) { ewprintf("Unknown function: %s", funcp); |