xref: /csrg-svn/contrib/ed/i.c (revision 60663)
157688Sbostic /*-
2*60663Sbostic  * Copyright (c) 1992, 1993
3*60663Sbostic  *	The Regents of the University of California.  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*60663Sbostic static char sccsid[] = "@(#)i.c	8.1 (Berkeley) 05/31/93";
1357688Sbostic #endif /* not lint */
1457688Sbostic 
1557710Sbostic #include <sys/types.h>
1657710Sbostic 
1757710Sbostic #include <regex.h>
1857710Sbostic #include <setjmp.h>
1957710Sbostic #include <stdio.h>
2057710Sbostic #include <string.h>
2157710Sbostic 
2258315Sbostic #ifdef DBI
2358315Sbostic #include <db.h>
2458315Sbostic #endif
2558315Sbostic 
2657688Sbostic #include "ed.h"
2757710Sbostic #include "extern.h"
2857688Sbostic 
2957688Sbostic /*
3057688Sbostic  * Set things up for the central input routine to correctly place
3157688Sbostic  * the text as per the insert command.
3257688Sbostic  */
3357688Sbostic void
i(inputt,errnum)3457688Sbostic i(inputt, errnum)
3557710Sbostic 	FILE *inputt;
3657710Sbostic 	int *errnum;
3757688Sbostic {
3857688Sbostic #ifdef POSIX
3957710Sbostic 	LINE *l_address;
4057688Sbostic #endif
4157688Sbostic 
4257710Sbostic 	if ((End_default == 1) && (current != NULL))
4358564Sralph 		Start = End = current->above;
4457710Sbostic 	else {
4557710Sbostic 		if (End == NULL) {
4657710Sbostic 			strcpy(help_msg, "illegal address for command i");
4757710Sbostic 			*errnum = -1;
4857710Sbostic 			return;
4957710Sbostic 		} else
5057710Sbostic 			End = End->above;
5157710Sbostic 	}
5258564Sralph 	Start_default = End_default = 0;
5357688Sbostic #ifdef POSIX
5457710Sbostic 	l_address = End;
5557688Sbostic #endif
5657688Sbostic 
5757710Sbostic 	/*
5857710Sbostic 	 * 'i' is just a variation on 'a': completely true with BSD; with
5957710Sbostic 	 * POSIX we have to fake the location of "current" in a special case.
6057710Sbostic 	 */
6157710Sbostic 	a(inputt, errnum);
6257688Sbostic #ifdef POSIX
6357710Sbostic 	if (l_address->above)
6457710Sbostic 		current = l_address->below;
6557688Sbostic #endif
6657710Sbostic }
67