diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2010-12-26 03:07:31 -0600 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-12-27 08:47:21 -0800 |
commit | 71a5d4bc0e4025b3fbdeed76052b39fcef284e8c (patch) | |
tree | 4d26bd18d48ba8f87f3e3e3a05be3ff48af3f44b /userdiff.c | |
parent | 73e7b2ef6c62b3ec345b557acb71a8da4798c70d (diff) | |
download | git-71a5d4bc0e4025b3fbdeed76052b39fcef284e8c.tar.gz |
diff: funcname and word patterns for perl
The default function name discovery already works quite well for Perl
code... with the exception of here-documents (or rather their ending).
sub foo {
print <<END
here-document
END
return 1;
}
The default funcname pattern treats the unindented END line as a
function declaration and puts it in the @@ line of diff and "grep
--show-function" output.
With a little knowledge of perl syntax, we can do better. You can
try it out by adding "*.perl diff=perl" to the gitattributes file.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'userdiff.c')
-rw-r--r-- | userdiff.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/userdiff.c b/userdiff.c index 2d5453697a..fc2afe33a7 100644 --- a/userdiff.c +++ b/userdiff.c @@ -61,6 +61,21 @@ PATTERNS("pascal", "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+" "|<>|<=|>=|:=|\\.\\." "|[^[:space:]]|[\x80-\xff]+"), +PATTERNS("perl", + "^[ \t]*package .*;\n" + "^[ \t]*sub .* \\{", + /* -- */ + "[[:alpha:]_'][[:alnum:]_']*" + "|0[xb]?[0-9a-fA-F_]*" + /* taking care not to interpret 3..5 as (3.)(.5) */ + "|[0-9a-fA-F_]+(\\.[0-9a-fA-F_]+)?([eE][-+]?[0-9_]+)?" + "|=>|-[rwxoRWXOezsfdlpSugkbctTBMAC>]|~~|::" + "|&&=|\\|\\|=|//=|\\*\\*=" + "|&&|\\|\\||//|\\+\\+|--|\\*\\*|\\.\\.\\.?" + "|[-+*/%.^&<>=!|]=" + "|=~|!~" + "|<<|<>|<=>|>>" + "|[^[:space:]]"), PATTERNS("php", "^[\t ]*(((public|protected|private|static)[\t ]+)*function.*)$\n" "^[\t ]*(class.*)$", |