!<arch>
compare.r       362839733   9     1     100666  1073      `
include /usr/style/io/globdefs
define	NAMESIZE	50
# compare _ compare two files for equality
	character arg1(MAXLINE), arg2(MAXLINE)
	character line1(MAXLINE), line2(MAXLINE)
	integer equal, getarg, getlin, open
	integer infil1, infil2, lineno, m1, m2

	if (getarg(1, arg1, MAXLINE) == EOF
	   | getarg(2, arg2, MAXLINE) == EOF)
		call error("usage: compare file1 file2.")
	infil1 = open(arg1, READ)
	if (infil1 == ERR)
		call cant(arg1)
	infil2 = open(arg2, READ)
	if (infil2 == ERR)
		call cant(arg2)
	lineno = 0
	repeat {
		m1 = getlin(line1, infil1)
		m2 = getlin(line2, infil2)
		if (m1 == EOF | m2 == EOF)
			break
		lineno = lineno + 1
		if (equal(line1, line2) == NO)
			call difmsg(lineno, line1, line2)
		}
	if (m1 == EOF & m2 != EOF)
		call remark("eof on file 1.")
	else if (m2 == EOF & m1 != EOF)
		call remark("eof on file 2.")
	stop
	end

#difmsg
	subroutine difmsg(lineno, line1, line2)
	integer line1(MAXLINE), line2(MAXLINE)
	integer lineno

	call putdec(lineno, 5)
	call putc(NEWLINE)
	call putlin(line1, STDOUT)
	call putlin(line2, STDOUT)
	return
	end

concat.r        362839741   9     1     100666  352       `
include /usr/style/io/globdefs
define	NAMESIZE	50
# concat _ concatenate named files onto standard output
	character name(NAMESIZE)
	integer getarg, open
	integer fin, i

	for (i = 1; getarg(i, name, NAMESIZE) != EOF; i = i + 1) {
		fin = open(name, READ)
		if (fin == ERR)
			call cant(name)
		call fcopy(fin, STDOUT)
		call close(fin)
		}
	stop
	end
include.r       362839740   9     1     100666  1315      `
include /usr/style/io/globdefs
define	NFILES	5
# include _ replace  include file  by contents of file
	character line(MAXLINE), str(MAXLINE)
	integer equal, getlin, getwrd, open
	integer infile(NFILES), len, level, loc
#	string incl "include"
	integer incl(8)
	data incl(1) /LETI/
	data incl(2) /LETN/
	data incl(3) /LETC/
	data incl(4) /LETL/
	data incl(5) /LETU/
	data incl(6) /LETD/
	data incl(7) /LETE/
	data incl(8) /EOS/

	infile(1) = STDIN
	for (level = 1; level > 0; level = level - 1) {
		while (getlin(line, infile(level)) != EOF) {
			loc = 1
			len = getwrd(line, loc, str)
			if (equal(str, incl) == NO)
				call putlin(line, STDOUT)
			else {
				level = level + 1
				if (level > NFILES)
					call error("includes nested too deeply.")
				len = getwrd(line, loc, str)
				infile(level) = open(str, READ)
				if (infile(level) == ERR)
					call cant(str)
				}
			}
		if (level > 1)
			call close(infile(level))
		}
	stop
	end
# getwrd _ get non\(hyblank word from in(i) into  out, increment i
	integer function getwrd(in, i, out)
	character in(ARB), out(ARB)
	integer i, j

	while (in(i) == BLANK | in(i) == TAB)
		i = i + 1
	j = 1
	while (in(i) != EOS & in(i) != BLANK
	   & in(i) != TAB & in(i) != NEWLINE) {
		out(j) = in(i)
		i = i + 1
		j = j + 1
		}
	out(j) = EOS
	getwrd = j - 1
	return
	end


io.a            362839748   9     1     100666  20842     `
efcopy.o       $	               ~                                        >   h                             	   
   
            d  fcopy       (   (   8  H  X  h   X  x                (   8  H  X  h   X  x       (     (   (   (                   fcopy.  "   entry       lino        stsp        lval        stst        lvalp       call        getlin.     rval4       ing4        ine4        lnt2        lif2        goto        putlin.     retrn       getarg.o      
0	  \  f D      f  J       :        \    ^    \        :   d   	   P  8   T      
   X    f             \  ^     P    `  j  b    ^    ^     P    `    \    f        P         f                8     P j           P                    8   T                      P  gtarg             (   8 H  X   (   h  x  H               X           X     ( X   8X   X   h  h  (     Hh  x  H   X     h  (     hh   x     ( X   X     ( X            X              X       H( X     X   X           X   8X   8                                    gtarg.  "   entry       rval4p      i4i2        stst        lino        stsp        lval        call        iargc.      ige4        lnt2        lif2        goto        rval4       alvalp      ing4        gas4        gmv4        retrn       iad4        getarg.     isb4        min0.       ile4        gar1        i1i4        type.o        
Z	                                        *   >                                           f   z   	        
                                                                                type    0   9      a   z      A   Z    (   8   H  X 8   H  h x      (   H    (     (   (   8   H  X 8   H  h x      (   H    (     (   (   8   H  X 8   H  h x      (   H    (     (   (   8     (   (   (   (    (                                          type.   "   entry       lino        rval4p      rval4       ige4        ile4        lan2        lnt2        lif2        goto        gmv4        retrn       fopen.o       >
T	     L       $    d  d              &   P   d  < (  d          d      d  
   d  < (          (                $  $                $      (         $      ( (       $      ( P           d      <   
   
   
   
                  (  H  (  x    (         (     (  x    8H(  (  xH    (     (  8H           H  (  (  8     X(  (  xx  (  (  (  xx  (  (  (  xx    XX                                                            fopen.  "   fopen_   $rval4       c0       gmv4        i_       d.23047   
 arvalp      d0        buf_      c1       ing4        ine4        lnt2        lif2        goto        .23049   P gal1        name1_   (i4i1        gas1        .23048   > c2       iad4        c3       stsp        ft       lval        name4_   (stst        lvalp       mode_     call        open.       c4       ilt4        .23050    retrn       c5       gal4        _filcom   xcpos_      c6       gas4        c7       ceof_    ( c8       c9       cstat_   P rval4p      d1        d2        d3        d4        d5        d6       base     "cbuf_    x create.o      &		  L  P ,      T  0        8    	        <        6   l   
     < X                8                    < X  @         L  X  N  D  P    L    T     T  H                       L  T  N    L         L  X  N     P    L    T           d      <  create                     (   (   8  H  (   8  X    8  h x      (   8      8  X      (   8  8   H  (     (   (   8      8    (         (8     H  (   8  8  H     (   X(   (       (h     H  (       x   (     H  (   X(   X                                              create. "   entry       lino        rval4       gmv4        arvalp      ing4        ine4        lnt2        lif2        goto        gal1        i4i1        gas1        iad4        stsp        lval        stst        call        creat.      ilt4        retrn       close.      lvalp       open.       fseek.o       >
X	   (           0   (      *      ,     (     0      (  H   h  H   h             fseek.  "   fseek_   0 stsp        ft       ( lvalp       fd_       stst        byte_     call        seek0.      gmv4        retrn       base     . cant.o        $~{	  pn   
        v   T      n      p   Z   r     n         n   ^   p     n               d  cant      : can't open.     (   8  H   X  h  X  x       (   8  h  X  x       (    (                                    cant.   "   entry       lino        stsp        lvalp       stst        lval        call        putlin.     error.      retrn       remove.o      E
d	  0   ^                                 &   P      P                          
      P                                 d   P                  (    8      H X h x            8           (                         (  ((                              remove. "   rval4       gmv4        arvalp      ing4        ine4        lnt2        lif2        goto        gal1        i4i1        gas1        iad4        stsp        lval        stst        call        unlink.     retrn       putdec.o      5	  L&  <        0       &     (  2  *    ,    &    ^        ^      Z  	   Z         b      
   &  "  (    &        Z      Z     J              Z     Z  ^               &  Z  ( 2  (    &        Z      Z                    
  putdec    
           (   8  H   X  h  X  h  X  x         (   (          (             (   8  h  X  x      (          (    (   (   (       (            (   8    (   X  x      (          (    (   (   8(   8                          putdec. "   entry       lino        stsp        lvalp       stst        lval        call        itoc.       gmv4        rval4       iad4        rval4p      ile4        lnt2        lif2        goto        putc.       gal4        retrn       putd.o o      F
	     >                                                             N   ~                                   :                            (                                    
    
           (   8  H  8  H  8  X h      x       x               H  8  (   8  X            x      x                   8  (   8  X            x                      putd.   "   stsp        lvalp       stst        lval        call        itoc.       gmv4        rval4       iad4        rval4p      ile4        lnt2        lif2        goto        putch.      gal4        retrn       putc.o o      F
	  ,           4   ,      .   (   0     ,     4         (  H   h  x  h                 putc.   "   putc_    4 stsp        ft       , lvalp       ch_       stst        lval        c0       ( call        putch.      gmv4        retrn       base     2 getc.o o      F
	  ,           4   ,      .   (   0     ,     4          (  H   h  x  h                 getc.   "   getc_    4 stsp        ft       , lvalp       ch_       stst        lval        c0       ( call        getch.      gmv4        retrn       base     2 putch.o       F
	  F           P        X   F      H   X   J   B   L     F     T      P         (   H X  x                       (    ((    putch.  "   putch_   P rval4p      inchar_   i4i1        gmv1        c_       X stsp        ft       F lvalp       fd_       stst        lval        c0       B call        write.      gmv4        nb_      T retrn       base     N getch.o       &U	  @|   8        6        T         V      X  <           	   \      
   \                  |     ~      `      |           T               d         d          &          `                                 "        |  h  ~    |                   getch (16hbad fd in getch:i5)                 read error in getch.   (   8   H  X h x    (   H          (   H     (   H     (   (   (   (    8   8   8 HX       (   H  H  hh x    (   H     (   H     (     (   (   H  H  hh x    (   x   (   x   (     (   (   (   8 H     (   (   (   (                                                                         getch.  "   entry       lino        rval4p      rval4       ilt4        lnt2        lif2        goto        lval        iowf        lvalp       iio4        endio       ing4        gmv4        gmv4p       retrn       stsp        stst        call        read.       ieq4        rval1       i1i4        error.      getlin.o      &	  <h   \      r                   ^                    	   $    r  
   $     (                    $  v     v  ,              h     j  ~  l  $  n    h    z     z                0    r     $     (              ^        z  $        <     v     ~         Z        h  4  j    h              v     L             v  $       (          v  r  !     "   #   v  $    v  $   r   %   &   h  P  j    h     '     (    d  getlin (17hbad fd in getlin:i5)                d    read error in getlin.     
 too long line in getlin.   (   8   H  X h x    (   H          (   H     (   H     H   (   ((   (   (   H    (   H  H  X h x    (   8    H   H   H Xh       (   H  H  xh x    (   H     (   H     H   (   ((     (   (   H  H  xh x    (   H      (     (   (   8   H X     (   (   (   H     H  xh x    (   H  H     H   (   H    (   ((   (   H  H    (     (   (   8   H X     (   ((   (                                                                                                                  getlin. "   entry       lino        rval4p      rval4       ilt4        lnt2        lif2        goto        lval        iowf        lvalp       iio4        endio       ing4        gmv4        alvalp      gas4        retrn       stsp        stst        call        read.       ieq4        rval1       i1i4        error.      arvalp      iad4        putlin.o      $	  P~  D        F        N         R      :   V          B   x             :       	     N      
              R               ~  Z      ~           ~             N        ~             N               ~  r      ~                        d     putlin           too long line in putlin.write error.   (   (   8  H  (   8  8  X 8  h    8  x        (   8      8  h      (   8  8  H  (     (   (   8  8       (   ( 8 H Xh     (   (   ( x  H 8 H 8  8  ( X     H  (   8  8  8        (   ( 8 H Xh     (   (   8  H  (   (                                                                       putlin. "   entry       lino        rval4       gmv4        ile4        arvalp      ing4        ine4        lan2        lnt2        lif2        goto        gal1        i4i1        gas1        iad4        igt4        stsp        lval        stst        call        error.      lvalp       isb4        write.      retrn       error.o       i
B	   $    `       *   $      &     $           d     (   8  H X      h   x       error.  "   stsp        lvalp       stst        call        remark.     stop        retrn       itoc.o        5	  8F  t                    Z     \    Z    N                       J           J       J     Z  N  \    ^    Z    F     J     F       ,        N      N     N      J              T                J             4     J       J     J             !   J         "   #      R  $   R  J      r    %   J     V  &   J     R       '   R     V    (   J       J  )   R       R  *   Z  +   ,     -          itoc          
       -         0   1   2   3   4   5   6   7   8   9                        (   8 H  X   h  x   H           X             X       X   X   X          X   h   H   H          X              (    X       8  X       H  (   Xhx  X   X   (       (   x  X          X            X   X         X   X       X       x  X          X               X            X         X          X    X   X   X                                                                                                               itoc.   "   entry       rval4p      i4i2        stst        lino        stsp        lvalp       call        iabs.       gmv4        rval4       alvalp      ing4        gas4        iad4        lval        mod.        gar4        idv4        ieq4        ige4        lor2        lnt2        lif2        goto        ilt4        lan2        isb4        arvalp      retrn       ctoi.o        5	  <J6  ,      L  ,               2           6        :   T         :          
            >  L            B                  P                   |     |  >                       F  L    |    :    L        :           h   !   "     #    d     ctoi        	             
         0   1   2   3   4   5   6   7   8   9        (   (   8   H    X  h 8   H    X  h x      (   8   X      (     (   (   (   X    (   8   H    X         (     ( 8   8   ( HX       (   X  X  h      (     (   (   X  X  hX   X  x  (   8   X      (     (   (   (                                                                                                   ctoi.   "   entry       lino        rval4p      arvalp      rval4       ieq4        lor2        lnt2        lif2        goto        iad4        gmv4p       gmv4        ing4        ine4        stsp        lval        stst        alvalp      call        index.      imp4        isb4        retrn       remark.o      i
B	  @          $    ,    0  0      0  0  
      4   <     0  0        P   l   ,      ,  ,      (        0   (                0   (                   (                 (                   d                    .   
    (    (      8 (      H X h  x    (       X h  x      8 (        (                                   X h  x          (8                         HH                                    remark. "   rval4       gmv4        iad4        igt4        lnt2        lif2        goto        ieq4        arvalp      stsp        lval        stst        gal1        call        write.      gar1        i1i4        i4i1        gas1        retrn       index.o       !C	                                                  6   x                    T   Z        	   
                                         d  index              (   (   8  H  (   8  X    8  h x      (   8  X             (    (   (   8  8   H  (     (   (   8  H  (    (                            index.  "   entry       lino        rval4       gmv4        arvalp      ing4        ine4        lnt2        lif2        goto        rval4p      ieq4        retrn       iad4        readf.o       w
	  8                                <                                                       z                                                                                                            ( 8     H  X h x    H    H      H          8   8     8  (       H  H  X h x    H     H      H     H    H  H  X h x    H      H  8   H H  H  X    H      H                                  readf.  "   rval4p      i4i2        stst        rval4       ile4        lnt2        lif2        goto        gmv4        alvalp      ing4        gas4        retrn       stsp        lvalp       lval        call        read.       gar1        i1i4        iad4        length.o      !C	                l         t            x     f    |         <   V         x              	   
         d  length               (   (   8  H  (   8  8  X h    8  x       (   8  8  X H  (     (   (    (                              length. "   entry       lino        rval4       gmv4        iad4        arvalp      ing4        ine4        lnt2        lif2        goto        retrn       scopy.o       
3	  `                                                         B      	                   
                               "                                d   d  scopy          (   8   H  (   (   8   H  (   X  h    X  x       (   X      X  h     (   X  X   H  (   X  X   H  (     (   (   X      X  x  (    (                              scopy.  "   entry       lino        rval4p      gmv4        rval4       arvalp      ing4        ine4        lnt2        lif2        goto        alvalp      gas4        iad4        retrn       min.o         
	  4V    x       X   R                   2         X      B            X   	   
        min    (   8   8   H X h  x  (   8     (   x  (   (   8     (   (    (        min.    "   entry       lino        rval4p      ilt4        lnt2        lif2        goto        gmv4        retrn       max.o         
	  4V    x       X   R                   2         X      B            X   	   
        max    (   8   8   H X h  x  (   8     (   x  (   (   8     (   (    (        max.    "   entry       lino        rval4p      igt4        lnt2        lif2        goto        gmv4        retrn       equal.o       $s	  4   
                                               :                         Z   l   	         
                                                 d   d  equal              (   (   8  H  (   8  X    8  X    h x     (   8  X    8   h x     (   8  H  (    (   (   8  8   H  (     (   (   8  H  (    (                                  equal.  "   entry       lino        rval4       gmv4        arvalp      ieq4        lnt2        lif2        goto        ing4        retrn       iad4        open.o        &	  2  L        :          "  z  	   z  
   &        6   l   
   z  < >  z  
          z  "    z              z  "               "    :             z  < >  *         2  >  4     6    2    :     :  .                             d      <  fopen                  (   (   8  H  (   8  X    8  h x      (   8      8  X      (   8  8   H  (     (   (   8  8        (   8  h H  (   (   (   8      8    (    ( 8 H  8 Xh     H  (   8  8  x     (   (   (   (                                           fopen.  "   entry       lino        rval4       gmv4        arvalp      ing4        ine4        lnt2        lif2        goto        gal1        i4i1        gas1        iad4        ile4        retrn       stsp        lval        stst        lvalp       call        open.       ilt4        makecopy.r      362839737   9     1     100666  505       `
include /usr/style/io/globdefs
define	NAMESIZE	50
# makecopy _ copy one file to another
	character iname(NAMESIZE), oname(NAMESIZE)
	integer create, getarg, open
	integer fin, fout

	if (getarg(1, iname, NAMESIZE) == EOF 
	   | getarg(2, oname, NAMESIZE) == EOF)
		call error("usage: makecopy input output.")
	fin = open(iname, READ)
	if (fin == ERR)
		call cant(iname)
	fout = create(oname, WRITE)
	if (fout == ERR)
		call cant(oname)
	call fcopy(fin, fout)
	call close(fin)
	call close(fout)
	stop
	end

print.r         362839736   9     1     100666  1675      `
include /usr/style/io/globdefs
define	NAMESIZE	50
define	MARGIN1	3
define	MARGIN2	2
define	MARGIN3	2
define	MARGIN4	3
define	BOTTOM	60
define	PAGELEN	66
# print  (default input STDIN) _ print files with headings
	character name(NAMESIZE)
	integer getarg, open
	integer fin, i
#	string null ""
	integer null(1)
	data null(1) /EOS/

	for (i = 1; getarg(i, name, NAMESIZE) != EOF; i = i + 1) {
		fin = open(name, READ)
		if (fin == ERR)
			call cant(name)
		call fprint(name, fin)
		call close(fin)
		}
	if (i == 1)		# no files specified
		call fprint(null, STDIN)
	stop
	end

# fprint _ print file "name" from  fin
	subroutine fprint(name, fin)
	integer line(MAXLINE), name(NAMESIZE)
	integer getlin, open
	integer fin, lineno, pageno

	pageno = 0
	lineno = 0
	while (getlin(line, fin) != EOF) {
		if (lineno == 0) {
			call skip(MARGIN1)
			pageno = pageno + 1
			call head(name, pageno)
			call skip(MARGIN2)
			lineno = MARGIN1 + MARGIN2 + 1
			}
		call putlin(line, STDOUT)
		lineno = lineno + 1
		if (lineno >= BOTTOM) {
			call skip(PAGELEN-lineno)
			lineno = 0
			}
		}
	if (lineno > 0)
		call skip(PAGELEN-lineno)
	return
	end

# skip _ output  n  blank lines
	subroutine skip(n)
	integer i, n

	for (i = 1; i <= n; i = i + 1)
		call putc(NEWLINE)
	return
	end

# head _ print top of page header
	subroutine head(name, pageno)
	integer name(NAMESIZE)
	integer pageno
#	string page " Page  "
	integer page(7)
	data page(1) /BLANK/
	data page(2) /LETP/
	data page(3) /LETA/
	data page(4) /LETG/
	data page(5) /LETE/
	data page(6) /BLANK/
	data page(7) /EOS/

	call putlin(name, STDOUT)
	call putlin(page, STDOUT)
	call putdec(pageno, 1)
	call putc(NEWLINE)
	return
	end

scompare.r      362839739   9     1     100666  856       `
include /usr/style/io/globdefs
define	INFILE1	1
define	INFILE2	2
define	NAMESIZE	50
# compare  (simple version) _ compare file 1 to file 2
	character line1(MAXLINE), line2(MAXLINE)
	integer equal, getlin
	integer lineno, m1, m2

	lineno = 0
	repeat {
		m1 = getlin(line1, INFILE1)
		m2 = getlin(line2, INFILE2)
		if (m1 == EOF | m2 == EOF)
			break
		lineno = lineno + 1
		if (equal(line1, line2) == NO)
			call difmsg(lineno, line1, line2)
		}
	if (m1 == EOF & m2 != EOF)
		call remark("eof on file 1.")
	else if (m2 == EOF & m1 != EOF)
		call remark("eof on file 2.")
	# else they match
	stop
	end

# difmsg _ print line numbers and differing lines
	subroutine difmsg(lineno, line1, line2)
	character line1(ARB), line2(ARB)
	integer lineno

	call putdec(lineno, 5)
	call putc(NEWLINE)
	call putlin(line1, STDOUT)
	call putlin(line2, STDOUT)
	return
	end
sprint.r        362839740   9     1     100666  1540      `
include /usr/style/io/globdefs
define	NAMESIZE	50
define	MARGIN1	3
define	MARGIN2	2
define	MARGIN3	2
define	MARGIN4	3
define	BOTTOM	60
define	PAGELEN	66
# print _ print files with headings
	character name(NAMESIZE)
	integer getarg, open
	integer fin, i

	for (i = 1; getarg(i, name, NAMESIZE) != EOF; i = i + 1) {
		fin = open(name, READ)
		if (fin == ERR)
			call cant(name)
		call fprint(name, fin)
		call close(fin)
		}
	stop
	end

# fprint _ print file "name" from  fin
	subroutine fprint(name, fin)
	character line(MAXLINE), name(NAMESIZE)
	integer getlin, open
	integer fin, lineno, pageno

	pageno = 0
	lineno = 0
	while (getlin(line, fin) != EOF) {
		if (lineno == 0) {
			call skip(MARGIN1)
			pageno = pageno + 1
			call head(name, pageno)
			call skip(MARGIN2)
			lineno = MARGIN1 + MARGIN2 + 1
			}
		call putlin(line, STDOUT)
		lineno = lineno + 1
		if (lineno >= BOTTOM) {
			call skip(PAGELEN-lineno)
			lineno = 0
			}
		}
	if (lineno > 0)
		call skip(PAGELEN-lineno)
	return
	end

# skip _ output  n  blank lines
	subroutine skip(n)
	integer i, n

	for (i = 1; i <= n; i = i + 1)
		call putc(NEWLINE)
	return
	end

# head _ print top of page header
	subroutine head(name, pageno)
	character name(NAMESIZE)
	integer pageno
#	string page " Page  "
	integer page(7)
	data page(1) /BLANK/
	data page(2) /LETP/
	data page(3) /LETA/
	data page(4) /LETG/
	data page(5) /LETE/
	data page(6) /BLANK/
	data page(7) /EOS/

	call putlin(name, STDOUT)
	call putlin(page, STDOUT)
	call putdec(pageno, 1)
	call putc(NEWLINE)
	return
	end
