xref: /original-bsd/usr.bin/learn/lrntee/lrntee.c (revision 014fe330)
1 #ifndef lint
2 static char sccsid[] = "@(#)lrntee.c	4.2	(Berkeley)	04/26/83";
3 #endif not lint
4 
5 main()
6 {
7 	int f, c;
8 
9 	f = creat(".ocopy", 0666);
10 	while (read(0, &c, 1) == 1) {
11 		write (1, &c, 1);
12 		put(c, f);
13 	}
14 	fl(f);
15 	close(f);
16 }
17 
18 static char ln[512];
19 char *p = ln;
20 put(c, f)
21 {
22 	*p++ = c;
23 	if (c == '\n') {
24 		fl(f);
25 		p=ln;
26 	}
27 }
28 fl(f)
29 {
30 	register char *s;
31 
32 	s = ln;
33 	while (*s == '%' && *(s+1) == ' ')
34 		s += 2;
35 	write(f, s, p-s);
36 }
37