#-h- ccnt.r 986 asc 07-may-80 12:07:24 #-h- main 283 asc 07-may-80 12:07:15 #--------------------------------------------------------------------- # include symbol definitions # include symbols #--------------------------------------------------------------------- ## main - calling routine for ccnt # call initr4 # call ccnt # call endr4 # end #-h- ccnts 605 asc 07-may-80 12:07:16 ## ccnt - count characters in input file(s) # subroutine ccnt subroutine main integer getarg, fsize character buf(MAXLINE), getc, c integer i, nc nc = 0 for (i=1; ; i=i+1) { if (getarg(i, buf, MAXLINE) == EOF) { if (i == 1) while (getc(c) != EOF) nc = nc + 1 break } if (buf(1) == QMARK & buf(2) == EOS) call error ('usage: ccnt [file ...].') else if (buf(1) == MINUS & buf(2) == EOS) while (getc(c) != EOF) nc = nc + 1 else { size = fsize(buf) if (size == ERR) call cant (buf) nc = nc + size } } call putdec (nc, 1) call putc (NEWLINE) return end