updates from John Kunze
[unix-history] / usr / src / usr.bin / learn / lrntee / lrntee.c
CommitLineData
30ec5a0e 1#ifndef lint
0acfbe6a 2static char sccsid[] = "@(#)lrntee.c 4.3 (Berkeley) %G%";
30ec5a0e
KM
3#endif not lint
4
5main()
6{
0acfbe6a
JB
7 int f;
8 char c;
30ec5a0e
KM
9
10 f = creat(".ocopy", 0666);
11 while (read(0, &c, 1) == 1) {
12 write (1, &c, 1);
13 put(c, f);
14 }
15 fl(f);
16 close(f);
17}
18
19static char ln[512];
20char *p = ln;
21put(c, f)
22{
23 *p++ = c;
24 if (c == '\n') {
25 fl(f);
26 p=ln;
27 }
28}
29fl(f)
30{
31 register char *s;
32
33 s = ln;
34 while (*s == '%' && *(s+1) == ' ')
35 s += 2;
36 write(f, s, p-s);
37}