xref: /original-bsd/contrib/ed/c.c (revision a043e977)
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.2 (Berkeley) 01/23/93";
13 #endif /* not lint */
14 
15 #include <sys/types.h>
16 
17 #include <db.h>
18 #include <regex.h>
19 #include <setjmp.h>
20 #include <stdio.h>
21 
22 #include "ed.h"
23 #include "extern.h"
24 
25 /*
26  * This deletes the range of lines specified and then sets up things
27  * for the central input routine.
28  */
29 
30 void
31 c(inputt, errnum)
32 	FILE *inputt;
33 	int *errnum;
34 {
35 	if (start_default && End_default)
36 		start = End = current;
37 	else
38 		if (start_default)
39 			start = End;
40 	if (start == NULL) {
41 		*errnum = -1;
42 		return;
43 	}
44 	start_default = End_default = 0;
45 
46 	/* first delete the lines */
47 	d(inputt, errnum);
48 	if (*errnum < 0)
49 		return;
50 	*errnum = 0;
51 
52 	if ((current != NULL) && (current != bottom))
53 		current = current->above;
54 	if (sigint_flag)
55 		SIGINT_ACTION;
56 	add_flag = 1;
57 	start_default = End_default = 1;
58 	/* now get the "change" lines */
59 	input_lines(inputt, errnum);
60 	add_flag = 0;
61 }
62