Hello,
On Tue, 19 May 2020, Martin Liška wrote:
> > The common problems I remember is that e.g. when changing a function comment
> > above some function, it is attributed to the previous function rather than
> > following, labels in function confusing it:
> > void
> > foo ()
> > {
> > ...
> > label:
> > ...
> > - ...
> > + ...
> > }
>
> I've just tested that and it will take function for patch context
> (sem_variable::equals):
> @@ -1875,6 +1875,7 @@ sem_variable::equals (tree t1, tree t2)
> default:
> return return_false_with_msg ("Unknown TREE code reached");
> }
> +
> }
No, the problem happens when the label is at column 0, like function names
are. Basically diff -p uses a regexp morally equivalent to
'^[[:alpha:]$_]' to detect function headers, and git diff -p and friends
followed suit. But it should use something like
'^[[:alpha:]$_].*[^:]$' to rule out things ending with ':'. See also diff
-F for GNU diff.
Ciao,
Michael.