xref: /csrg-svn/contrib/ed/i.c (revision 57710)
157688Sbostic /*-
257688Sbostic  * Copyright (c) 1992 The Regents of the University of California.
357688Sbostic  * All rights reserved.
457688Sbostic  *
557688Sbostic  * This code is derived from software contributed to Berkeley by
657688Sbostic  * Rodney Ruddock of the University of Guelph.
757688Sbostic  *
857688Sbostic  * %sccs.include.redist.c%
957688Sbostic  */
1057688Sbostic 
1157688Sbostic #ifndef lint
12*57710Sbostic static char sccsid[] = "@(#)i.c	5.2 (Berkeley) 01/23/93";
1357688Sbostic #endif /* not lint */
1457688Sbostic 
15*57710Sbostic #include <sys/types.h>
16*57710Sbostic 
17*57710Sbostic #include <db.h>
18*57710Sbostic #include <regex.h>
19*57710Sbostic #include <setjmp.h>
20*57710Sbostic #include <stdio.h>
21*57710Sbostic #include <string.h>
22*57710Sbostic 
2357688Sbostic #include "ed.h"
24*57710Sbostic #include "extern.h"
2557688Sbostic 
2657688Sbostic /*
2757688Sbostic  * Set things up for the central input routine to correctly place
2857688Sbostic  * the text as per the insert command.
2957688Sbostic  */
3057688Sbostic void
3157688Sbostic i(inputt, errnum)
32*57710Sbostic 	FILE *inputt;
33*57710Sbostic 	int *errnum;
3457688Sbostic {
3557688Sbostic #ifdef POSIX
36*57710Sbostic 	LINE *l_address;
3757688Sbostic #endif
3857688Sbostic 
39*57710Sbostic 	if ((End_default == 1) && (current != NULL))
40*57710Sbostic 		start = End = current->above;
41*57710Sbostic 	else {
42*57710Sbostic 		if (End == NULL) {
43*57710Sbostic 			strcpy(help_msg, "illegal address for command i");
44*57710Sbostic 			*errnum = -1;
45*57710Sbostic 			return;
46*57710Sbostic 		} else
47*57710Sbostic 			End = End->above;
48*57710Sbostic 	}
49*57710Sbostic 	start_default = End_default = 0;
5057688Sbostic #ifdef POSIX
51*57710Sbostic 	l_address = End;
5257688Sbostic #endif
5357688Sbostic 
54*57710Sbostic 	if (sigint_flag)
55*57710Sbostic 		SIGINT_ACTION;
56*57710Sbostic 	/*
57*57710Sbostic 	 * 'i' is just a variation on 'a': completely true with BSD; with
58*57710Sbostic 	 * POSIX we have to fake the location of "current" in a special case.
59*57710Sbostic 	 */
60*57710Sbostic 	a(inputt, errnum);
6157688Sbostic #ifdef POSIX
62*57710Sbostic 	if (l_address->above)
63*57710Sbostic 		current = l_address->below;
6457688Sbostic #endif
65*57710Sbostic }
66