#-h- lcnt.r 720 asc 25-apr-81 07:19:16 [002,100] #-h- main 658 asc 25-apr-81 07:17:27 [002,100] ## lnct - count lines in input file(s) DRIVER(lcnt) character getch character c, buf(MAXLINE) integer nl(2), i, int integer open, getarg, ditoc call query("usage: lcnt [file] ...") initdi(nl) for (i=1; getarg(i,buf,MAXLINE)!=EOF; i=i+1) { if (buf(1) == MINUS & buf(2) == EOS) int = STDIN else { int = open(buf, READ) if (int == ERR) call cant (buf) } while (getch(c, int) != EOF) if (c == NEWLINE) incrdi(nl) if (int != STDIN) call close(int) } if (i == 1) while (getch(c,STDIN) != EOF) if (c == NEWLINE) incrdi(nl) i = ditoc(nl, buf, MAXCHARS) call putlin(buf, STDOUT) call putc(NEWLINE) DRETURN end #-h- lcnt.rof 862 asc 06-may-81 08:12:48 [002,100] .pl 60 .bp .rm 70 .in 0 .he 'LCNT'1/11/79'LCNT' .fo ''-#-' .fi NAME .br .in 7 lcnt - line count .sp 1 .in SYNOPSIS .br .in 7 lcnt [file] ... .sp 1 .in DESCRIPTION .br .in 7 Lcnt counts the number of lines of text in the named input files, or the standard input if no files are given or the filename '-' appears. A line is zero or more characters terminated by a NEWLINE marker. Lcnt could also be implemented as a shell script file: .ce tr '!@n' | ccnt .sp 1 .in FILES .br .in 7 .sp 1 .in SEE ALSO .br .in 7 ccnt; wcnt; the Unix command 'wc' .sp 1 .in DIAGNOSTICS .br .in 7 A message is printed if an input file could not be opened; processing is terminated. .sp 1 .in AUTHORS .br .in 7 .sp 1 Original from Kernighan and Plauger's 'Software Tools', with modifications by Debbie Scherrer. .sp 1 .in BUGS .br .in 7