diff options
author | Peter Valchev <pvalchev@cvs.openbsd.org> | 2001-09-19 02:43:20 +0000 |
---|---|---|
committer | Peter Valchev <pvalchev@cvs.openbsd.org> | 2001-09-19 02:43:20 +0000 |
commit | a184eec4ec22fc5b964da531ae7b82409a54d1db (patch) | |
tree | 98fd36f3e01d52081177dd6a38b8572d0032ba48 /usr.bin | |
parent | 79b60428c53c4b0ef3595ae6e8310d72be71f530 (diff) |
Define ENTIRE_LINE to be -1 instead of 0 because we may want to copy 0 characters,
and use ENTIRE_LINE instead of hardcoding 0 in a few places. Fixes a bug when
dw on an empty line would delete only the empty line, but copy the next line too.
From NetBSD, ok millert
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/vi/common/cut.c | 10 | ||||
-rw-r--r-- | usr.bin/vi/common/delete.c | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/usr.bin/vi/common/cut.c b/usr.bin/vi/common/cut.c index 81a14b6f842..2d4dd7c39e2 100644 --- a/usr.bin/vi/common/cut.c +++ b/usr.bin/vi/common/cut.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cut.c,v 1.4 2001/01/29 01:58:28 niklas Exp $ */ +/* $OpenBSD: cut.c,v 1.5 2001/09/19 02:43:19 pvalchev Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -138,16 +138,16 @@ copyloop: } -#define ENTIRE_LINE 0 +#define ENTIRE_LINE -1 /* In line mode, it's pretty easy, just cut the lines. */ if (LF_ISSET(CUT_LINEMODE)) { cbp->flags |= CB_LMODE; for (lno = fm->lno; lno <= tm->lno; ++lno) - if (cut_line(sp, lno, 0, 0, cbp)) + if (cut_line(sp, lno, 0, ENTIRE_LINE, cbp)) goto cut_line_err; } else { /* - * Get the first line. A length of 0 causes cut_line + * Get the first line. A length of ENTIRE_LINE causes cut_line * to cut from the MARK to the end of the line. */ if (cut_line(sp, fm->lno, fm->cno, fm->lno != tm->lno ? @@ -266,7 +266,7 @@ cut_line(sp, lno, fcno, clen, cbp) * copy the portion we want, and reset the TEXT length. */ if (len != 0) { - if (clen == 0) + if (clen == ENTIRE_LINE) clen = len - fcno; memcpy(tp->lb, p + fcno, clen); tp->len = clen; diff --git a/usr.bin/vi/common/delete.c b/usr.bin/vi/common/delete.c index 399594e58cc..7d8f808e736 100644 --- a/usr.bin/vi/common/delete.c +++ b/usr.bin/vi/common/delete.c @@ -1,4 +1,4 @@ -/* $OpenBSD: delete.c,v 1.5 2001/01/29 01:58:29 niklas Exp $ */ +/* $OpenBSD: delete.c,v 1.6 2001/09/19 02:43:19 pvalchev Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -68,7 +68,7 @@ del(sp, fm, tm, lmode) if (tm->lno == lno) { if (db_get(sp, lno, DBG_FATAL, &p, &len)) return (1); - eof = tm->cno >= len ? 1 : 0; + eof = tm->cno != -1 && tm->cno >= len ? 1 : 0; } else eof = 1; if (eof) { |