%%s 0/0/0 %%d D 1.1 25-Mar-82 12:08:08 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- ll.r 1584 asc 25-mar-82 08:04:52 v1.1 (sw-tools v1.1) #-h- defns 107 asc 25-mar-82 08:04:41 v1.1 (sw-tools v1.1) # include ratdef define(HUGE,10000) # bigger than longest possible line define(MAXNAME,FILENAMESIZE) #-h- main 738 asc 25-mar-82 08:04:42 v1.1 (sw-tools v1.1) # ll - prints length of shortest and longest lines DRIVER(ll) character arg(MAXLINE) integer open, getarg integer fd, i call query("usage: ll [file] ...") for (i = 1; getarg(i, arg, MAXNAME) != EOF; i = i + 1) { if (arg(1) == '-' & arg(2) == EOS) fd = STDIN else fd = open(arg, READ) if (fd == ERR) call cant(arg) else { call doll(fd) if (fd != STDIN) { call putc(' ') call putlin(arg, STDOUT) call close(fd) } call putc('@n') } } if (i == 1) { # no args, do STDIN call doll(STDIN) call putc('@n') } DRETURN end #-h- doll 520 asc 25-mar-82 08:04:43 v1.1 (sw-tools v1.1) # doll - determine longest and shortest lines in fd subroutine doll(fd) integer fd character getch character c integer len, minl, maxl minl = HUGE maxl = 0 len = 0 while (getch(c, fd) != EOF) if (c == '@n') { if (len > maxl) maxl = len if (len < minl) minl = len len = 0 } else len = len + 1 if (minl == HUGE) minl = 0 call putdec(minl, 5) call putc(' ') call putdec(maxl, 5) return end #-h- ll.fmt 454 asc 25-mar-82 08:04:53 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Ll (1) 15-Sep-78 print line lengths .sy ll [file] ... .ds ll prints the lengths of the shortest and longest lines in the named files. The name "-" may be used to refer to the standard input. If no files are given, ll reads the standard input. NEWLINE characters are not counted as part of the length of a line. .fl none .di A message is issued if a named file could not be opened. .au David Hanson and friends (U. of Arizona) .bu %%E 1