Skip to content

Commit

Permalink
Teach git diff about Objective-C syntax
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
  • Loading branch information
Jonathan del Strother authored and Shawn O. Pearce committed Oct 6, 2008
1 parent 276328f commit 5d1e958
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Documentation/gitattributes.txt
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 10 additions & 0 deletions diff.c
Original file line number Diff line number Diff line change
@@ -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]*.*)$"

0 comments on commit 5d1e958

Please sign in to comment.