hi, i notice when comparing identical files with diff -u the header is always printed: % diff -u /dev/null /dev/null --- /tmp/diff100000021006 +++ /tmp/diff200000021006 i dont think this is correct and is not consistent with other diff formats like -c. i think the header should be printed only when there is at least one change (diff hunk), and only before the first change in a given file. it look like change() in diffio.c is only called when there is at least one change, and it already keeps track if the first change has been seen already. diff below moves the -u header printing into change() under the 'firstchange' condition. ive been testing this for a few days under different conditions and it has been working well: % diff -u /dev/null /dev/null % indeed the diff -u below was created with the diff below applied. kyle diff e2e4a46f26ff7268a696a45d82414fb992b648d5 uncommitted --- a/sys/src/cmd/diff/diff.h +++ b/sys/src/cmd/diff/diff.h @@ -22,6 +22,5 @@ void panic(int, char *, ...); void check(Biobuf *, Biobuf *); void change(int, int, int, int); -void fileheader(void); void flushchanges(void); --- a/sys/src/cmd/diff/diffio.c +++ b/sys/src/cmd/diff/diffio.c @@ -267,16 +267,22 @@ if (a > b && c > d) return; anychange = 1; - if (mflag && firstchange == 0) { - if(mode) { - buf[0] = '-'; - buf[1] = mode; - buf[2] = ' '; - buf[3] = '\0'; - } else { - buf[0] = '\0'; + if (firstchange == 0) { + if (mflag) { + if(mode) { + buf[0] = '-'; + buf[1] = mode; + buf[2] = ' '; + buf[3] = '\0'; + } else { + buf[0] = '\0'; + } + Bprint(&stdout, "diff %s%s %s\n", buf, file1, file2); } - Bprint(&stdout, "diff %s%s %s\n", buf, file1, file2); + if (mode == 'u') { + Bprint(&stdout, "--- %s\n", file1); + Bprint(&stdout, "+++ %s\n", file2); + } firstchange = 1; } verb = a > b ? 'a': c > d ? 'd': 'c'; @@ -337,15 +343,6 @@ if(i