X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=userdiff.c;h=e55310cd02c8e7d1f0404b2fee9539e7340993d9;hb=294e15fc19b5ba370b703d003920d000a4f5547a;hp=1ff47977d549992ada8c1236187d4516b648ee7d;hpb=22dbeee715e4c9fae3e3fdc1f3a2c4a6ec90e593;p=git.git diff --git a/userdiff.c b/userdiff.c index 1ff47977d..e55310cd0 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_]*"