summaryrefslogtreecommitdiff
path: root/userdiff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-05-26 10:32:25 -0700
committerJunio C Hamano <gitster@pobox.com>2011-05-26 10:32:25 -0700
commit7eacc2bc29cc810fd5722096aa3c2c9dc8db34ab (patch)
treec7848640dfe346b9900c25d3051545a92c68a4ae /userdiff.c
parent8784e4dddeb16a89dd19bfb879788b8df0aac1f5 (diff)
parentf143d9c695cd4c3e86069c536fa0dff04fc93e93 (diff)
downloadgit-7eacc2bc29cc810fd5722096aa3c2c9dc8db34ab.tar.gz
Merge branch 'jn/userdiff-perl-updates'
* jn/userdiff-perl-updates: userdiff/perl: tighten BEGIN/END block pattern to reject here-doc delimiters tests: make test_expect_code quieter on success userdiff/perl: catch sub with brace on second line userdiff/perl: match full line of POD headers userdiff/perl: anchor "sub" and "package" patterns on the left t4018 (funcname patterns): minor cleanups t4018 (funcname patterns): make configuration easier to track t4018 (funcname patterns): make .gitattributes state easier to track
Diffstat (limited to 'userdiff.c')
-rw-r--r--userdiff.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/userdiff.c b/userdiff.c
index 1ff47977d5..e55310cd02 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -60,10 +60,24 @@ PATTERNS("pascal",
"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"
"|<>|<=|>=|:=|\\.\\."),
PATTERNS("perl",
- "^[ \t]*package .*;\n"
- "^[ \t]*sub .* \\{\n"
- "^[A-Z]+ \\{\n" /* BEGIN, END, ... */
- "^=head[0-9] ", /* POD */
+ "^package .*\n"
+ "^sub [[:alnum:]_':]+[ \t]*"
+ "(\\([^)]*\\)[ \t]*)?" /* prototype */
+ /*
+ * Attributes. A regex can't count nested parentheses,
+ * so just slurp up whatever we see, taking care not
+ * to accept lines like "sub foo; # defined elsewhere".
+ *
+ * An attribute could contain a semicolon, but at that
+ * point it seems reasonable enough to give up.
+ */
+ "(:[^;#]*)?"
+ "(\\{[ \t]*)?" /* brace can come here or on the next line */
+ "(#.*)?$\n" /* comment */
+ "^(BEGIN|END|INIT|CHECK|UNITCHECK|AUTOLOAD|DESTROY)[ \t]*"
+ "(\\{[ \t]*)?" /* brace can come here or on the next line */
+ "(#.*)?$\n"
+ "^=head[0-9] .*", /* POD */
/* -- */
"[[:alpha:]_'][[:alnum:]_']*"
"|0[xb]?[0-9a-fA-F_]*"