1 /* $NetBSD: ex_delete.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */
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.
13 #include <sys/cdefs.h>
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 ";
19 __RCSID("$NetBSD: ex_delete.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
22 #include <sys/types.h>
23 #include <sys/queue.h>
25 #include <bitstring.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 *));
39 ex_delete(SCR
*sp
, EXCMD
*cmdp
)
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.
52 FL_ISSET(cmdp
->iflags
, E_C_BUFFER
) ? &cmdp
->buffer
: NULL
,
53 &cmdp
->addr1
, &cmdp
->addr2
, CUT_LINEMODE
))
56 /* Delete the lines. */
57 if (del(sp
, &cmdp
->addr1
, &cmdp
->addr2
, 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
))