Remove building with NOCRYPTO option
[minix.git] / external / bsd / nvi / dist / ex / ex_delete.c
blob5f7f60b102a17c10faf6573d20364cb8e8a5f4cf
1 /* $NetBSD: ex_delete.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */
2 /*-
3 * Copyright (c) 1992, 1993, 1994
4 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1992, 1993, 1994, 1995, 1996
6 * Keith Bostic. All rights reserved.
8 * See the LICENSE file for redistribution information.
9 */
11 #include "config.h"
13 #include <sys/cdefs.h>
14 #if 0
15 #ifndef lint
16 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 ";
17 #endif /* not lint */
18 #else
19 __RCSID("$NetBSD: ex_delete.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
20 #endif
22 #include <sys/types.h>
23 #include <sys/queue.h>
25 #include <bitstring.h>
26 #include <limits.h>
27 #include <stdio.h>
29 #include "../common/common.h"
32 * ex_delete: [line [,line]] d[elete] [buffer] [count] [flags]
34 * Delete lines from the file.
36 * PUBLIC: int ex_delete __P((SCR *, EXCMD *));
38 int
39 ex_delete(SCR *sp, EXCMD *cmdp)
41 db_recno_t lno;
43 NEEDFILE(sp, cmdp);
46 * !!!
47 * Historically, lines deleted in ex were not placed in the numeric
48 * buffers. We follow historic practice so that we don't overwrite
49 * vi buffers accidentally.
51 if (cut(sp,
52 FL_ISSET(cmdp->iflags, E_C_BUFFER) ? &cmdp->buffer : NULL,
53 &cmdp->addr1, &cmdp->addr2, CUT_LINEMODE))
54 return (1);
56 /* Delete the lines. */
57 if (del(sp, &cmdp->addr1, &cmdp->addr2, 1))
58 return (1);
60 /* Set the cursor to the line after the last line deleted. */
61 sp->lno = cmdp->addr1.lno;
63 /* Or the last line in the file if deleted to the end of the file. */
64 if (db_last(sp, &lno))
65 return (1);
66 if (sp->lno > lno)
67 sp->lno = lno;
68 return (0);