diff: eliminate space at end of line
No functionnal changes
This commit is contained in:
parent
fa977a3b2b
commit
15abb23286
@ -268,17 +268,17 @@ diffreg(char *file1, char *file2, int flags, int capsicum)
|
||||
lastmatchline = 0;
|
||||
context_vec_ptr = context_vec_start - 1;
|
||||
|
||||
/*
|
||||
* hw excludes padding and make sure when -t is not used,
|
||||
/*
|
||||
* hw excludes padding and make sure when -t is not used,
|
||||
* the second column always starts from the closest tab stop
|
||||
*/
|
||||
if (diff_format == D_SIDEBYSIDE) {
|
||||
if (diff_format == D_SIDEBYSIDE) {
|
||||
hw = width >> 1;
|
||||
padding = tabsize - (hw % tabsize);
|
||||
if ((flags & D_EXPANDTABS) != 0 || (padding % tabsize == 0))
|
||||
padding = MIN_PAD;
|
||||
|
||||
hw = (width >> 1) -
|
||||
hw = (width >> 1) -
|
||||
((padding == MIN_PAD) ? (padding << 1) : padding) - 1;
|
||||
}
|
||||
|
||||
@ -901,14 +901,14 @@ output(char *file1, FILE *f1, char *file2, FILE *f2, int flags)
|
||||
if (diff_format != D_EDIT) {
|
||||
for (i0 = 1; i0 <= m; i0 = i1 + 1) {
|
||||
while (i0 <= m && J[i0] == J[i0 - 1] + 1){
|
||||
if (diff_format == D_SIDEBYSIDE &&
|
||||
if (diff_format == D_SIDEBYSIDE &&
|
||||
suppress_common != 1) {
|
||||
nc = fetch(ixold, i0, i0, f1, '\0',
|
||||
nc = fetch(ixold, i0, i0, f1, '\0',
|
||||
1, flags);
|
||||
print_space(nc,
|
||||
(hw - nc) + (padding << 1) + 1,
|
||||
print_space(nc,
|
||||
(hw - nc) + (padding << 1) + 1,
|
||||
flags);
|
||||
fetch(ixnew, J[i0], J[i0], f2, '\0',
|
||||
fetch(ixnew, J[i0], J[i0], f2, '\0',
|
||||
0, flags);
|
||||
diff_output("\n");
|
||||
}
|
||||
@ -922,32 +922,32 @@ output(char *file1, FILE *f1, char *file2, FILE *f2, int flags)
|
||||
J[i1] = j1;
|
||||
|
||||
/*
|
||||
* When using side-by-side, lines from both of the
|
||||
* files are printed. The algorithm used by diff(1)
|
||||
* identifies the ranges in which two files differ.
|
||||
* See the change() function below.
|
||||
* The for loop below consumes the shorter range,
|
||||
* whereas one of the while loops deals with the
|
||||
* When using side-by-side, lines from both of the
|
||||
* files are printed. The algorithm used by diff(1)
|
||||
* identifies the ranges in which two files differ.
|
||||
* See the change() function below.
|
||||
* The for loop below consumes the shorter range,
|
||||
* whereas one of the while loops deals with the
|
||||
* longer one.
|
||||
*/
|
||||
if (diff_format == D_SIDEBYSIDE) {
|
||||
for (i=i0, j=j0; i<=i1 && j<=j1; i++, j++)
|
||||
change(file1, f1, file2, f2, i, i,
|
||||
for (i=i0, j=j0; i<=i1 && j<=j1; i++, j++)
|
||||
change(file1, f1, file2, f2, i, i,
|
||||
j, j, &flags);
|
||||
|
||||
while (i <= i1) {
|
||||
change(file1, f1, file2, f2,
|
||||
change(file1, f1, file2, f2,
|
||||
i, i, j+1, j, &flags);
|
||||
i++;
|
||||
}
|
||||
|
||||
while (j <= j1) {
|
||||
change(file1, f1, file2, f2,
|
||||
change(file1, f1, file2, f2,
|
||||
i+1, i, j, j, &flags);
|
||||
j++;
|
||||
}
|
||||
} else
|
||||
change(file1, f1, file2, f2, i0, i1, j0,
|
||||
change(file1, f1, file2, f2, i0, i1, j0,
|
||||
j1, &flags);
|
||||
}
|
||||
} else {
|
||||
@ -1187,10 +1187,10 @@ change(char *file1, FILE *f1, char *file2, FILE *f2, int a, int b, int c, int d,
|
||||
print_space(0, hw + padding , *pflags);
|
||||
} else {
|
||||
nc = fetch(ixold, a, b, f1, '\0', 1, *pflags);
|
||||
print_space(nc, hw - nc + padding, *pflags);
|
||||
print_space(nc, hw - nc + padding, *pflags);
|
||||
}
|
||||
diff_output("%c", (a>b)? '>' : ((c>d)? '<' : '|'));
|
||||
print_space(hw + padding + 1 , padding, *pflags);
|
||||
print_space(hw + padding + 1 , padding, *pflags);
|
||||
fetch(ixnew, c, d, f2, '\0', 0, *pflags);
|
||||
diff_output("\n");
|
||||
}
|
||||
@ -1259,13 +1259,13 @@ fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile, int flags)
|
||||
for (i = a; i <= b; i++) {
|
||||
fseek(lb, f[i - 1], SEEK_SET);
|
||||
nc = (f[i] - f[i - 1]);
|
||||
if (diff_format == D_SIDEBYSIDE && hw < nc)
|
||||
if (diff_format == D_SIDEBYSIDE && hw < nc)
|
||||
nc = hw;
|
||||
if ((diff_format != D_IFDEF && diff_format != D_GFORMAT) &&
|
||||
if ((diff_format != D_IFDEF && diff_format != D_GFORMAT) &&
|
||||
ch != '\0') {
|
||||
diff_output("%c", ch);
|
||||
if (Tflag && (diff_format == D_NORMAL ||
|
||||
diff_format == D_CONTEXT ||
|
||||
if (Tflag && (diff_format == D_NORMAL ||
|
||||
diff_format == D_CONTEXT ||
|
||||
diff_format == D_UNIFIED))
|
||||
diff_output("\t");
|
||||
else if (diff_format != D_UNIFIED)
|
||||
@ -1274,7 +1274,7 @@ fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile, int flags)
|
||||
col = 0;
|
||||
for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) {
|
||||
if ((c = getc(lb)) == EOF) {
|
||||
if (diff_format == D_EDIT ||
|
||||
if (diff_format == D_EDIT ||
|
||||
diff_format == D_REVERSE ||
|
||||
diff_format == D_NREVERSE)
|
||||
warnx("No newline at end of file");
|
||||
@ -1283,8 +1283,8 @@ fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile, int flags)
|
||||
"file\n");
|
||||
return col;
|
||||
}
|
||||
/*
|
||||
* when using --side-by-side, col needs to be increased
|
||||
/*
|
||||
* when using --side-by-side, col needs to be increased
|
||||
* in any case to keep the columns aligned
|
||||
*/
|
||||
if (c == '\t') {
|
||||
@ -1296,9 +1296,9 @@ fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile, int flags)
|
||||
diff_output(" ");
|
||||
} while (++col < newcol && j < nc);
|
||||
} else {
|
||||
if (diff_format == D_SIDEBYSIDE) {
|
||||
if (diff_format == D_SIDEBYSIDE) {
|
||||
if ((j + tabsize) > nc) {
|
||||
diff_output("%*s",
|
||||
diff_output("%*s",
|
||||
nc - j,"");
|
||||
j = col = nc;
|
||||
} else {
|
||||
@ -1690,9 +1690,9 @@ print_header(const char *file1, const char *file2)
|
||||
file2, buf2);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Prints n number of space characters either by using tab
|
||||
* or single space characters.
|
||||
* or single space characters.
|
||||
* nc is the preceding number of characters
|
||||
*/
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user