Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/vi/common Define ENTIRE_LINE to be -1 instead of 0 s...



details:   https://anonhg.NetBSD.org/src/rev/ff784891a903
branches:  trunk
changeset: 514715:ff784891a903
user:      aymeric <aymeric%NetBSD.org@localhost>
date:      Sun Sep 09 11:01:09 2001 +0000

description:
Define ENTIRE_LINE to be -1 instead of 0 since we may want to copy 0 characters.
(and use ENTIRE_LINE instead of 0 where appropriate)

This fixes a bug in the dw command with for example:

<cursor>
a b c

~
~
if you hit dw there, only the empty line would be killed but both the empty
line and the subsequent one would be pasted when asked for with P for example.

diffstat:

 usr.bin/vi/common/cut.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (38 lines):

diff -r 6af2f1cd81a0 -r ff784891a903 usr.bin/vi/common/cut.c
--- a/usr.bin/vi/common/cut.c   Sun Sep 09 11:00:59 2001 +0000
+++ b/usr.bin/vi/common/cut.c   Sun Sep 09 11:01:09 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cut.c,v 1.3 2001/03/31 11:37:45 aymeric Exp $  */
+/*     $NetBSD: cut.c,v 1.4 2001/09/09 11:01:09 aymeric Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993, 1994
@@ -138,16 +138,16 @@
        }
 
 
-#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 @@
         * 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;



Home | Main Index | Thread Index | Old Index