#-h- ccnt.r 722 asc 25-apr-81 07:26:45 [002,100] #-h- main 660 asc 25-apr-81 07:22:43 [002,100] ## ccnt - count characters in input file(s) DRIVER(ccnt) integer getarg, open, ditoc character buf(MAXLINE), getch, c integer i, nc(2), int call query("usage: ccnt [file] ...") initdi(nc) for (i=1; ; i=i+1) { if (getarg(i, buf, MAXLINE) == EOF) { if (i == 1) while (getch(c, STDIN) != EOF) incrdi(nc) break } else if (buf(1) == MINUS & buf(2) == EOS) while (getch(c, STDIN) != EOF) incrdi(nc) else { int = open(buf, READ) if (int == ERR) call cant(buf) while (getch(c, int) != EOF) incrdi(nc) call close(int) } } i = ditoc(nc, buf, MAXCHARS) call putlin(buf, STDOUT) call putc(NEWLINE) DRETURN end #-h- ccnt.rof 745 asc 02-may-81 21:32:40 [002,100] .pl 60 .bp .rm 70 .in 0 .he 'CCNT'1/11/79'CCNT' .fo ''-#-' .fi NAME .br .in 7 ccnt - character count .sp 1 .in SYNOPSIS .br .in 7 ccnt [file] ... .sp 1 .in DESCRIPTION .br .in 7 Ccnt counts characters in the named file(s). Newlines are counted as characters. If no file name or the file '-' is given, standard input will be read. .sp 1 .in FILES .br .in 7 .sp 1 .in SEE ALSO .br .in 7 wcnt; lcnt; the Unix command 'wc' .sp 1 .in DIAGNOSTICS .br .in 7 A message is printed if an input file cannot be opened; further processing is terminated. .sp 1 .in AUTHORS .br .in 7 .sp 1 Original from Kernighan and Plauger's 'Software Tools', with minor modifications by Debbie Scherrer. .sp 1 .in BUGS .br .in 7