git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: diffutils: C labels misdetected as functions

From
Simon Arlott <simon@fire.lp0.eu>
Date
Jul 22, 2007, 19:16 UTC
Message-ID
<46A3AD07.1070504@simon.arlott.org.uk>
In-Reply-To
<87abtogu6u.fsf@penguin.cs.ucla.edu>
On 22/07/07 19:38, Paul Eggert wrote:
Show 7 quoted lines
> Simon Arlott <simon@fire.lp0.eu> writes:
> 
>> The patch below stops diffutils treating C labels starting in column 1 as function names.
> 
> That patch alone wouldn't suffice, since -p is documented as implying
> -F '^[[:alpha:]$_]'.  If the behavior changes, we'd also have to
> change the documentation to match.
Ok.
> I'm not sure the change is a good idea.  It would complicate the
> documentation and therefore the user interface, without that much
Complicated documentation means a bug shouldn't be fixed?
> benefit.  And it wouldn't suffice in general, since it would still
> mishandle labels followed by comments or by white space.
Yes, the regexp needs changing further to ignore comments...

"[[:alpha:]$_][^:]*$" perhaps? Although that ignores functions with comments on the same line containing a :.

> Also, for long C functions some people might rather see a top-level
> (unindented) label highlighted than the function name highlighted, so
> they might prefer the current behavior.
"-p  --show-c-function  Show which C function each change is in."
It's not "--show-c-function-or-label".
> Anyway, to work around your problem without changing "diff", you can
> use "diff -u -F '^[[:alpha:]$_](|.*[^:])$'" instead of "diff -u -p".
Perhaps git could do this (or similar) as a workaround? (Cc:ed)
> Or you can put a single space before the labels in question: they'll
> still stand out plenty.

The code should definitely not need to be modified to work around a diff bug.

-- 
Simon Arlott
Next: Junio C Hamano
Message 1 of 2 in “Re: diffutils: C labels misdetected as functions”
  1. Simon ArlottJul 22, 2007
  2. Junio C HamanoJul 22, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.