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