xref: /csrg-svn/usr.bin/learn/lrntee/lrntee.c (revision 62074)
148273Sbostic /*-
2*62074Sbostic  * Copyright (c) 1986, 1993
3*62074Sbostic  *	The Regents of the University of California.  All rights reserved.
448273Sbostic  *
548273Sbostic  * %sccs.include.proprietary.c%
648273Sbostic  */
748273Sbostic 
812056Smckusick #ifndef lint
9*62074Sbostic static char copyright[] =
10*62074Sbostic "@(#) Copyright (c) 1986, 1993\n\
11*62074Sbostic 	The Regents of the University of California.  All rights reserved.\n";
1248273Sbostic #endif /* not lint */
1312056Smckusick 
1448273Sbostic #ifndef lint
15*62074Sbostic static char sccsid[] = "@(#)lrntee.c	8.1 (Berkeley) 06/06/93";
1648273Sbostic #endif /* not lint */
1748273Sbostic 
main()1812056Smckusick main()
1912056Smckusick {
2028231Sbloom 	int f;
2128231Sbloom 	char c;
2212056Smckusick 
2312056Smckusick 	f = creat(".ocopy", 0666);
2412056Smckusick 	while (read(0, &c, 1) == 1) {
2512056Smckusick 		write (1, &c, 1);
2612056Smckusick 		put(c, f);
2712056Smckusick 	}
2812056Smckusick 	fl(f);
2912056Smckusick 	close(f);
3012056Smckusick }
3112056Smckusick 
3212056Smckusick static char ln[512];
3312056Smckusick char *p = ln;
put(c,f)3412056Smckusick put(c, f)
3512056Smckusick {
3612056Smckusick 	*p++ = c;
3712056Smckusick 	if (c == '\n') {
3812056Smckusick 		fl(f);
3912056Smckusick 		p=ln;
4012056Smckusick 	}
4112056Smckusick }
fl(f)4212056Smckusick fl(f)
4312056Smckusick {
4412056Smckusick 	register char *s;
4512056Smckusick 
4612056Smckusick 	s = ln;
4712056Smckusick 	while (*s == '%' && *(s+1) == ' ')
4812056Smckusick 		s += 2;
4912056Smckusick 	write(f, s, p-s);
5012056Smckusick }
51