diff: fix -u when comparing identical files
This commit is contained in:
parent
160e36aaef
commit
cd7480f68f
3 changed files with 15 additions and 20 deletions
|
@ -22,6 +22,5 @@ Biobuf *prepare(int, char *);
|
||||||
void panic(int, char *, ...);
|
void panic(int, char *, ...);
|
||||||
void check(Biobuf *, Biobuf *);
|
void check(Biobuf *, Biobuf *);
|
||||||
void change(int, int, int, int);
|
void change(int, int, int, int);
|
||||||
void fileheader(void);
|
|
||||||
void flushchanges(void);
|
void flushchanges(void);
|
||||||
|
|
||||||
|
|
|
@ -267,16 +267,22 @@ change(int a, int b, int c, int d)
|
||||||
if (a > b && c > d)
|
if (a > b && c > d)
|
||||||
return;
|
return;
|
||||||
anychange = 1;
|
anychange = 1;
|
||||||
if (mflag && firstchange == 0) {
|
if (firstchange == 0) {
|
||||||
if(mode) {
|
if (mflag) {
|
||||||
buf[0] = '-';
|
if(mode) {
|
||||||
buf[1] = mode;
|
buf[0] = '-';
|
||||||
buf[2] = ' ';
|
buf[1] = mode;
|
||||||
buf[3] = '\0';
|
buf[2] = ' ';
|
||||||
} else {
|
buf[3] = '\0';
|
||||||
buf[0] = '\0';
|
} else {
|
||||||
|
buf[0] = '\0';
|
||||||
|
}
|
||||||
|
Bprint(&stdout, "diff %s%s %s\n", buf, file1, file2);
|
||||||
|
}
|
||||||
|
if (mode == 'u') {
|
||||||
|
Bprint(&stdout, "--- %s\n", file1);
|
||||||
|
Bprint(&stdout, "+++ %s\n", file2);
|
||||||
}
|
}
|
||||||
Bprint(&stdout, "diff %s%s %s\n", buf, file1, file2);
|
|
||||||
firstchange = 1;
|
firstchange = 1;
|
||||||
}
|
}
|
||||||
verb = a > b ? 'a': c > d ? 'd': 'c';
|
verb = a > b ? 'a': c > d ? 'd': 'c';
|
||||||
|
@ -339,15 +345,6 @@ changeset(int i)
|
||||||
return nchanges;
|
return nchanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
fileheader(void)
|
|
||||||
{
|
|
||||||
if(mode != 'u')
|
|
||||||
return;
|
|
||||||
Bprint(&stdout, "--- %s\n", file1);
|
|
||||||
Bprint(&stdout, "+++ %s\n", file2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
flushchanges(void)
|
flushchanges(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -285,7 +285,6 @@ output(void)
|
||||||
m = len[0];
|
m = len[0];
|
||||||
J[0] = 0;
|
J[0] = 0;
|
||||||
J[m+1] = len[1]+1;
|
J[m+1] = len[1]+1;
|
||||||
fileheader();
|
|
||||||
if (mode != 'e') {
|
if (mode != 'e') {
|
||||||
for (i0 = 1; i0 <= m; i0 = i1+1) {
|
for (i0 = 1; i0 <= m; i0 = i1+1) {
|
||||||
while (i0 <= m && J[i0] == J[i0-1]+1)
|
while (i0 <= m && J[i0] == J[i0-1]+1)
|
||||||
|
|
Loading…
Reference in a new issue