xref: /original-bsd/contrib/ed/f.c (revision 4670e840)
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
12 static char sccsid[] = "@(#)f.c	5.3 (Berkeley) 02/28/93";
13 #endif /* not lint */
14 
15 #include <sys/types.h>
16 
17 #include <regex.h>
18 #include <setjmp.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 
23 #ifdef DBI
24 #include <db.h>
25 #endif
26 
27 #include "ed.h"
28 #include "extern.h"
29 
30 /*
31  * Prints out or sets the remembered filename.
32  */
33 void
34 f(inputt, errnum)
35 	FILE *inputt;
36 	int *errnum;
37 {
38 	char *l_temp;
39 
40 	l_temp = filename(inputt, errnum);
41 	if (*errnum == 1) {
42 		sigspecial++;
43 		free(filename_current);
44 		filename_current = l_temp;
45 		sigspecial--;
46 		if (sigint_flag && (!sigspecial))
47 			SIGINT_ACTION;
48 	} else
49 		if (*errnum == -2)
50 			while (((ss = getc(inputt)) != '\n') || (ss == EOF));
51 		else
52 			if (*errnum < 0)
53 				return;
54 	if (filename_current)
55 		fwrite(filename_current,
56 		    sizeof(char), strlen(filename_current), stdout);
57 	putchar('\n');
58 	*errnum = 1;
59 }
60