Sync usage with man page.
[netbsd-mini2440.git] / share / man / tools / line.c
blob31367db2e7380cfbeeaebf10dacacc01d25cd5c7
1 /* $NetBSD$ */
3 /* @(#)line.c 1.1 */
4 /*
5 This program reads a single line from the standard input
6 and writes it on the standard output. It is probably most useful
7 in conjunction with the Bourne shell.
8 */
9 #define LSIZE 512
10 int EOF;
11 char nl = '\n';
12 main()
14 register char c;
15 char line[LSIZE];
16 register char *linep, *linend;
18 EOF = 0;
19 linep = line;
20 linend = line + LSIZE;
22 while ((c = readc()) != nl)
24 if (linep == linend)
26 write (1, line, LSIZE);
27 linep = line;
29 *linep++ = c;
31 write (1, line, linep-line);
32 write(1,&nl,1);
33 if (EOF == 1) exit(1);
34 exit (0);
36 readc()
38 char c;
39 if (read (0, &c, 1) != 1) {
40 EOF = 1;
41 return(nl);
43 else
44 return (c);