%%s 3/3/1024 %%d D 1.2 04-May-82 12:24:45 j 2 1 %%c Modified diff.w`diff.r`gscrip to fix a bug when generating `ed' script. %%c `putint' was call with an insufficient number of arguments when generating %%c delete commands. %%s 0/0/0 %%d D 1.1 25-Mar-82 12:04:07 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 #-h- cdiff 1226 asc 25-mar-82 07:39:26 v1.1 (sw-tools v1.1) sym_pointer _ Old_count (MAX_FILE_SIZE), New_count (MAX_FILE_SIZE), Old_xref (MAX_FILE_SIZE), New_xref (MAX_FILE_SIZE), Old_lno (MAX_UNIQUE_LINES), Bucket (HASH_TABLE_SIZE), Sym_store (MAX_UNIQUE_LINES2) linepointer _ Text_loc (MAX_UNIQUE_LINES) common /c1/ Old_count # separate common because of size limitations common /c2/ New_count # on some machines... common /c3/ Old_xref common /c4/ New_xref common /c5/ Old_lno common /c6/ Bucket common /c7/ Sym_store common /c8/ Text_loc sym_pointer _ Next_sym, Next_inx, New_size, Old_size filedes _ Old_file, New_file, Text_file, Old_copy, New_copy linepointer _ Old_copy_start, New_copy_start, Text_file_end integer _ Option, Verbos character _ Text_file_name (FILENAMESIZE), Old_copy_name (FILENAMESIZE), New_copy_name (FILENAMESIZE) common /difcom/ Next_sym, Next_inx, Old_file, New_file, Text_file, Old_copy_start, New_copy_start, Text_file_end, New_size, Old_size, Old_copy, New_copy, Option, Verbos, Text_file_name, Old_copy_name, New_copy_name %%D 2 #-h- diff.r 23492 asc 25-mar-82 07:39:31 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- diff.r 23488 asc 04-may-82 12:22:19 j (sventek j) %%E 2 #-h- defns 2359 asc 25-mar-82 07:38:45 v1.1 (sw-tools v1.1) # diff --- isolate differences between two files ifdef(LARGE_ADDRESS_SPACE) define(MAX_UNIQUE_LINES,10000) define(HASH_TABLE_SIZE,6073) define(MAX_FILE_SIZE,10000) elsedef define (MAX_UNIQUE_LINES,1000) # no. of unique lines in all files define (HASH_TABLE_SIZE,1021) # must be prime, as large as possible define (MAX_FILE_SIZE,1000) # no. of lines in largest input file enddef define (MAX_UNIQUE_LINES2,arith(MAX_UNIQUE_LINES,*,2)) define (NULL_POINTER,0) define (sym_pointer,integer) # large enough to index MAX_UNIQUE_LINES2 define (hash_index,integer) # large enough to index HASH_TABLE_SIZE define (file_mark,linepointer) # large enough to hold a file position define (DIFFERENCES,1) # -d => list differences define (REVISION,2) # -r => revision bar requests for 'fmt' define (SCRIPT,3) # -s => update script for 'ed' define (COMPARISON,4) # -c => simple line-by-line compare define (ON,) define (OFF,#) define (DEBUG,OFF) # turn debugging output on/off define (TUNING,OFF) # turn algorithm tuning output on/off # definitions for long variable names define(Old_count,ocount) define(New_count,ncount) define(Old_xref,oxref) define(New_xref,nxref) define(Old_lno,oldlno) define(Sym_store,sstore) define(Text_loc,tloc) define(Next_sym,nsym) define(Next_inx,ninx) define(New_size,nsize) define(Old_size,osize) define(Old_file,ofile) define(New_file,nfile) define(Text_file,tfile) define(Old_copy,ocopy) define(New_copy,ncopy) define(Text_file_end,tfend) define(Old_copy_start,ocstrt) define(New_copy_start,ncstrt) define(Text_file_name,tfname) define(Old_copy_name,ocname) define(New_copy_name,ncname) define(cleanup,clean) define(gen_listing,glist) define(gen_revision,grevis) define(gen_script,gscrip) define(initialize,init) define(simple_compare,scompr) define(mkuniq,scratf) define(lower,fold) define(blank_d,bld) define(blank_i_blank,blibl) define(blank_i_five_blanks,bli5bl) define(n_bar,nbar) define(c_i_blank,cibl) define(c_i_five_blanks,ci5bl) define(o_bar,obar) define(c_d,cd) define(five_blanks_bar,bl5bar) define(start_revision_bar,brbar) define(stop_revision_bar,erbar) define(start_deletion_star,bdstar) define(stop_deletion_star,edstar) define(different,difrnt) define(eof_on_old_file,eofold) define(eof_on_new_file,eofnew) #-h- diff 246 asc 25-mar-82 07:38:46 v1.1 (sw-tools v1.1) DRIVER (diff) include cdiff call initialize if (Option == COMPARISON) call simple_compare else { call load call pair call grow call label call report } call cleanup DRETURN end #-h- clean 511 asc 25-mar-82 07:38:47 v1.1 (sw-tools v1.1) # cleanup --- close input files, remove temporaries, and shut down subroutine cleanup integer junk integer remove include cdiff call close (Old_file) if (New_file != STDIN) call close (New_file) ifnotdef( CPM ) call close(Old_copy) enddef junk = remove (Old_copy_name) ifnotdef( CPM ) call close(New_copy) enddef junk = remove (New_copy_name) ifnotdef( CPM ) call close(Text_file) enddef junk = remove (Text_file_name) return end #-h- enter 1400 asc 25-mar-82 07:38:48 v1.1 (sw-tools v1.1) # enter --- enter a line in the symbol table, return its index sym_pointer function enter (line) character line (ARB) include cdiff hash_index h hash_index hash sym_pointer i, p character text (MAXLINE) integer junk integer equal, getlin, note h = hash (line) p = Bucket (h) while (p != NULL_POINTER) { i = Sym_store (p + 1) # grab index field of entry structure call seek (Text_loc (i), Text_file) junk = getlin (text, Text_file) if (equal (line, text) == YES) return (i) # we got it; return its useful index p = Sym_store (p) # try next item in the chain DEBUG call remark ("probing in lookup:.") DEBUG call remark ("ptr =.") DEBUG call putint (p, 0, ERROUT) DEBUG call putch ('@n', ERROUT) DEBUG call remark ("line =.") DEBUG call putlin (line, ERROUT) } if (Next_inx >= MAX_UNIQUE_LINES) call error ("too many unique lines; symbol table overflow.") i = Next_inx Next_inx = Next_inx + 1 h = hash (line) Sym_store (Next_sym) = Bucket (h) # link in new entry Sym_store (Next_sym + 1) = i Bucket (h) = Next_sym Next_sym = Next_sym + 2 call seek (Text_file_end, Text_file) call ptrcpy(Text_file_end, Text_loc (i)) call putlin (line, Text_file) junk = note(Text_file_end, Text_file) return (i) end #-h- glist 3505 asc 25-mar-82 07:38:50 v1.1 (sw-tools v1.1) # gen_listing --- generate a full listing of changes to a file subroutine gen_listing include cdiff sym_pointer oi, ni integer junk integer getlin character line (MAXLINE) string n_bar "n|" string c_i_blank "ci " string c_i_five_blanks "ci " string o_bar "o|" string c_d "cd" string five_blanks_bar " |" string blank_d " d" string blank_i_blank " i " string blank_i_five_blanks " i " oi = 2 ni = 2 repeat if (Old_count (oi) == 0 & New_count (ni) == 0) { if (Verbos == YES) call putch ('@n', STDOUT) while (Old_count (oi) == 0 & New_count (ni) == 0) { junk = getlin (line, Old_copy) if (Verbos == YES) { call putint (oi - 1, 7, STDOUT) call putint (ni - 1, 5, STDOUT) call putlin (line, STDOUT) } junk = getlin (line, New_copy) oi = oi + 1 ni = ni + 1 } } else if (Old_count (oi) != 1 & New_count (ni) == 1) { call putch ('@n', STDOUT) for (; New_count (ni) == 1; ni = ni + 1) { junk = getlin (line, New_copy) if (Verbos == YES) { call putlin (blank_i_five_blanks, STDOUT) call putint (ni - 1, 5, STDOUT) call putch ('|', STDOUT) } else { call putlin (blank_i_blank, STDOUT) call putint (ni - 1, 4, STDOUT) call putlin (n_bar, STDOUT) } call putlin (line, STDOUT) } } else if (Old_count (oi) == 1 & New_count (ni) != 1) { call putch ('@n', STDOUT) for (; Old_count (oi) == 1; oi = oi + 1) { junk = getlin (line, Old_copy) if (Verbos == YES) { call putlin (blank_d, STDOUT) call putint (oi - 1, 5, STDOUT) call putlin (five_blanks_bar, STDOUT) } else { call putlin (blank_d, STDOUT) call putint (oi - 1, 5, STDOUT) call putlin (o_bar, STDOUT) } call putlin (line, STDOUT) } } else if (Old_count (oi) == 1 & New_count (ni) == 1) { call putch ('@n', STDOUT) for (; Old_count (oi) == 1; oi = oi + 1) { junk = getlin (line, Old_copy) if (Verbos == YES) { call putlin (c_d, STDOUT) call putint (oi - 1, 5, STDOUT) call putlin (five_blanks_bar, STDOUT) } else { call putlin (c_d, STDOUT) call putint (oi - 1, 5, STDOUT) call putlin (o_bar, STDOUT) } call putlin (line, STDOUT) } call putch ('@n', STDOUT) for (; New_count (ni) == 1; ni = ni + 1) { junk = getlin (line, New_copy) if (Verbos == YES) { call putlin (c_i_five_blanks, STDOUT) call putint (ni - 1, 5, STDOUT) call putch ('|', STDOUT) } else { call putlin (c_i_blank, STDOUT) call putint (ni - 1, 4, STDOUT) call putlin (n_bar, STDOUT) } call putlin (line, STDOUT) } } else if (Old_count (oi) == 2 & New_count (ni) == 2) break return end #-h- grevis 1824 asc 25-mar-82 07:38:55 v1.1 (sw-tools v1.1) # gen_revision --- generate 'fmt' input text with revision bar requests subroutine gen_revision include cdiff sym_pointer oi, ni integer junk integer getlin character line (MAXLINE) string start_revision_bar "[cc]mc |" string stop_revision_bar "[cc]mc" string start_deletion_star "[cc]mc *" string stop_deletion_star "[cc]mc" oi = 2 ni = 2 repeat if (Old_count (oi) == 0 & New_count (ni) == 0) { oi = oi + 1 ni = ni + 1 junk = getlin (line, New_copy) call putlin (line, STDOUT) } else if (Old_count (oi) != 1 & New_count (ni) == 1) { call putlin (start_revision_bar, STDOUT) call putch ('@n', STDOUT) for (; New_count (ni) == 1; ni = ni + 1) { junk = getlin (line, New_copy) call putlin (line, STDOUT) } call putlin (stop_revision_bar, STDOUT) call putch ('@n', STDOUT) } else if (Old_count (oi) == 1 & New_count (ni) != 1) { call putlin (start_deletion_star, STDOUT) call putch ('@n', STDOUT) call putlin (stop_deletion_star, STDOUT) call putch ('@n', STDOUT) for (; Old_count (oi) == 1; oi = oi + 1) ; } else if (Old_count (oi) == 1 & New_count (ni) == 1) { for (; Old_count (oi) == 1; oi = oi + 1) ; call putlin (start_revision_bar, STDOUT) call putch ('@n', STDOUT) for (; New_count (ni) == 1; ni = ni + 1) { junk = getlin (line, New_copy) call putlin (line, STDOUT) } call putlin (stop_revision_bar, STDOUT) call putch ('@n', STDOUT) } else if (Old_count (oi) == 2 & New_count (ni) == 2) break return end %%D 2 #-h- gscrip 2263 asc 25-mar-82 07:38:57 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- gscrip 2266 asc 04-may-82 12:11:45 j (sventek j) %%E 2 # gen_script --- produce editor script to convert old file into new subroutine gen_script include cdiff sym_pointer oi, ni, offset, length integer junk integer getlin character line (MAXLINE) oi = 2 ni = 2 offset = 0 repeat if (Old_count (oi) == 0 & New_count (ni) == 0) { oi = oi + 1 ni = ni + 1 junk = getlin (line, New_copy) } else if (Old_count (oi) != 1 & New_count (ni) == 1) { call putint (oi - 2 + offset, 0, STDOUT) call putch ('a', STDOUT) call putch ('@n', STDOUT) length = 0 for (; New_count (ni) == 1; ni = ni + 1) { length = length + 1 junk = getlin (line, New_copy) call putlin (line, STDOUT) } call putch ('.', STDOUT) call putch ('@n', STDOUT) offset = offset + length } else if (Old_count (oi) == 1 & New_count (ni) != 1) { length = 0 for (; Old_count (oi) == 1; oi = oi + 1) length = length + 1 call putint (oi - 1 - length + offset, 0, STDOUT) call putch (',', STDOUT) %%D 2 call putint (oi - 2 + offset, STDOUT) %%E 2 %%I 2 call putint (oi - 2 + offset, 0, STDOUT) %%E 2 call putch ('d', STDOUT) call putch ('@n', STDOUT) offset = offset - length } else if (Old_count (oi) == 1 & New_count (ni) == 1) { length = 0 for (; Old_count (oi) == 1; oi = oi + 1) length = length + 1 call putint (oi - 1 - length + offset, 0, STDOUT) call putch (',', STDOUT) call putint (oi - 2 + offset, 0, STDOUT) call putch ('c', STDOUT) call putch ('@n', STDOUT) offset = offset - length length = 0 for (; New_count (ni) == 1; ni = ni + 1) { length = length + 1 junk = getlin (line, New_copy) call putlin (line, STDOUT) } call putch ('.', STDOUT) call putch ('@n', STDOUT) offset = offset + length } else if (Old_count (oi) == 2 & New_count (ni) == 2) break call putch ('w', STDOUT) call putch ('@n', STDOUT) # DON'T output a 'q' command -- prevents concatentation of scripts return end #-h- grow 751 asc 25-mar-82 07:38:58 v1.1 (sw-tools v1.1) # grow --- grow unchanged blocks around unique line pairs subroutine grow include cdiff sym_pointer i, nx for (i = 1; i < New_size; i = i + 1) { nx = New_xref (i) if (nx > 0) # is this line paired with an old line? if (New_xref (i + 1) < 0 & New_xref (i + 1) == Old_xref (nx + 1)) { Old_xref (nx + 1) = i + 1 New_xref (i + 1) = nx + 1 } } for (i = New_size; i > 1; i = i - 1) { nx = New_xref (i) if (nx > 0) # is this line paired? if (New_xref (i - 1) < 0 & New_xref (i - 1) == Old_xref (nx - 1)) { Old_xref (nx - 1) = i - 1 New_xref (i - 1) = nx - 1 } } return end #-h- hash 267 asc 25-mar-82 07:38:58 v1.1 (sw-tools v1.1) # hash --- hash a line into a hash_index hash_index function hash (line) character line (ARB) integer i hash = 0 for (i = 1; line (i) != EOS; i = i + 1) hash = hash + line (i) hash = mod (iabs (hash), HASH_TABLE_SIZE) + 1 return end #-h- init 2403 asc 25-mar-82 07:38:59 v1.1 (sw-tools v1.1) # initialize --- set up everything needed for a file comparison subroutine initialize include cdiff filedes open, create integer argno, i, junk integer equal, getarg, note character arg (FILENAMESIZE) string tf1 "df1" # text of unique lines string tf2 "df2" # copy of "old" file string tf3 "df3" # copy of "new" file call query ("usage: diff [-{c|d|r|s|v}] old_file [new_file].") Option = DIFFERENCES # the default Verbos = NO argno = 1 # where we expect to find file names if (getarg (1, arg, FILENAMESIZE) != EOF) if (arg (1) == '-') { call lower (arg) for (i = 2; arg (i) != EOS; i = i + 1) if (arg (i) == 'c') Option = COMPARISON else if (arg (i) == 'd') Option = DIFFERENCES else if (arg (i) == 'r') Option = REVISION else if (arg (i) == 's') Option = SCRIPT else if (arg (i) == 'v') Verbos = YES else call usage argno = 2 } if (getarg (argno, arg, FILENAMESIZE) == EOF) { # no files, use STDIN # Old_file = STDIN1 # New_file = STDIN2 call usage # GT implementation has multiple standard ports... } else { Old_file = open (arg, READ) if (Old_file == ERR) call cant (arg) argno = argno + 1 if (getarg (argno, arg, FILENAMESIZE) == EOF) New_file = STDIN # STDIN1, to be precise else { New_file = open (arg, READ) if (New_file == ERR) call cant (arg) argno = argno + 1 call close(STDIN) # save a unit } } if (getarg (argno, arg, FILENAMESIZE) != EOF) call usage Next_inx = 1 Next_sym = 1 call mkuniq (tf1, Text_file_name) Text_file = create (Text_file_name, READWRITE) if (Text_file == ERR) call error ("can't open temporary file.") junk = note(Text_file_end, Text_file) call mkuniq (tf2, Old_copy_name) Old_copy = create (Old_copy_name, READWRITE) if (Old_copy == ERR) call error ("can't open temporary file.") junk = note(Old_copy_start, Old_copy) call mkuniq (tf3, New_copy_name) New_copy = create (New_copy_name, READWRITE) if (New_copy == ERR) call error ("can't open temporary file.") junk = note(New_copy_start, New_copy) return end #-h- label 1871 asc 25-mar-82 07:39:00 v1.1 (sw-tools v1.1) # label --- label lines as "inserted," "deleted," or "unchanged" subroutine label include cdiff sym_pointer oi, ni, ox, nx DEBUG call remark ("input new xref:.") DEBUG do ni = 1, New_size; { DEBUG call putch (' ', ERROUT) DEBUG call putint (New_xref (ni), 0, ERROUT) DEBUG } DEBUG call putch ('@n', ERROUT) DEBUG call remark ("input old xref:.") DEBUG do oi = 1, Old_size; { DEBUG call putch (' ', ERROUT) DEBUG call putint (Old_xref (oi), 0, ERROUT) DEBUG } DEBUG call putch ('@n', ERROUT) oi = 2 ni = 2 repeat { ox = Old_xref (oi) nx = New_xref (ni) if (oi >= Old_size & ni >= New_size) break else if (oi < Old_size & ox < 0) { # deletion from old file Old_count (oi) = 1 oi = oi + 1 } else if (ni < New_size & nx < 0) { # insertion in new file New_count (ni) = 1 ni = ni + 1 } else if (ox == ni & nx == oi) { # unchanged line Old_count (oi) = 0 oi = oi + 1 New_count (ni) = 0 ni = ni + 1 } else if (oi <= Old_size & ni <= New_size) { # out-of-order block New_count (ni) = 1 ni = ni + 1 Old_count (nx) = 1 Old_count (oi) = 1 oi = oi + 1 New_count (ox) = 1 } else { call remark ("oi, ox, ni, nx:.") call putint (oi, 10, ERROUT) call putint (ox, 10, ERROUT) call putint (ni, 10, ERROUT) call putint (nx, 10, ERROUT) call putch ('@n', ERROUT) call error ("in label: can't happen.") } } Old_count (1) = 2 # mark the null lines specially, Old_count (Old_size) = 2 # so people won't have to deal New_count (1) = 2 # with file sizes New_count (New_size) = 2 return end #-h- load 2085 asc 25-mar-82 07:39:02 v1.1 (sw-tools v1.1) # load --- load symbol table, set up cross-reference structures subroutine load include cdiff sym_pointer lno, i sym_pointer enter hash_index h character line (MAXLINE) integer getlin, length TUNING sym_pointer p TUNING integer used, chain_len, max_chain_len, min_chain_len do h = 1, HASH_TABLE_SIZE Bucket (h) = NULL_POINTER do lno = 1, MAX_UNIQUE_LINES; { Old_count (lno) = 0 New_count (lno) = 0 } # Load the "old" file: for (lno = 2; getlin (line, Old_file) != EOF; lno = lno + 1) { if (lno > MAX_FILE_SIZE) call error ("old file too large to handle.") call putlin (line, Old_copy) i = enter (line) Old_count (i) = Old_count (i) + 1 Old_lno (i) = lno Old_xref (lno) = -i } Old_size = lno # includes null line at end # Load the "new" file: for (lno = 2; getlin (line, New_file) != EOF; lno = lno + 1) { if (lno > MAX_FILE_SIZE) call error ("new file too large to handle.") call putlin (line, New_copy) i = enter (line) New_count (i) = New_count (i) + 1 New_xref (lno) = -i } New_size = lno # also allows for null line at end TUNING call print (STDOUT2, "Old_size = *i, New_size = *i*n"s, TUNING Old_size, New_size) TUNING call print (STDOUT2, "*i unique lines*n"s, Next_inx - 1) TUNING used = 0 TUNING max_chain_len = 0 TUNING min_chain_len = MAX_UNIQUE_LINES TUNING do h = 1, HASH_TABLE_SIZE; { TUNING p = Bucket (h) TUNING if (p != NULL_POINTER) TUNING used += 1 TUNING chain_len = 0 TUNING while (p != NULL_POINTER) { TUNING chain_len += 1 TUNING p = Sym_store (p) TUNING } TUNING max_chain_len = max0 (chain_len, max_chain_len) TUNING min_chain_len = min0 (chain_len, min_chain_len) TUNING } TUNING call print (STDOUT2, "chain lengths: min = *i, avg = *i, max = *i*n"s, TUNING min_chain_len, (Next_inx - 1) / used, max_chain_len) TUNING call print (STDOUT2, "hash buckets *i% full*n"s, TUNING (100 * used) / HASH_TABLE_SIZE) return end #-h- pair 536 asc 25-mar-82 07:39:03 v1.1 (sw-tools v1.1) # pair --- pair up unique lines in both files subroutine pair include cdiff sym_pointer i, j, k for (i = 2; i < New_size; i = i + 1) { j = -New_xref (i) if (Old_count (j) == 1 & New_count (j) == 1) { # unique pair New_xref (i) = Old_lno (j) k = Old_lno (j) Old_xref (k) = i } } New_xref (1) = 1 # match null lines at BOF Old_xref (1) = 1 New_xref (New_size) = Old_size # ... and at EOF Old_xref (Old_size) = New_size return end #-h- report 714 asc 25-mar-82 07:39:04 v1.1 (sw-tools v1.1) # report --- report differences between files in desired format subroutine report include cdiff DEBUG sym_pointer i DEBUG call print (ERROUT, "New mark: "s) DEBUG do i = 1, New_size DEBUG call print (ERROUT, " *i"s, New_count (i)) DEBUG call print (ERROUT, "*nOld mark: "s) DEBUG do i = 1, Old_size DEBUG call print (ERROUT, " *i"s, Old_count (i)) DEBUG call putch ('@n', ERROUT) call seek (Old_copy_start, Old_copy) call seek (New_copy_start, New_copy) if (Option == DIFFERENCES) call gen_listing else if (Option == REVISION) call gen_revision else if (Option == SCRIPT) call gen_script else call error ("in report: can't happen.") return end #-h- scompr 1450 asc 25-mar-82 07:39:04 v1.1 (sw-tools v1.1) # simple_compare --- do a line-by-line comparison of the input files subroutine simple_compare include cdiff character line1 (MAXLINE), line2 (MAXLINE) integer lineno, m1, m2 integer equal, getlin string different "different" string eof_on_old_file "eof on old file" string eof_on_new_file "eof on new file" lineno = 0 repeat { m1 = getlin (line1, Old_file) m2 = getlin (line2, New_file) if (m1 == EOF | m2 == EOF) break lineno = lineno + 1 if (equal (line1, line2) == NO) if (Verbos == YES) { call putch ('@n', STDOUT) call putint (lineno, 5, STDOUT) call putch ('@n', STDOUT) call putlin (line1, STDOUT) call putlin (line2, STDOUT) } else { call putlin (different, STDOUT) call putch ('@n', STDOUT) return } } if (m1 == EOF & m2 != EOF) if (Verbos == YES) { call putlin (eof_on_old_file, STDOUT) call putch ('@n', STDOUT) } else { call putlin (different, STDOUT) call putch ('@n', STDOUT) } if (m1 != EOF & m2 == EOF) if (Verbos == YES) { call putlin (eof_on_new_file, STDOUT) call putch ('@n', STDOUT) } else { call putlin (different, STDOUT) call putch ('@n', STDOUT) } return end #-h- usage 139 asc 25-mar-82 07:39:05 v1.1 (sw-tools v1.1) # usage --- print usage message, then die subroutine usage call error ("usage: diff [-{c|d|r|s|v}] old_file [new_file].") end #-h- diff.fmt 3460 asc 25-mar-82 07:39:39 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Diff (1) 20-Mar-80 isolate differences between files .sy diff [-{c|d|r|s|v}] old_file [new_file] .ds 'Diff' compares the contents of two files and reports on the differences between them. The default behavior is to describe the insert, delete, and change operations that must be performed on `old_file' to convert its contents into those of `new_file'. .sp The second file name argument is optional. If omitted, the standard input is read for the text of the `new_file'. .sp The options currently available are: .in +10 .rm -5 .sp .ti -5 -c Perform a simple line-by-line comparison. 'Diff' will compare successive lines of the input files; if any corresponding lines differ, or if one file is shorter than the other, 'diff' prints the message "different" and exits. If the files are the same, 'diff' produces no output. When the "-v" option (see below) is specified, 'diff' prints the lines that differ along with their line number in the input file, and notifies the user if one file is shorter than the other. .sp .ti -5 -d List the "differences" between the two files, by highlighting the insertions, deletions, and changes that will convert `old_file' into `new_file'. This is the default option. If the "verbose" option "-v" (see below) is specified, unchanged text will also be listed. .sp .ti -5 -r Insert text formatter requests to mark the `new_file' with revision bars and deletion asterisks. This option is particularly useful for maintenance of large documents, like Software Tools reference manuals. (At present, only GT's version of 'format' can produce revision bars.) .sp .ti -5 -s Output a "script" of commands for the text editor 'ed' that will convert `old_file' into `new_file'. This is handy for preparing updates to large programs or data files, since generally the volume of changes required will be much smaller than the new text in its entirety. .sp .ti -5 -v Make output "verbose." This option applies to the "-c" and "-d" options discussed above. If not selected, 'diff' produces "concise" output; if selected, 'diff' produces more verbiage. .sp .in -10 'Diff' is based on the algorithm found in Heckel, P., "A Technique for Isolating Differences Between Files", .ul Comm. ACM 21, 4 (April 1978), 264-268. .ex To print the differences between two files on your terminal: .in -5 .sp diff -cv file maybe_the_same_file .br .in +5 does a simple line-by-line comparison on the two files, printing lines which differ. (Expects no missing or extra lines.) Same as 'cmp file1 file2'. .in -5 .sp diff -s old_version new_version | ed - old_version .br .in +5 make an ed script which changes 'old_version' into 'new_version' .in -5 .sp diff -r old_manual.fmt new_manual.fmt | format .br .in +5 to mark changes in a document. Useful only if your version of 'format' has this capability. .in -5 .sp diff -s old new >>update_old_to_new .br .in +5 to keep a list of changes made to an original source file .in -5 .fi .sp .ne 2 .di ": can't open" if either `new_file' or `old_file' is not readable. .sp "Usage: diff . . ." for illegal options. .ne 4 .au Allen Akin and friends, Georgia Institute of Technology .ne 2 .bu The algorithm used has one quirk: a line or a block of lines which is not unique within a file will be labeled as an insertion (deletion) if its immediately adjacent neighbors both above and below are labeled as insertions (deletions). .sp Fails on very large files (> 10000 lines on VMS). %%E 1