mirror of
https://https.git.savannah.gnu.org/git/diffutils.git
synced 2026-01-27 09:54:25 +00:00
with -F or -p, emit better function lines: no leading white space
* src/diff.c (print_context_function): For languages like Ada that allow local functions and procedures, the plain context function line may start with enough blank characters that the function name does not get completely printed in the 40 characters limit. This patch solves this problem by removing these useless initial blank characters. * NEWS (Changes in behavior): Mention this change.
This commit is contained in:
parent
d9c2b10e33
commit
24cc227fa1
7
NEWS
7
NEWS
@ -4,6 +4,13 @@ GNU diffutils NEWS -*- outline -*-
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
In context-style diffs, diff prints a portion of a preceding "function"
|
||||
line for each hunk, with --show-function-line=RE (-F) or
|
||||
--show-c-function (-p). Now, it trims leading blanks from such lines
|
||||
before extracting a prefix. This is useful especially when a function
|
||||
line is so far indented that the name itself would be truncated or not
|
||||
included in the limited-width substring that diff appends.
|
||||
|
||||
diff once again reports a difference with the diagnostic
|
||||
"Binary files A and B differ" when at least one of the files
|
||||
appears to be binary. From 2.8.4 through diffutils-2.9, it printed
|
||||
|
||||
@ -145,13 +145,15 @@ print_context_number_range (struct file_data const *file, lin a, lin b)
|
||||
static void
|
||||
print_context_function (FILE *out, char const *function)
|
||||
{
|
||||
int i;
|
||||
int i, j;
|
||||
putc (' ', out);
|
||||
for (i = 0; i < 40 && function[i] != '\n'; i++)
|
||||
for (i = 0; isspace ((unsigned char)function[i]) && function[i] != '\n'; i++)
|
||||
continue;
|
||||
while (0 < i && isspace ((unsigned char) function[i - 1]))
|
||||
i--;
|
||||
fwrite (function, sizeof (char), i, out);
|
||||
for (j = i; j < i + 40 && function[j] != '\n'; j++)
|
||||
continue;
|
||||
while (i < j && isspace ((unsigned char) function[j - 1]))
|
||||
j--;
|
||||
fwrite (function + i, sizeof (char), j - i, out);
|
||||
}
|
||||
|
||||
/* Print a portion of an edit script in context format.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user