Annotation of 43BSD/contrib/icon/src/cmd/i-psort.icn, revision 1.1.1.1

1.1       root        1: #      I-PSORT(1)
                      2: #
                      3: #      Sort Icon procedures and declarations
                      4: #
                      5: #      Ralph E. Griswold
                      6: #
                      7: #      Last modified 4/27/83
                      8: #
                      9: 
                     10: procedure main()
                     11:    local line, x, i, proctable, proclist, comments
                     12:    comments := []
                     13:    proctable := table()
                     14:    while line := read() do {
                     15:       if line ? {
                     16:          ="procedure" &                        #  procedure declaration
                     17:          tab(many(" ")) &
                     18:          proctable[tab(upto("("))] := x := []
                     19:          } then {
                     20:             while put(x,get(comments)) #  save it
                     21:             put(x,line)
                     22:             i := 1
                     23:             while line := read() do {
                     24:                put(x,line)
                     25:                if line == "end" then break
                     26:                }
                     27:             }
                     28:                                        #  other declarations
                     29:          else if line ? =("global" | "record" | "external")
                     30:          then {
                     31:             while write(get(comments))
                     32:             write(line)
                     33:             }
                     34:          else put(comments,line)
                     35:          }
                     36:    while write(get(comments))
                     37:    proclist := sort(proctable)         #  sort procedures
                     38:    if *proclist > 1 then
                     39:       every i := 1 to *proclist do     #  get main procedure to front
                     40:          if proclist[i][1] == "main" then {
                     41:             proclist := proclist[i+:1] ||| proclist[1:i] ||| proclist[i + 1:0]
                     42:             break
                     43:             }
                     44:    every x := !proclist do {           #  output procedures
                     45:       every write(!(x[2]))
                     46:       }
                     47: end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.