[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-grep] Implemented --show-c-function and --show-function-line=RE

From: Charles Levert
Subject: [bug-grep] Implemented --show-c-function and --show-function-line=RE
Date: Mon, 24 Jan 2005 18:39:02 -0500
User-agent: Mutt/1.4.1i


I have implemented

  -p  --show-c-function     show which C function each range of lines is in
                            show most recent line matching RE before range

based on a version of GNU grep I currently use (2.5.1-29 from Fedora
Core).  The option names are compatible with those of GNU diff ("-F"
is omitted for an obvious reason).

This feature comes in very handy (combined with context lines or not)
when, e.g., grepping through code to find out where and how a variable
might be used.  Without the option, the output is unchanged (i.e.,
still standard compliant).

I coded this for myself, but I hope there is some general interest for it.
At this point, I just wanted the readers of this list to be aware of
this development (and so that no effort is duplicated if someone else
ever got the same idea).  I explain below why it would be of limited
use to release the code at this point.

Of course, I have implemented this on top of my GREP_COLORS code, but
this accounts for a very little part of the changes.

Implementing this involved making sure grep's internal matcher could
be set up and invoked on two different regular expressions (the main
PATTERN and the RE above for function lines).  This meant in turn that
the code in src/search.c and src/dfa.c had to no longer rely on static
variables.  This is done through the introduction of an opaque
"struct match_handle" and a revealed "struct match_spec" for src/search.c,
and through the introduction of "struct dfa_syntax", "struct dfa_lex",
and "struct dfa_parse" to extend by inclusion the existing "struct dfa"
for src/dfa.c.  Variables shared between different sources files through
the "extern" mechanism are also gone (as is the need for the now empty

As I have indicated above, I have implemented this on top of a Fedora
Core version which includes several enhancements such as the addition of
something called "mb_cache".  I have seen in the archives of the list
that there was an intention to "integrate all the Red Hat patches", so
I don't know if this is part of it.  (If integrated, this "mb_cache"
code would also benefit from being isolated in a src/mbcache.c file,
behind an interface with an opaque instead of revealed "struct mb_cache".)

So this possible lack of an up-to-date and stabilized base (I may be wrong
on this; just tell me) justifies why I am waiting to release my new code.
However, if anybody would like to have a copy of it now, just ask,
no problem.

What is the list of all that's considered pending to be integrated at
this point?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]