From: Theo Buehler Subject: Re: diff -p redux To: Dag-Erling Smørgrav Cc: gameoftrees@openbsd.org, thj@freebsd.org Date: Thu, 7 Mar 2024 19:50:43 +0100 On Thu, Mar 07, 2024 at 05:22:55PM +0100, Dag-Erling Smørgrav wrote: > Hi, > > I believe the attached patch solves the issue of function prototype > detection, cf. dc306c6bd88271ab911e205539974da98be82d17. It simply > moves the calculation of chunk_start_line up and passes that to > diff_output_match_function_prototype(), which can then start the search > at the line preceding chunk_start_line. I still think that this change breaks documented behavior. -p With unified and context diffs, show with each change the first 40 characters of the last line before the context beginning with a letter, an underscore or a dollar sign. For C source code following standard layout conventions, this will show the prototype of the function the change applies to. The way I read this, the first sentence clearly and precisely states what -p does. The second sentence is the rationale. FreeBSD has almost identical text. return_test() in the test output below is not "before the context". It really comes down to whether one puts more weight on the first or the second sentence of the quoted text. FreeBSD chose to put more weight on the latter. > diff --git a/test/expect124.diff b/test/expect124.diff > index 82713c2..2ae051a 100644 > --- a/test/expect124.diff > +++ b/test/expect124.diff > @@ -1,6 +1,6 @@ > --- test124.left-p.txt > +++ test124.right-p.txt > -@@ -11,5 +11,5 @@ doSomethingThenPrintHello(int test) This tends to be useful additional info ^ > +@@ -11,5 +11,5 @@ return_test(int test) { This really isn't ^ > > struct testfile * > return_test(int test) { My suggested fix for this would be Index: diff.1 =================================================================== RCS file: /cvs/src/usr.bin/diff/diff.1,v diff -u -p -r1.51 diff.1 --- diff.1 5 Jan 2023 00:00:44 -0000 1.51 +++ diff.1 22 Aug 2023 09:54:39 -0000 @@ -226,7 +226,7 @@ file name and time in the context or uni With unified and context diffs, show with each change the first 40 characters of the last line before the context beginning with a letter, an underscore or a dollar sign. -For C source code following standard layout conventions, this will +For C source code following standard layout conventions, this will usually show the prototype of the function the change applies to. .It Fl T Print a tab rather than a space before the rest of the line for the