diff options
author | Kjell Wooding <kjell@cvs.openbsd.org> | 2006-06-01 09:45:06 +0000 |
---|---|---|
committer | Kjell Wooding <kjell@cvs.openbsd.org> | 2006-06-01 09:45:06 +0000 |
commit | 666ea0d423dcccd14c4c2a67eba8293a623e9a67 (patch) | |
tree | e2ea9e5969da57aa1476ea508e0aa3ebcedf4be1 | |
parent | 08d2419132728f71b6a4fe1925be6ef9d7f0c0e2 (diff) |
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); |