home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / fortran / ratfor.lbr / COMPARE.RTF next >
Encoding:
Text File  |  1986-04-27  |  1.4 KB  |  66 lines

  1.  
  2.    include "b:ratdefn.rtf"
  3.  
  4. define(READ,RDONLY)
  5. define(NAMESIZE,50)
  6. # compare - compare two files for equality
  7.    character arg1(MAXLINE), arg2(MAXLINE)
  8.    character line1(MAXLINE), line2(MAXLINE)
  9.    integer equal, getarg, getlin, fopen
  10.    integer infil1, infil2, lineno, m1, m2
  11.  
  12.    call initio
  13.  
  14.    if (getarg(1, arg1, MAXLINE) == EOF
  15.       | getarg(2, arg2, MAXLINE) == EOF)
  16.       call error("usage: compare file1 file2.")
  17.    infil1 = fopen(arg1, READ)
  18.    if (infil1 == ERR)
  19.       call cant(arg1)
  20.    infil2 = fopen(arg2, READ)
  21.    if (infil2 == ERR)
  22.       call cant(arg2)
  23.    lineno = 0
  24.    repeat {
  25.       m1 = getlin(line1, infil1)
  26.       m2 = getlin(line2, infil2)
  27.       if (m1 == EOF | m2 == EOF)
  28.      break
  29.       lineno = lineno + 1
  30.       if (equal(line1, line2) == NO)
  31.      call difmsg(lineno, line1, line2)
  32.       }
  33.    if (m1 == EOF & m2 ^= EOF)
  34.       call remark("eof on file 1.")
  35.    else if (m2 == EOF & m1 ^= EOF)
  36.       call remark("eof on file 2.")
  37.  
  38.    call putc(EOF)
  39.  
  40.    stop
  41.    end
  42.  
  43. # difmsg
  44.    subroutine difmsg(lineno, line1, line2)
  45.    integer line1(MAXLINE), line2(MAXLINE)
  46.    integer lineno
  47.  
  48.    call putdec(lineno, 5)
  49.    call putc(NEWLINE)
  50.    call putlin(line1, STDOUT)
  51.    call putlin(line2, STDOUT)
  52.    return
  53.    end
  54. 
  55.  
  56.  
  57.  
  58.  
  59.  
  60. ineno, 5)
  61.    call putc(NEWLINE)
  62.    call putlin(line1, STDOUT)
  63.    call putlin(line2, STDOUT)
  64.    return
  65.    end
  66.