diff --git a/NEWS b/NEWS index 569c4ef..2d20b40 100644 --- a/NEWS +++ b/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 diff --git a/src/context.c b/src/context.c index e918134..84120f0 100644 --- a/src/context.c +++ b/src/context.c @@ -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.