date and time created 83/04/26 01:21:12 by mckusick
[unix-history] / usr / src / usr.bin / learn / lrntee / lrntee.c
CommitLineData
30ec5a0e
KM
1#ifndef lint
2static char sccsid[] = "@(#)lrntee.c 4.1 (Berkeley) %G%";
3#endif not lint
4
5main()
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
18static char ln[512];
19char *p = ln;
20put(c, f)
21{
22 *p++ = c;
23 if (c == '\n') {
24 fl(f);
25 p=ln;
26 }
27}
28fl(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}