Skip to content

Commit 17e1c9e

Browse files
committed
Merge branch 'jn/perl-funcname'
* jn/perl-funcname: userdiff/perl: catch BEGIN/END/... and POD as headers diff: funcname and word patterns for perl
2 parents 17fd68d + a25e473 commit 17e1c9e

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

Documentation/gitattributes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,8 @@ patterns are available:
504504

505505
- `pascal` suitable for source code in the Pascal/Delphi language.
506506

507+
- `perl` suitable for source code in the Perl language.
508+
507509
- `php` suitable for source code in the PHP language.
508510

509511
- `python` suitable for source code in the Python language.

t/t4018-diff-funcname.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ EOF
3232

3333
sed 's/beer\\/beer,\\/' < Beer.java > Beer-correct.java
3434

35-
builtin_patterns="bibtex cpp csharp fortran html java objc pascal php python ruby tex"
35+
builtin_patterns="bibtex cpp csharp fortran html java objc pascal perl php python ruby tex"
3636
for p in $builtin_patterns
3737
do
3838
test_expect_success "builtin $p pattern compiles" '

userdiff.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,23 @@ PATTERNS("pascal",
6161
"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"
6262
"|<>|<=|>=|:=|\\.\\."
6363
"|[^[:space:]]|[\x80-\xff]+"),
64+
PATTERNS("perl",
65+
"^[ \t]*package .*;\n"
66+
"^[ \t]*sub .* \\{\n"
67+
"^[A-Z]+ \\{\n" /* BEGIN, END, ... */
68+
"^=head[0-9] ", /* POD */
69+
/* -- */
70+
"[[:alpha:]_'][[:alnum:]_']*"
71+
"|0[xb]?[0-9a-fA-F_]*"
72+
/* taking care not to interpret 3..5 as (3.)(.5) */
73+
"|[0-9a-fA-F_]+(\\.[0-9a-fA-F_]+)?([eE][-+]?[0-9_]+)?"
74+
"|=>|-[rwxoRWXOezsfdlpSugkbctTBMAC>]|~~|::"
75+
"|&&=|\\|\\|=|//=|\\*\\*="
76+
"|&&|\\|\\||//|\\+\\+|--|\\*\\*|\\.\\.\\.?"
77+
"|[-+*/%.^&<>=!|]="
78+
"|=~|!~"
79+
"|<<|<>|<=>|>>"
80+
"|[^[:space:]]"),
6481
PATTERNS("php",
6582
"^[\t ]*(((public|protected|private|static)[\t ]+)*function.*)$\n"
6683
"^[\t ]*(class.*)$",

0 commit comments

Comments
 (0)