STDIO fix
[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
e692f66f 12static char sccsid[] = "@(#)c.c 5.3 (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{
ecbf4ad0
KB
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;
ecbf4ad0
KB
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}