diff options
author | Jeff King <peff@peff.net> | 2014-03-04 19:36:40 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-03-05 12:27:47 -0800 |
commit | 53ad86ef569bdcb91da9cd2a2a0322620c978389 (patch) | |
tree | b9d695a4a8255efcafb953a31c46b56d613157f2 /compat/unsetenv.c | |
parent | 5f95c9f850b19b368c43ae399cc831b17a26a5ac (diff) | |
download | git-jk/diff-funcname-cpp-regex.tar.gz |
diff: simplify cpp funcname regexjk/diff-funcname-cpp-regex
The current funcname matcher for C files requires one or
more words before the function name, like:
static int foo(int arg)
{
However, some coding styles look like this:
static int
foo(int arg)
{
and we do not match, even though the default regex would.
This patch simplifies the regex significantly. Rather than
trying to handle all the variants of keywords and return
types, we simply look for an identifier at the start of the
line that contains a "(", meaning it is either a function
definition or a function call, and then not containing ";"
which would indicate it is a call or declaration.
This can be fooled by something like:
if (foo)
but it is unlikely to find that at the very start of a line
with no identation (and without having a complete set of
keywords, we cannot distinguish that from a function called
"if" taking "foo" anyway).
We had no tests at all for .c files, so this attempts to add
a few obvious cases (including the one we are fixing here).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat/unsetenv.c')
0 files changed, 0 insertions, 0 deletions