| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: delete.c,v 1.3 2012/01/21 19:29:41 christos Exp $ */ | | 1 | /* $NetBSD: delete.c,v 1.4 2012/01/21 19:35:02 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 |
| @@ -55,27 +55,27 @@ del(SCR *sp, MARK *fm, MARK *tm, int lmo | | | @@ -55,27 +55,27 @@ del(SCR *sp, MARK *fm, MARK *tm, int lmo |
55 | goto done; | | 55 | goto done; |
56 | } | | 56 | } |
57 | | | 57 | |
58 | /* | | 58 | /* |
59 | * Case 2 -- delete to EOF. This is a special case because it's | | 59 | * Case 2 -- delete to EOF. This is a special case because it's |
60 | * easier to pick it off than try and find it in the other cases. | | 60 | * easier to pick it off than try and find it in the other cases. |
61 | */ | | 61 | */ |
62 | if (db_last(sp, &lno)) | | 62 | if (db_last(sp, &lno)) |
63 | return (1); | | 63 | return (1); |
64 | if (tm->lno >= lno) { | | 64 | if (tm->lno >= lno) { |
65 | if (tm->lno == lno) { | | 65 | if (tm->lno == lno) { |
66 | if (db_get(sp, lno, DBG_FATAL, &p, &len)) | | 66 | if (db_get(sp, lno, DBG_FATAL, &p, &len)) |
67 | return (1); | | 67 | return (1); |
68 | eof = tm->cno >= len ? 1 : 0; | | 68 | eof = tm->cno != -1 && tm->cno >= len ? 1 : 0; |
69 | } else | | 69 | } else |
70 | eof = 1; | | 70 | eof = 1; |
71 | if (eof) { | | 71 | if (eof) { |
72 | for (lno = tm->lno; lno > fm->lno; --lno) { | | 72 | for (lno = tm->lno; lno > fm->lno; --lno) { |
73 | if (db_delete(sp, lno)) | | 73 | if (db_delete(sp, lno)) |
74 | return (1); | | 74 | return (1); |
75 | ++sp->rptlines[L_DELETED]; | | 75 | ++sp->rptlines[L_DELETED]; |
76 | if (lno % | | 76 | if (lno % |
77 | INTERRUPT_CHECK == 0 && INTERRUPTED(sp)) | | 77 | INTERRUPT_CHECK == 0 && INTERRUPTED(sp)) |
78 | break; | | 78 | break; |
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); |