File:  [Research Unix] / researchv10dc / cmd / icon / ipl / source / ipsplit.icn
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:34 2018 UTC (8 years, 3 months ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Dan Cross

#	IPSPLIT
#
#	Split Icon program into separate files
#
#	Ralph E. Griswold
#
#	Last modified 4/29/86
#

procedure main(o)
   local line, x, i, proctable, proclist, comments, gfile, ofile
   comments := []
   if o[1] := "-g" then gfile := open(o[2],"w") |
      stop("usage:  i-split [-g file]")
   proctable := table()
   while line := read() do {
      if line ? {
         ="procedure" &			#  procedure declaration
         tab(many(' ')) &
         proctable[tab(upto('('))] := x := []
         } then {
            while put(x,get(comments))	#  save it
            put(x,line)
            i := 1
            while line := read() do {
               put(x,line)
               if line == "end" then break
               }
            }
					#  other declarations
         else if \gfile & line ? =("global" | "record" | "link")
         then {
            while write(gfile,get(comments))
            write(gfile,line)
            }
         else put(comments,line)
         }
   while write(\gfile,get(comments))
   proclist := sort(proctable,3)	#  sort procedures
   while x := get(proclist) do {	#  output procedures
      ofile := open(x || ".icn","w") | stop("cannot write ",x,".icn")
      every write(ofile,!get(proclist))
      close(ofile)
      }
end

unix.superglobalmegacorp.com

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