diff options
-rw-r--r-- | usr.bin/vi/common/cut.c | 15 | ||||
-rw-r--r-- | usr.bin/vi/common/cut.h | 5 | ||||
-rw-r--r-- | usr.bin/vi/ex/ex_move.c | 4 |
3 files changed, 13 insertions, 11 deletions
diff --git a/usr.bin/vi/common/cut.c b/usr.bin/vi/common/cut.c index 2d4dd7c39e2..b952db5e334 100644 --- a/usr.bin/vi/common/cut.c +++ b/usr.bin/vi/common/cut.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cut.c,v 1.5 2001/09/19 02:43:19 pvalchev Exp $ */ +/* $OpenBSD: cut.c,v 1.6 2002/01/31 11:10:39 hugh Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -138,25 +138,24 @@ copyloop: } -#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, ENTIRE_LINE, cbp)) + if (cut_line(sp, lno, 0, CUT_LINE_TO_EOL, cbp)) goto cut_line_err; } else { /* - * Get the first line. A length of ENTIRE_LINE causes cut_line - * to cut from the MARK to the end of the line. + * Get the first line. A length of CUT_LINE_TO_EOL 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 ? - ENTIRE_LINE : (tm->cno - fm->cno) + 1, cbp)) + CUT_LINE_TO_EOL : (tm->cno - fm->cno) + 1, cbp)) goto cut_line_err; /* Get the intermediate lines. */ for (lno = fm->lno; ++lno < tm->lno;) - if (cut_line(sp, lno, 0, ENTIRE_LINE, cbp)) + if (cut_line(sp, lno, 0, CUT_LINE_TO_EOL, cbp)) goto cut_line_err; /* Get the last line. */ @@ -266,7 +265,7 @@ cut_line(sp, lno, fcno, clen, cbp) * copy the portion we want, and reset the TEXT length. */ if (len != 0) { - if (clen == ENTIRE_LINE) + if (clen == CUT_LINE_TO_EOL) clen = len - fcno; memcpy(tp->lb, p + fcno, clen); tp->len = clen; diff --git a/usr.bin/vi/common/cut.h b/usr.bin/vi/common/cut.h index bae99c3ba72..1202004193b 100644 --- a/usr.bin/vi/common/cut.h +++ b/usr.bin/vi/common/cut.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cut.h,v 1.3 2001/01/29 01:58:29 niklas Exp $ */ +/* $OpenBSD: cut.h,v 1.4 2002/01/31 11:10:39 hugh Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -77,3 +77,6 @@ struct _text { /* Text: a linked list of lines. */ #define CUT_LINEMODE 0x01 /* Cut in line mode. */ #define CUT_NUMOPT 0x02 /* Numeric buffer: optional. */ #define CUT_NUMREQ 0x04 /* Numeric buffer: required. */ + +/* Special length to cut_line(). */ +#define CUT_LINE_TO_EOL ((size_t) -1) /* Cut to the end of line. */ diff --git a/usr.bin/vi/ex/ex_move.c b/usr.bin/vi/ex/ex_move.c index 8205500ecdd..e4459599da6 100644 --- a/usr.bin/vi/ex/ex_move.c +++ b/usr.bin/vi/ex/ex_move.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_move.c,v 1.4 2001/01/29 01:58:43 niklas Exp $ */ +/* $OpenBSD: ex_move.c,v 1.5 2002/01/31 11:10:39 hugh Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -56,7 +56,7 @@ ex_copy(sp, cmdp) memset(&cb, 0, sizeof(cb)); CIRCLEQ_INIT(&cb.textq); for (cnt = fm1.lno; cnt <= fm2.lno; ++cnt) - if (cut_line(sp, cnt, 0, 0, &cb)) { + if (cut_line(sp, cnt, 0, CUT_LINE_TO_EOL, &cb)) { rval = 1; goto err; } |