diff options
author | 2006-06-01 09:45:05 +0000 | |
---|---|---|
committer | 2006-06-01 09:45:05 +0000 | |
commit | 38064268b4cebc02ab46bbe00e941c2547d0cf78 (patch) | |
tree | 6341985f1a09c8580aeaefbb17534effb85215e9 | |
parent | enable hardware RX checksum offload. (diff) | |
download | wireguard-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.c | 11 |
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); |