xref: /titanic_44/usr/src/cmd/refer/refer8.c (revision b7f45089ccbe01bab3d7c7377b49d80d2ae18a69)
1 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
2 /*	  All Rights Reserved  	*/
3 
4 
5 /*
6  * Copyright (c) 1980 Regents of the University of California.
7  * All rights reserved. The Berkeley software License Agreement
8  * specifies the terms and conditions for redistribution.
9  */
10 
11 /*
12  * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc.
13  * All Rights Reserved.
14  */
15 
16 #pragma ident	"%Z%%M%	%I%	%E% SMI"
17 
18 #include "refer..c"
19 
20 static char ahead[1024];
21 static int peeked = 0;
22 static char *noteof = (char *) 1;
23 
24 char *
25 input(s)
26 char *s;
27 {
28 	if (peeked) {
29 		peeked = 0;
30 		if (noteof == 0)
31 			return(0);
32 		strcpy(s, ahead);
33 		return(s);
34 	}
35 	return(fgets(s, 1000, in));
36 }
37 
38 char *
39 lookat()
40 {
41 	if (peeked)
42 		return(ahead);
43 	noteof = input(ahead);
44 	peeked = 1;
45 	return(noteof);
46 }
47 
48 addch(s, c)
49 char *s;
50 {
51 	while (*s)
52 		s++;
53 	*s++ = c;
54 	*s = 0;
55 }
56