From: Jonathan del Strother <jon.delStrother@bestbefore.tv>
To: git@vger.kernel.org
Cc: Miklos Vajna <vmiklos@frugalware.org>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Junio C Hamano <gitster@pobox.com>, Andreas Ericsson <ae@op5.se>,
Jonathan del Strother <jon.delStrother@bestbefore.tv>
Subject: [PATCH v2] Teach git diff about Objective-C syntax
Date: Wed, 1 Oct 2008 00:46:34 +0100 [thread overview]
Message-ID: <1222818394-11547-1-git-send-email-jon.delStrother@bestbefore.tv> (raw)
In-Reply-To: <57518fd10809171630v97485aalcc5089f96082c0fc@mail.gmail.com>
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?
Documentation/gitattributes.txt | 2 ++
diff.c | 10 ++++++++++
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 2ae771f..2694559 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -315,6 +315,8 @@ patterns are available:
- `java` suitable for source code in the Java language.
+- `objc` suitable for source code in the Objective-C language.
+
- `pascal` suitable for source code in the Pascal/Delphi language.
- `php` suitable for source code in the PHP language.
diff --git a/diff.c b/diff.c
index b001d7b..3694602 100644
--- a/diff.c
+++ b/diff.c
@@ -1429,6 +1429,16 @@ static const struct funcname_pattern_entry builtin_funcname_pattern[] = {
"!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
"^[ \t]*(([ \t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \t]*\\([^;]*)$",
REG_EXTENDED },
+ { "objc",
+ /* Negate C statements that can look like functions */
+ "!^[ \t]*(do|for|if|else|return|switch|while)\n"
+ /* Objective-C methods */
+ "^[ \t]*([-+][ \t]*\\([ \t]*[A-Za-z_][A-Za-z_0-9* \t]*\\)[ \t]*[A-Za-z_].*)$\n"
+ /* C functions */
+ "^[ \t]*(([ \t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \t]*\\([^;]*)$\n"
+ /* Objective-C class/protocol definitions */
+ "^(@(implementation|interface|protocol)[ \t].*)$",
+ REG_EXTENDED },
{ "pascal",
"^((procedure|function|constructor|destructor|interface|"
"implementation|initialization|finalization)[ \t]*.*)$"
--
1.6.0.2.416.g8cab.dirty
next prev parent reply other threads:[~2008-09-30 23:48 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-16 23:21 [PATCH] Teach git diff about Objective-C syntax Jonathan del Strother
2008-09-16 23:39 ` Miklos Vajna
2008-09-17 0:07 ` Jonathan del Strother
2008-09-17 10:49 ` Jonathan del Strother
2008-09-17 11:06 ` Johannes Schindelin
2008-09-17 12:26 ` Jonathan del Strother
2008-09-17 13:29 ` Jonathan del Strother
2008-09-17 15:03 ` Andreas Ericsson
2008-09-17 15:31 ` Jonathan del Strother
2008-09-17 15:55 ` Miklos Vajna
2008-09-17 19:14 ` Jonathan del Strother
2008-09-17 20:44 ` Junio C Hamano
2008-09-17 23:30 ` Jonathan del Strother
2008-09-30 23:46 ` Jonathan del Strother [this message]
2008-10-01 0:52 ` [PATCH v2] " Brandon Casey
2008-10-01 19:28 ` [PATCH] xdiff-interface.c: strip newline (and cr) from line before pattern matching Brandon Casey
2008-10-01 20:05 ` Johannes Schindelin
2008-10-02 10:29 ` Jonathan del Strother
2008-10-02 10:40 ` [PATCH v2] Teach git diff about Objective-C syntax Jonathan del Strother
2008-09-18 6:50 ` [PATCH] " Andreas Ericsson
2008-09-17 13:37 ` Jonathan del Strother
2008-09-17 14:28 ` Johannes Schindelin
2008-09-17 14:32 ` Jonathan del Strother
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1222818394-11547-1-git-send-email-jon.delStrother@bestbefore.tv \
--to=jon.delstrother@bestbefore.tv \
--cc=Johannes.Schindelin@gmx.de \
--cc=ae@op5.se \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=vmiklos@frugalware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).