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

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

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Oct 1, 2008, 00:52 UTC
Message-ID
<mJtumbyBuR0sRaFjwb6O5_D_ps0fVfz6APTAAjYMixV0MvzP8nEZRw@cipher.nrlssc.navy.mil>
In-Reply-To
<1222818394-11547-1-git-send-email-jon.delStrother@bestbefore.tv>
Jonathan del Strother wrote:
Show 10 quoted lines
> Add support for recognition of Objective-C class & instance methods, C functions, and class implementation/interfaces.
> 
> Signed-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>
> ---
> This version is much the same, but rebuilt on top of 1883a0d3b to use the extended regexp stuff, and it doesn't attempt to tidy up other patterns.
> 
> I've been trying to make the objc-method matching line a bit more specific - I think I'm running into a bug (or more likely a misunderstanding) in the matching process.
> Every pattern there uses either .*$ or [^;]*$ to match up to the end of a line.  But in trying to come up with a whitelist of characters to match up to the end of a line, I couldn't do it : there seems to be an invisible character at the end of the line that I can't match.
> That is, a line containing just "FUNCNAME" (terminated by a newline) will be matched by the pattern "^(FUNCNAME.$)" but not "^(FUNCNAME$)".
> Why is this?
I think it is the newline which git is not removing from the string passed to regexec.
See: http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_02
   "...In the regular expression processing described in IEEE Std 1003.1-2001,
    the <newline> is regarded as an ordinary character and both a period and a
    non-matching list can match one."
   "...Those utilities (like grep) that do not allow <newline>s to match are
    responsible for eliminating any <newline> from strings before matching against
    the RE."
Possibly something like:
diff --git a/xdiff-interface.c b/xdiff-interface.c
index 8bab82e..f471c7c 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -191,7 +191,7 @@ struct ff_regs {
 static long ff_regexp(const char *line, long len,
		char *buffer, long buffer_size, void *priv)
 {
-	char *line_buffer = xstrndup(line, len); /* make NUL terminated */
+	char *line_buffer = xstrndup(line, len-1); /* make NUL terminated */
 	struct ff_regs *regs = priv;
 	regmatch_t pmatch[2];
 	int i;
Previous: Jonathan del StrotherNext: Brandon Casey
Message 15 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.