xref: /original-bsd/contrib/ed/c.c (revision f66f3413)
1 /*-
2  * Copyright (c) 1992 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Rodney Ruddock of the University of Guelph.
7  *
8  * %sccs.include.redist.c%
9  */
10 
11 #ifndef lint
12 static char sccsid[] = "@(#)c.c	5.4 (Berkeley) 03/08/93";
13 #endif /* not lint */
14 
15 #include <sys/types.h>
16 
17 #include <regex.h>
18 #include <setjmp.h>
19 #include <stdio.h>
20 
21 #ifdef DBI
22 #include <db.h>
23 #endif
24 
25 #include "ed.h"
26 #include "extern.h"
27 
28 /*
29  * This deletes the range of lines specified and then sets up things
30  * for the central input routine.
31  */
32 
33 void
34 c(inputt, errnum)
35 	FILE *inputt;
36 	int *errnum;
37 {
38 	if (Start_default && End_default)
39 		Start = End = current;
40 	else
41 		if (Start_default)
42 			Start = End;
43 	if (Start == NULL) {
44 		*errnum = -1;
45 		return;
46 	}
47 	Start_default = End_default = 0;
48 
49 	/* first delete the lines */
50 	d(inputt, errnum);
51 	if (*errnum < 0)
52 		return;
53 	*errnum = 0;
54 
55 	if ((current != NULL) && (current != bottom))
56 		current = current->above;
57 	add_flag = 1;
58 	Start_default = End_default = 1;
59 	/* now get the "change" lines */
60 	input_lines(inputt, errnum);
61 	add_flag = 0;
62 }
63