Research V7 development
[unix-history] / usr / src / cmd / learn / tee.c
CommitLineData
29512365
BK
1main()
2{
3 int f, c;
4
5 f = creat(".ocopy", 0666);
6 while (read(0, &c, 1) == 1) {
7 write (1, &c, 1);
8 put(c, f);
9 }
10 fl(f);
11 close(f);
12}
13
14static char ln[512];
15char *p = ln;
16put(c, f)
17{
18 *p++ = c;
19 if (c == '\n') {
20 fl(f);
21 p=ln;
22 }
23}
24fl(f)
25{
26 register char *s;
27
28 s = ln;
29 while (*s == '$' && *(s+1) == ' ')
30 s += 2;
31 write(f, s, p-s);
32}