update from Rodney Ruddock (rodney@snowhite.cis.uoguelph.ca)
[unix-history] / usr / src / contrib / ed / c.c
CommitLineData
5496c33f
KB
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
05ee7127 12static char sccsid[] = "@(#)c.c 5.5 (Berkeley) %G%";
5496c33f
KB
13#endif /* not lint */
14
ecbf4ad0
KB
15#include <sys/types.h>
16
ecbf4ad0
KB
17#include <regex.h>
18#include <setjmp.h>
19#include <stdio.h>
20
e692f66f
KB
21#ifdef DBI
22#include <db.h>
23#endif
24
5496c33f 25#include "ed.h"
ecbf4ad0 26#include "extern.h"
5496c33f
KB
27
28/*
29 * This deletes the range of lines specified and then sets up things
30 * for the central input routine.
31 */
32
33void
34c(inputt, errnum)
ecbf4ad0
KB
35 FILE *inputt;
36 int *errnum;
5496c33f 37{
05ee7127
KB
38 int l_flag=1;
39
035e94f8
RC
40 if (Start_default && End_default)
41 Start = End = current;
ecbf4ad0 42 else
035e94f8
RC
43 if (Start_default)
44 Start = End;
45 if (Start == NULL) {
ecbf4ad0
KB
46 *errnum = -1;
47 return;
48 }
035e94f8 49 Start_default = End_default = 0;
05ee7127
KB
50 if (End == bottom)
51 l_flag = 0;
ecbf4ad0
KB
52
53 /* first delete the lines */
54 d(inputt, errnum);
55 if (*errnum < 0)
56 return;
57 *errnum = 0;
58
05ee7127
KB
59 /*if ((current != NULL) && (current != bottom)) RMSR */
60 if ((current != NULL) && l_flag)
ecbf4ad0 61 current = current->above;
ecbf4ad0 62 add_flag = 1;
035e94f8 63 Start_default = End_default = 1;
ecbf4ad0
KB
64 /* now get the "change" lines */
65 input_lines(inputt, errnum);
66 add_flag = 0;
67}