anand@crysiris.rice.edu (Anand Kolatkar) (12/20/90)
Sorry if if duplicated this posting, but I'm having a problem with the diff command. When I enter the following command: diff example1.f example2.f, all I get is some statement saying the two binary files differ. First, why does diff think that the two fortran code(ascii) files are binary? Also, why does diff not list out the differences? Any explanation of this problem (probably my UNIX ignorance) would be appreciated. Anand Kolatkar anand@crysiris.rice.edu -- // Anand Kolatkar E-mail: anand@crysiris.rice.edu // // Rice University // // Dept. of Biochemistry and Cell Biology //
pj@giraffe.asd.sgi.com (Paul Jackson) (12/22/90)
In article <1990Dec20.004248.2921@rice.edu>, anand@crysiris.rice.edu (Anand Kolatkar) writes: |> I'm having a problem with the diff command. |> When I enter the following command: |> diff example1.f example2.f, |> all I get is some statement saying the two binary files differ. There is currently a low priority bug filed against diff inside SGI, which probably also explains your problem. It seems that diff has this same problem with SCCS s. files as well. The rest of this followup is a quote in full of the bug report, since I'm not sure what details in it might be most helpful to you. Attempts to diff two SCCS s. files fail with the complaint: Binary files s.filename1.c and s.filename2.c differ This is because the ISCOFF macro in the /usr/include/filehdr.h is used by diff to identify object files, and this macro checks for everything but the kitchen sink in the way of known object file types, including byte backwards machines like the 3B series. The magic number N3BMAGIC == 0550 (for file type: 3B20 executable, no TV) is the same short as the lead SCCS file characters of ^Ah (control-A, letter h), on machines with SGI byte ordering. The minimalist solution might be to add a check in the cmd/diff/diffreg.c routine called asciifile(), to decide that a file is an ascii file if it starts with ^Ah, prior to checking for ISCOFF. A more ambitious attempt might change the ISCOFF macro in filehdr.h (risky) and/or look throughout the source tree for other users of this macro, and in each case, ask what should be done with SCCS s.files. An alternative solution might be to simply skip the ISCOFF check altogether, since asciifile() also checks for bytes with high bit set, which is a better check that will surely find object files. It's too bad that good old diff has to have such heuristics. Since POSIX 1003.2 has apparently discarded the "file" command (a heuristic bag of tricks for identifying file types) because it was heuristic, I'll bet that if they thought about it, they would not want diff to have heuristics for text files either. Indeed the AT&T SVR4 source for cmd/diff/diff.c has none of this stuff. It will happily diff binaries, SCCS, ... The real solution: delete this error and asciifile() routine from diff altogether. -- I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj@asd.sgi.com), x1373