PR/10367: Mason Loring Bliss: fix delete word near end of file. Patch from tnozaki.diff -r1.1.1.2 -r1.2 src/dist/nvi/common/delete.c
(christos)
--- src/dist/nvi/common/Attic/delete.c 2008/05/18 14:29:41 1.1.1.2
+++ src/dist/nvi/common/Attic/delete.c 2012/01/21 17:12:56 1.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: delete.c,v 1.1.1.2 2008/05/18 14:29:41 aymeric Exp $ */ | 1 | /* $NetBSD: delete.c,v 1.2 2012/01/21 17:12:56 christos Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1992, 1993, 1994 | 4 | * Copyright (c) 1992, 1993, 1994 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * Copyright (c) 1992, 1993, 1994, 1995, 1996 | 6 | * Copyright (c) 1992, 1993, 1994, 1995, 1996 | |
7 | * Keith Bostic. All rights reserved. | 7 | * Keith Bostic. All rights reserved. | |
8 | * | 8 | * | |
9 | * See the LICENSE file for redistribution information. | 9 | * See the LICENSE file for redistribution information. | |
10 | */ | 10 | */ | |
11 | 11 | |||
12 | #include "config.h" | 12 | #include "config.h" | |
13 | 13 | |||
14 | #ifndef lint | 14 | #ifndef lint | |
@@ -79,26 +79,31 @@ del(SCR *sp, MARK *fm, MARK *tm, int lmo | @@ -79,26 +79,31 @@ del(SCR *sp, MARK *fm, MARK *tm, int lmo | |||
79 | } | 79 | } | |
80 | if (db_get(sp, fm->lno, DBG_FATAL, &p, &len)) | 80 | if (db_get(sp, fm->lno, DBG_FATAL, &p, &len)) | |
81 | return (1); | 81 | return (1); | |
82 | GET_SPACE_RETW(sp, bp, blen, fm->cno); | 82 | GET_SPACE_RETW(sp, bp, blen, fm->cno); | |
83 | MEMCPYW(bp, p, fm->cno); | 83 | MEMCPYW(bp, p, fm->cno); | |
84 | if (db_set(sp, fm->lno, bp, fm->cno)) | 84 | if (db_set(sp, fm->lno, bp, fm->cno)) | |
85 | return (1); | 85 | return (1); | |
86 | goto done; | 86 | goto done; | |
87 | } | 87 | } | |
88 | } | 88 | } | |
89 | 89 | |||
90 | /* Case 3 -- delete within a single line. */ | 90 | /* Case 3 -- delete within a single line. */ | |
91 | if (tm->lno == fm->lno) { | 91 | if (tm->lno == fm->lno) { | |
92 | if (tm->cno == fm->cno) { | |||
93 | if (db_delete(sp, fm->lno)) | |||
94 | return (1); | |||
95 | goto done; | |||
96 | } | |||
92 | if (db_get(sp, fm->lno, DBG_FATAL, &p, &len)) | 97 | if (db_get(sp, fm->lno, DBG_FATAL, &p, &len)) | |
93 | return (1); | 98 | return (1); | |
94 | GET_SPACE_RETW(sp, bp, blen, len); | 99 | GET_SPACE_RETW(sp, bp, blen, len); | |
95 | if (fm->cno != 0) | 100 | if (fm->cno != 0) | |
96 | MEMCPYW(bp, p, fm->cno); | 101 | MEMCPYW(bp, p, fm->cno); | |
97 | MEMCPYW(bp + fm->cno, p + (tm->cno + 1), | 102 | MEMCPYW(bp + fm->cno, p + (tm->cno + 1), | |
98 | len - (tm->cno + 1)); | 103 | len - (tm->cno + 1)); | |
99 | if (db_set(sp, fm->lno, | 104 | if (db_set(sp, fm->lno, | |
100 | bp, len - ((tm->cno - fm->cno) + 1))) | 105 | bp, len - ((tm->cno - fm->cno) + 1))) | |
101 | goto err; | 106 | goto err; | |
102 | goto done; | 107 | goto done; | |
103 | } | 108 | } | |
104 | 109 |
--- src/dist/nvi/vi/Attic/getc.c 2011/03/21 14:53:04 1.3
+++ src/dist/nvi/vi/Attic/getc.c 2012/01/21 17:12:56 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: getc.c,v 1.3 2011/03/21 14:53:04 tnozaki Exp $ */ | 1 | /* $NetBSD: getc.c,v 1.4 2012/01/21 17:12:56 christos Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1992, 1993, 1994 | 4 | * Copyright (c) 1992, 1993, 1994 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * Copyright (c) 1992, 1993, 1994, 1995, 1996 | 6 | * Copyright (c) 1992, 1993, 1994, 1995, 1996 | |
7 | * Keith Bostic. All rights reserved. | 7 | * Keith Bostic. All rights reserved. | |
8 | * | 8 | * | |
9 | * See the LICENSE file for redistribution information. | 9 | * See the LICENSE file for redistribution information. | |
10 | */ | 10 | */ | |
11 | 11 | |||
12 | #include "config.h" | 12 | #include "config.h" | |
13 | 13 | |||
14 | #ifndef lint | 14 | #ifndef lint | |
@@ -133,30 +133,32 @@ cs_fspace(SCR *sp, VCS *csp) | @@ -133,30 +133,32 @@ cs_fspace(SCR *sp, VCS *csp) | |||
133 | } | 133 | } | |
134 | return (0); | 134 | return (0); | |
135 | } | 135 | } | |
136 | 136 | |||
137 | /* | 137 | /* | |
138 | * cs_fblank -- | 138 | * cs_fblank -- | |
139 | * Eat forward to the next non-whitespace character. | 139 | * Eat forward to the next non-whitespace character. | |
140 | * | 140 | * | |
141 | * PUBLIC: int cs_fblank __P((SCR *, VCS *)); | 141 | * PUBLIC: int cs_fblank __P((SCR *, VCS *)); | |
142 | */ | 142 | */ | |
143 | int | 143 | int | |
144 | cs_fblank(SCR *sp, VCS *csp) | 144 | cs_fblank(SCR *sp, VCS *csp) | |
145 | { | 145 | { | |
146 | if (csp->cs_flags == CS_EMP) | |||
147 | return (0); | |||
146 | for (;;) { | 148 | for (;;) { | |
147 | if (cs_next(sp, csp)) | 149 | if (cs_next(sp, csp)) | |
148 | return (1); | 150 | return (1); | |
149 | if (csp->cs_flags == CS_EOL || csp->cs_flags == CS_EMP || | 151 | if (csp->cs_flags == CS_EOL || | |
150 | (csp->cs_flags == 0 && ISBLANK2(csp->cs_ch))) | 152 | (csp->cs_flags == 0 && ISBLANK2(csp->cs_ch))) | |
151 | continue; | 153 | continue; | |
152 | break; | 154 | break; | |
153 | } | 155 | } | |
154 | return (0); | 156 | return (0); | |
155 | } | 157 | } | |
156 | 158 | |||
157 | /* | 159 | /* | |
158 | * cs_prev -- | 160 | * cs_prev -- | |
159 | * Retrieve the previous character. | 161 | * Retrieve the previous character. | |
160 | * | 162 | * | |
161 | * PUBLIC: int cs_prev __P((SCR *, VCS *)); | 163 | * PUBLIC: int cs_prev __P((SCR *, VCS *)); | |
162 | */ | 164 | */ | |
@@ -202,23 +204,25 @@ cs_prev(SCR *sp, VCS *csp) | @@ -202,23 +204,25 @@ cs_prev(SCR *sp, VCS *csp) | |||
202 | } | 204 | } | |
203 | return (0); | 205 | return (0); | |
204 | } | 206 | } | |
205 | 207 | |||
206 | /* | 208 | /* | |
207 | * cs_bblank -- | 209 | * cs_bblank -- | |
208 | * Eat backward to the next non-whitespace character. | 210 | * Eat backward to the next non-whitespace character. | |
209 | * | 211 | * | |
210 | * PUBLIC: int cs_bblank __P((SCR *, VCS *)); | 212 | * PUBLIC: int cs_bblank __P((SCR *, VCS *)); | |
211 | */ | 213 | */ | |
212 | int | 214 | int | |
213 | cs_bblank(SCR *sp, VCS *csp) | 215 | cs_bblank(SCR *sp, VCS *csp) | |
214 | { | 216 | { | |
217 | if (csp->cs_flags == CS_EMP) | |||
218 | return (0); | |||
215 | for (;;) { | 219 | for (;;) { | |
216 | if (cs_prev(sp, csp)) | 220 | if (cs_prev(sp, csp)) | |
217 | return (1); | 221 | return (1); | |
218 | if (csp->cs_flags == CS_EOL || csp->cs_flags == CS_EMP || | 222 | if (csp->cs_flags == CS_EOL || | |
219 | (csp->cs_flags == 0 && ISBLANK2(csp->cs_ch))) | 223 | (csp->cs_flags == 0 && ISBLANK2(csp->cs_ch))) | |
220 | continue; | 224 | continue; | |
221 | break; | 225 | break; | |
222 | } | 226 | } | |
223 | return (0); | 227 | return (0); | |
224 | } | 228 | } |