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