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