From: Junio C Hamano Date: Mon, 27 Dec 2010 17:18:17 GMT Subject: Re: [RFC/PATCH] diff: funcname and word patterns for perl Message-ID: <7vmxnrxhgm.fsf@alter.siamese.dyndns.org> In-Reply-To: <201012270014.09962.jnareb@gmail.com> Jakub Narebski writes: > 2. sub foo { > FOO: while (1) { > ... > } > } > > which should be marked with 'sub foo {', I think I do not think Jonathan's patterns would be fooled by this; it wants to catch only "package ;" and "sub {". 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_]*"