"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: diff -p function prototypes regression
To:
gameoftrees@openbsd.org, Tom Jones <thj@freebsd.org>
Date:
Tue, 22 Aug 2023 11:57:48 +0200

Download raw body.

Thread
On Tue, Aug 22, 2023 at 11:25:53AM +0200, Stefan Sperling wrote:
> Since diff.git commit 8993f42562696079866fc2dec7191877b6cc1f18 which
> intentionally changed the line index where we start searching upwards
> for a function prototype, there is a difference in behaviour compared
> to traditional usr.bin/diff -p. Unfortunately this difference can result
> in confusing output, such as the following reported by tb@ and sthen@.

I think the change should be reverted as it brings a loss of information.
diff -p is a hack, but it usually has helpful additional info.

diff -p is documented this way (FreeBSD version, OpenBSD has the same
text except for the long option):

     -p	--show-c-function
	     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 fol-
	     lowing standard layout conventions, this will show	the prototype
	     of	the function the change	applies	to.

The change (and its variant that was applied to FreeBSD's diff) attempts
to improve code to follow the second sentence more closely. The tradeoff
is that it makes the first sentence incorrect.

I think the better fix would be to change the second sentence to say
'will usually show the prototype of the function the change applies to.'