git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jonathan del Strother <maillist@steelskies.com>
Date
Sep 17, 2008, 23:30 UTC
Message-ID
<57518fd10809171630v97485aalcc5089f96082c0fc@mail.gmail.com>
In-Reply-To
<7vljxq4i5p.fsf@gitster.siamese.dyndns.org>
On Wed, Sep 17, 2008 at 9:44 PM, Junio C Hamano <gitster@pobox.com> 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?

Show 8 quoted lines
> 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...

Previous: Junio C HamanoNext: Jonathan del Strother
Message 13 of 23 in “Teach git diff about Objective-C syntax”
  1. Teach git diff about Objective-C syntaxJonathan del Strother, Sep 16, 2008
  2. Miklos VajnaSep 16, 2008
  3. Teach git diff about Objective-C syntaxJonathan del Strother, Sep 17, 2008
  4. Teach git diff about Objective-C syntaxJonathan del Strother, Sep 17, 2008
  5. Johannes SchindelinSep 17, 2008
  6. Jonathan del StrotherSep 17, 2008
  7. Teach git diff about Objective-C syntaxJonathan del Strother, Sep 17, 2008
  8. Andreas EricssonSep 17, 2008
  9. Jonathan del StrotherSep 17, 2008
  10. Miklos VajnaSep 17, 2008
  11. Jonathan del StrotherSep 17, 2008
  12. Junio C HamanoSep 17, 2008
  13. Jonathan del StrotherSep 17, 2008
  14. Teach git diff about Objective-C syntaxJonathan del Strother, Sep 30, 2008
  15. Brandon CaseyOct 1, 2008
  16. xdiff-interface.c: strip newline (and cr) from line before pattern matchingBrandon Casey, Oct 1, 2008
  17. Johannes SchindelinOct 1, 2008
  18. Jonathan del StrotherOct 2, 2008
  19. Jonathan del StrotherOct 2, 2008
  20. Andreas EricssonSep 18, 2008
  21. Jonathan del StrotherSep 17, 2008
  22. Johannes SchindelinSep 17, 2008
  23. Jonathan del StrotherSep 17, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.