update to 1.01
[nvi.git] / ex / ex_delete.c
blob017c16c73624108ccec5be7b076e1537d438eb7c
1 /*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
6 */
8 #ifndef lint
9 static char sccsid[] = "$Id: ex_delete.c,v 8.6 1994/01/11 22:18:38 bostic Exp $ (Berkeley) $Date: 1994/01/11 22:18:38 $";
10 #endif /* not lint */
12 #include <sys/types.h>
14 #include "vi.h"
15 #include "excmd.h"
18 * ex_delete: [line [,line]] d[elete] [buffer] [count] [flags]
20 * Delete lines from the file.
22 int
23 ex_delete(sp, ep, cmdp)
24 SCR *sp;
25 EXF *ep;
26 EXCMDARG *cmdp;
28 recno_t lno;
30 /* Yank the lines. */
31 if (cut(sp, ep, NULL, F_ISSET(cmdp, E_BUFFER) ? &cmdp->buffer : NULL,
32 &cmdp->addr1, &cmdp->addr2, CUT_DELETE | CUT_LINEMODE))
33 return (1);
35 /* Delete the lines. */
36 if (delete(sp, ep, &cmdp->addr1, &cmdp->addr2, 1))
37 return (1);
39 /* Set the cursor to the line after the last line deleted. */
40 sp->lno = cmdp->addr1.lno;
42 /* Or the last line in the file if deleted to the end of the file. */
43 if (file_lline(sp, ep, &lno))
44 return (1);
45 if (sp->lno > lno)
46 sp->lno = lno;
47 return (0);