############################################################################ # # File: roffcmds.icn # # Subject: Program to list roff commands and macros # # Author: Ralph E. Griswold # # Date: June 10, 1988 # ############################################################################ # # This file is in the public domain. # ############################################################################ # # This progam processes standard input and writes a tabulation of # nroff/troff commands and defined strings to standard output. # # Limitations: # # This program only recognizes commands that appear at the beginning of # lines and does not attempt to unravel conditional constructions. # Similarly, defined strings buried in disguised form in definitions are # not recognized. # # Reference: # # Nroff/Troff User's Manual, Joseph F. Ossana, Bell Laboratories, # Murray Hill, New Jersey. October 11, 1976. # ############################################################################ procedure main() local line, con, mac, y, nonpuncs, i, inname, infile, outname, outfile nonpuncs := ~'. \t\\' con := table(0) mac := table(0) while line := read() do { line ? if tab(any('.\'')) then con[tab(any(nonpuncs)) || (tab(upto(' ') | 0))] +:= 1 line ? while tab((i := find("\\")) + 1) do { case move(1) of { "(": move(2) "*" | "f" | "n": if ="(" then move(2) else move(1) } mac[&subject[i:&pos]] +:= 1 } } con := sort(con,3) write(,"Commands:\n") while write(,get(con),"\t",get(con)) mac := sort(mac,3) write(,"\nControls:\n") while write(,get(mac),"\t",get(mac)) end