summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 73e7b2e)
raw | patch | inline | side by side (parent: 73e7b2e)
author | Jonathan Nieder <jrnieder@gmail.com> | |
Sun, 26 Dec 2010 09:07:31 +0000 (03:07 -0600) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 27 Dec 2010 16:47:21 +0000 (08:47 -0800) |
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>
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>
Documentation/gitattributes.txt | patch | blob | history | |
t/t4018-diff-funcname.sh | patch | blob | history | |
userdiff.c | patch | blob | history |
index 5a7f9364299cb4ed34a7dc35688c9bddcd35ff3d..e59b87829374bfd72bc1d3375cbe0694e52e116e 100644 (file)
- `pascal` suitable for source code in the Pascal/Delphi language.
+- `perl` suitable for source code in the Perl language.
+
- `php` suitable for source code in the PHP language.
- `python` suitable for source code in the Python language.
index 0a61b57b5f6f00ae4c0734a34ce45c0ba1fcf098..364693062399228cd6a18b52a21db173519d8e94 100755 (executable)
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
sed 's/beer\\/beer,\\/' < Beer.java > Beer-correct.java
-builtin_patterns="bibtex cpp csharp fortran html java objc pascal php python ruby tex"
+builtin_patterns="bibtex cpp csharp fortran html java objc pascal perl php python ruby tex"
for p in $builtin_patterns
do
test_expect_success "builtin $p pattern compiles" '
diff --git a/userdiff.c b/userdiff.c
index 2d5453697aaf5287f524b72d0088ee15679e0691..fc2afe33a7640677fbf3a10bbdbec25b023f752c 100644 (file)
--- a/userdiff.c
+++ b/userdiff.c
"|[-+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.*)$",