summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkjell <kjell@openbsd.org>2006-06-01 09:45:05 +0000
committerkjell <kjell@openbsd.org>2006-06-01 09:45:05 +0000
commit38064268b4cebc02ab46bbe00e941c2547d0cf78 (patch)
tree6341985f1a09c8580aeaefbb17534effb85215e9
parentenable hardware RX checksum offload. (diff)
downloadwireguard-openbsd-38064268b4cebc02ab46bbe00e941c2547d0cf78.tar.xz
wireguard-openbsd-38064268b4cebc02ab46bbe00e941c2547d0cf78.zip
Fix message on empty goto-line. While here, lose a strlen and KNF.
-rw-r--r--usr.bin/mg/basic.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/mg/basic.c b/usr.bin/mg/basic.c
index 6093376eee6..023b88d7ee1 100644
--- a/usr.bin/mg/basic.c
+++ b/usr.bin/mg/basic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: basic.c,v 1.23 2006/06/01 09:00:50 kjell Exp $ */
+/* $OpenBSD: basic.c,v 1.24 2006/06/01 09:45:05 kjell Exp $ */
/* This file is in the public domain */
@@ -221,6 +221,8 @@ int
getgoal(struct line *dlp)
{
int c, i, col = 0;
+ char tmp[5];
+
for (i = 0; i < llength(dlp); i++) {
c = lgetc(dlp, i);
@@ -236,10 +238,7 @@ getgoal(struct line *dlp)
} else if (isprint(c))
col++;
else {
- char tmp[5];
-
- snprintf(tmp, sizeof(tmp), "\\%o", c);
- col += strlen(tmp);
+ col += snprintf(tmp, sizeof(tmp), "\\%o", c);
}
if (col > curgoal)
break;
@@ -449,6 +448,8 @@ gotoline(int f, int n)
if ((bufp = eread("Goto line: ", buf, sizeof(buf),
EFNUL | EFNEW | EFCR)) == NULL)
return (ABORT);
+ if (bufp[0] == '\0')
+ return (ABORT);
n = (int)strtonum(buf, INT_MIN, INT_MAX, &err);
if (err) {
ewprintf("Line number %s", err);