Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / nvi / ex / ex_delete.c
blob6211b114c1910764086faa8d845ef9efb9ae61ff
1 /* $NetBSD$ */
3 /*-
4 * Copyright (c) 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 * Copyright (c) 1992, 1993, 1994, 1995, 1996
7 * Keith Bostic. All rights reserved.
9 * See the LICENSE file for redistribution information.
12 #include "config.h"
14 #ifndef lint
15 static const char sccsid[] = "Id: ex_delete.c,v 10.11 2001/06/25 15:19:15 skimo Exp (Berkeley) Date: 2001/06/25 15:19:15";
16 #endif /* not lint */
18 #include <sys/types.h>
19 #include <sys/queue.h>
21 #include <bitstring.h>
22 #include <limits.h>
23 #include <stdio.h>
25 #include "../common/common.h"
28 * ex_delete: [line [,line]] d[elete] [buffer] [count] [flags]
30 * Delete lines from the file.
32 * PUBLIC: int ex_delete __P((SCR *, EXCMD *));
34 int
35 ex_delete(SCR *sp, EXCMD *cmdp)
37 db_recno_t lno;
39 NEEDFILE(sp, cmdp);
42 * !!!
43 * Historically, lines deleted in ex were not placed in the numeric
44 * buffers. We follow historic practice so that we don't overwrite
45 * vi buffers accidentally.
47 if (cut(sp,
48 FL_ISSET(cmdp->iflags, E_C_BUFFER) ? &cmdp->buffer : NULL,
49 &cmdp->addr1, &cmdp->addr2, CUT_LINEMODE))
50 return (1);
52 /* Delete the lines. */
53 if (del(sp, &cmdp->addr1, &cmdp->addr2, 1))
54 return (1);
56 /* Set the cursor to the line after the last line deleted. */
57 sp->lno = cmdp->addr1.lno;
59 /* Or the last line in the file if deleted to the end of the file. */
60 if (db_last(sp, &lno))
61 return (1);
62 if (sp->lno > lno)
63 sp->lno = lno;
64 return (0);