Re: [RFC/PATCH] diff: funcname and word patterns for perl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 27 Dec 2010, Junio C Hamano wrote:
> Jakub Narebski <jnareb@xxxxxxxxx> 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 <anything>;" and "sub <anything> {".

All right.

> 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"

Note that in future Perl 5.14 there would be 'package NAME {' form,
so perhaps it would be better to future-proof and use

  +	 "^package .*[;{]\n"

> +	 "^sub .* \\{\n"

Using "sub foo {" is just a recommended programming convention (like e.g.
GNU convention or K&R convention for C code).  I think it would be better
to relax it a bit, either

  +	 "^sub "

or

  +	 "^sub .*( \\{)?\n"

> +	 "^[A-Z]+ \\{\n"	/* BEGIN, END, ... */

We won't list possible block here?

> +	 "^=head[0-9] ",	/* POD */
>  	 /* -- */
>  	 "[[:alpha:]_'][[:alnum:]_']*"
>  	 "|0[xb]?[0-9a-fA-F_]*"

-- 
Jakub Narebski
Poland
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]