%%s 5/5/88 %%d D 1.2 15-Jun-83 10:45:28 sventek 2 1 %%c Removed trailing periods from quoted strings, as they are no longer needed. %%s 0/0/0 %%d D 1.1 25-Mar-82 12:02:43 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 %%D 2 #-h- cmp.r 1625 asc 25-mar-82 07:26:12 v1.1 (sw-tools v1.1) #-h- main 1157 asc 25-mar-82 07:25:50 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- cmp.r 1626 asc 15-jun-83 10:45:13 sventek (joseph sventek) #-h- main 1154 asc 15-jun-83 10:44:55 sventek (joseph sventek) %%E 2 ## cmp - compare two files for equality DRIVER(cmp) character arg1(MAXLINE), arg2(MAXLINE) , stdin(2) character line1(MAXLINE), line2(MAXLINE) integer equal, getarg, getlin, open integer infil1, infil2, lineno, m1, m2 %%D 2 string usestr "usage: cmp file1 [file2]." %%E 2 %%I 2 string usestr "usage: cmp file1 [file2]" %%E 2 data stdin/'-', EOS/ call query(usestr) if (getarg(1, arg1, MAXLINE) == EOF) call error(usestr) if (getarg(2, arg2, MAXLINE) == EOF) # read STDIN if arg 2 call scopy(stdin, 1, args, 1) infil1 = open(arg1, READ) if (infil1 == ERR) call cant(arg1) if (equal(args, stdin) == YES) infil2 = STDIN else { 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) %%D 2 call remark("eof on file 1.") %%E 2 %%I 2 call remark("eof on file 1") %%E 2 else if (m2 == EOF & m1 != EOF) %%D 2 call remark("eof on file 2.") %%E 2 %%I 2 call remark("eof on file 2") %%E 2 DRETURN end #-h- difmsg 322 asc 25-mar-82 07:25:52 v1.1 (sw-tools v1.1) ## difmsg - print line number and differing lines of file1 and file2 subroutine difmsg(lineno, line1, line2) character line1(MAXLINE), line2(MAXLINE) integer lineno call putdec(lineno, 5) call putc('@n') call putlin(line1, STDOUT) call putlin(line2, STDOUT) return end #-h- cmp.fmt 818 asc 25-mar-82 07:26:14 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Cmp (1) 6-Mar-78 compare two files .sy cmp file1 [file2] .ds file1 is compared line-by-line with file2. If file2 is not specified, standard input is used. If any lines differ, cmp announces the line number and prints each file's offending line. .fl none .sa comm .br The UNIX commands cmp, diff, and comm .di If the end of one file is reached before the end of the other, a message is printed. .au Acquired from "Software Tools" by Kernighan and Plauger, with minor modifications made by Debbie Scherrer. .bu If either file is binary, spurious results should be expected. Cmp cannot handle offset lines: line n of file1 is simply compared to line n of file2. Trailing blanks are significant, which will cause some lines to appear similar to the user which are actually different. %%E 1