Re: [RFC/PATCH] diff: funcname and word patterns for perl
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 27, 2010, 17:18 UTC
- Message-ID
- <7vmxnrxhgm.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <201012270014.09962.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
Show 7 quoted lines
> 2. sub foo {
> FOO: while (1) {
> ...
> }
> }
>
> which should be marked with 'sub foo {', I thinkI do not think Jonathan's patterns would be fooled by this; it wants to catch only "package <anything>;" and "sub <anything> {".
Jonathan's pattern set allows them to be indented, and followed by some garbage at the end., which we might want to tighten. How many people start 'package' and the outermost 'sub' indented?
userdiff.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/userdiff.c b/userdiff.c index fc2afe3..79569c4 100644 --- a/userdiff.c +++ b/userdiff.c @@ -62,8 +62,10 @@ PATTERNS("pascal", "|<>|<=|>=|:=|\\.\\." "|[^[:space:]]|[\x80-\xff]+"), PATTERNS("perl", - "^[ \t]*package .*;\n" - "^[ \t]*sub .* \\{", + "^package .*;\n" + "^sub .* \\{\n" + "^[A-Z]+ \\{\n" /* BEGIN, END, ... */ + "^=head[0-9] ", /* POD */ /* -- */ "[[:alpha:]_'][[:alnum:]_']*" "|0[xb]?[0-9a-fA-F_]*"