xref: /csrg-svn/contrib/ed/c.c (revision 60663)
157678Sbostic /*-
2*60663Sbostic  * Copyright (c) 1992, 1993
3*60663Sbostic  *	The Regents of the University of California.  All rights reserved.
457678Sbostic  *
557678Sbostic  * This code is derived from software contributed to Berkeley by
657678Sbostic  * Rodney Ruddock of the University of Guelph.
757678Sbostic  *
857678Sbostic  * %sccs.include.redist.c%
957678Sbostic  */
1057678Sbostic 
1157678Sbostic #ifndef lint
12*60663Sbostic static char sccsid[] = "@(#)c.c	8.1 (Berkeley) 05/31/93";
1357678Sbostic #endif /* not lint */
1457678Sbostic 
1557710Sbostic #include <sys/types.h>
1657710Sbostic 
1757710Sbostic #include <regex.h>
1857710Sbostic #include <setjmp.h>
1957710Sbostic #include <stdio.h>
2057710Sbostic 
2158315Sbostic #ifdef DBI
2258315Sbostic #include <db.h>
2358315Sbostic #endif
2458315Sbostic 
2557678Sbostic #include "ed.h"
2657710Sbostic #include "extern.h"
2757678Sbostic 
2857678Sbostic /*
2957678Sbostic  * This deletes the range of lines specified and then sets up things
3057678Sbostic  * for the central input routine.
3157678Sbostic  */
3257678Sbostic 
3357678Sbostic void
c(inputt,errnum)3457678Sbostic c(inputt, errnum)
3557710Sbostic 	FILE *inputt;
3657710Sbostic 	int *errnum;
3757678Sbostic {
3859915Sbostic 	int l_flag=1;
3959915Sbostic 
4058564Sralph 	if (Start_default && End_default)
4158564Sralph 		Start = End = current;
4257710Sbostic 	else
4358564Sralph 		if (Start_default)
4458564Sralph 			Start = End;
4558564Sralph 	if (Start == NULL) {
4657710Sbostic 		*errnum = -1;
4757710Sbostic 		return;
4857710Sbostic 	}
4958564Sralph 	Start_default = End_default = 0;
5059915Sbostic 	if (End == bottom)
5159915Sbostic 		l_flag = 0;
5257678Sbostic 
5357710Sbostic 	/* first delete the lines */
5457710Sbostic 	d(inputt, errnum);
5557710Sbostic 	if (*errnum < 0)
5657710Sbostic 		return;
5757710Sbostic 	*errnum = 0;
5857678Sbostic 
5959915Sbostic 	/*if ((current != NULL) && (current != bottom)) RMSR */
6059915Sbostic 	if ((current != NULL) && l_flag)
6157710Sbostic 		current = current->above;
6257710Sbostic 	add_flag = 1;
6358564Sralph 	Start_default = End_default = 1;
6457710Sbostic 	/* now get the "change" lines */
6557710Sbostic 	input_lines(inputt, errnum);
6657710Sbostic 	add_flag = 0;
6757710Sbostic }
68