home *** CD-ROM | disk | FTP | other *** search
-
- include "b:ratdefn.rtf"
-
- define(READ,RDONLY)
- define(NAMESIZE,50)
- # compare - compare two files for equality
- character arg1(MAXLINE), arg2(MAXLINE)
- character line1(MAXLINE), line2(MAXLINE)
- integer equal, getarg, getlin, fopen
- integer infil1, infil2, lineno, m1, m2
-
- call initio
-
- if (getarg(1, arg1, MAXLINE) == EOF
- | getarg(2, arg2, MAXLINE) == EOF)
- call error("usage: compare file1 file2.")
- infil1 = fopen(arg1, READ)
- if (infil1 == ERR)
- call cant(arg1)
- infil2 = fopen(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.")
-
- call putc(EOF)
-
- 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
-
-
-
-
-
- ineno, 5)
- call putc(NEWLINE)
- call putlin(line1, STDOUT)
- call putlin(line2, STDOUT)
- return
- end