%%s 0/0/0 %%d D 1.1 25-Mar-82 12:08:02 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 #-h- lcnt.r 720 asc 25-mar-82 08:04:23 v1.1 (sw-tools v1.1) #-h- main 647 asc 25-mar-82 08:04:14 v1.1 (sw-tools v1.1) ## 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) == '-' & buf(2) == EOS) int = STDIN else { int = open(buf, READ) if (int == ERR) call cant (buf) } while (getch(c, int) != EOF) if (c == '@n') incrdi(nl) if (int != STDIN) call close(int) } if (i == 1) while (getch(c,STDIN) != EOF) if (c == '@n') incrdi(nl) i = ditoc(nl, buf, MAXCHARS) call putlin(buf, STDOUT) call putc('@n') DRETURN end #-h- lcnt.fmt 593 asc 25-mar-82 08:04:24 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Lcnt (1) 11-Jan-79 line count .sy lcnt [file] ... .ds 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 .fl .sa ccnt; wcnt; the Unix command 'wc' .di A message is printed if an input file could not be opened; processing is terminated. .au Original from Kernighan and Plauger's 'Software Tools', with modifications by Debbie Scherrer. .bu %%E 1