Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/vi Fix a cut_line() caller not using the right value...



details:   https://anonhg.NetBSD.org/src/rev/eaffd57ee007
branches:  trunk
changeset: 516294:eaffd57ee007
user:      aymeric <aymeric%NetBSD.org@localhost>
date:      Sat Oct 20 10:04:49 2001 +0000

description:
Fix a cut_line() caller not using the right value for (former) ENTIRE_LINE,
by defining the (newer) CUT_LINE_TO_EOL define in common/cut.h and using it
where due.

Bug reported on current-users by Masanori Kanaoka <kanaoka%ann.hi-ho.ne.jp@localhost>
diagnosed by Bang Jun-Young <bjy%mogua.org@localhost>,
quick-fixed by Robert Elz <kre%munnari.OZ.AU@localhost>.

diffstat:

 usr.bin/vi/common/cut.c |  15 +++++++--------
 usr.bin/vi/common/cut.h |   5 ++++-
 usr.bin/vi/ex/ex_move.c |   4 ++--
 3 files changed, 13 insertions(+), 11 deletions(-)

diffs (83 lines):

diff -r babb669e4a57 -r eaffd57ee007 usr.bin/vi/common/cut.c
--- a/usr.bin/vi/common/cut.c   Sat Oct 20 09:45:31 2001 +0000
+++ b/usr.bin/vi/common/cut.c   Sat Oct 20 10:04:49 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cut.c,v 1.4 2001/09/09 11:01:09 aymeric Exp $  */
+/*     $NetBSD: cut.c,v 1.5 2001/10/20 10:04:49 aymeric Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993, 1994
@@ -138,25 +138,24 @@
        }
 
 
-#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 @@
         * 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 -r babb669e4a57 -r eaffd57ee007 usr.bin/vi/common/cut.h
--- a/usr.bin/vi/common/cut.h   Sat Oct 20 09:45:31 2001 +0000
+++ b/usr.bin/vi/common/cut.h   Sat Oct 20 10:04:49 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cut.h,v 1.2 1998/01/09 08:06:34 perry Exp $    */
+/*     $NetBSD: cut.h,v 1.3 2001/10/20 10:04:49 aymeric Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -77,3 +77,6 @@
 #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 -r babb669e4a57 -r eaffd57ee007 usr.bin/vi/ex/ex_move.c
--- a/usr.bin/vi/ex/ex_move.c   Sat Oct 20 09:45:31 2001 +0000
+++ b/usr.bin/vi/ex/ex_move.c   Sat Oct 20 10:04:49 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ex_move.c,v 1.8 2001/03/31 11:37:50 aymeric Exp $      */
+/*     $NetBSD: ex_move.c,v 1.9 2001/10/20 10:04:50 aymeric Exp $      */
 
 /*-
  * Copyright (c) 1992, 1993, 1994
@@ -56,7 +56,7 @@
        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;
                }



Home | Main Index | Thread Index | Old Index