Re: [PATCH] Teach git diff about Objective-C syntax

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

 



On Wed, Sep 17, 2008 at 9:44 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Are you sure the regexp you have for Objective-C methods quotes a dot "."
> correctly, by the way?  It appears to match almost anything enclosed in a
> pair of parentheses, as long as you have two alpha after open paren.

It could be a little more restrictive, but I'm not sure how much
further it could be taken without it getting ridiculous.  Just as some
examples, it needs to match :
+(id)someClassMethod
-(id)someInstanceMethod
-(NSNumber*)numberWithNumerator:(int)n denominator:(int)d
-(NSString*)stringWithVariableArguments:(NSString*)format ...

(I seem to remember that if your method returns 'id' you can skip the
return type, eg "- someInstanceMethod", but I don't think there's any
hope for people that use that notation...)

^[ \t]*\\([-+][ \t]*([ \t]*[A-Za-z_][A-Za-z_0-9* \t]*)[ \t]*_?[A-Za-z]*\\)$
would be a small improvement - that is, a plus or minus, brackets
around the return type, then at least one letter for the method name,
potentially preceded by an underscore.  Can anyone suggest anything
better?

Also, why can't I use \s for whitespace, \w for word characters etc?
I thought we were using the gnu regex library?


> Also I am not sure if you can do the pattern alternates the way you did.
> If you have this:
>
>        "...\\(A\\|B\\)$"
>        "\\|"
>        "...\\(C\\|D\\)$"
>
> A and B will be captured as $1 but wouldn't C or D captured as $2?

Hmm, hadn't considered that.  It appears to work fine, but I haven't
yet had chance to track down exactly where the funcname regexp match
occurs to see what the code is doing with the different matches.  I'll
try and take a look tomorrow, unless someone can enlighten me before
then...
--
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]

  Powered by Linux