{"thread":{"id":"15559","subject":"[PATCH] Teach git diff about Objective-C syntax","startedAt":"2008-09-16T23:21:37Z","lastAt":"2008-10-02T10:40:14Z","messageCount":23,"participants":["Jonathan del Strother","Miklos Vajna","Johannes Schindelin","Andreas Ericsson","Junio C Hamano","Brandon Casey"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"90876","messageId":"1221607297-33212-1-git-send-email-jon.delStrother@bestbefore.tv","threadId":"15559","inReplyTo":null,"subject":"[PATCH] Teach git diff about Objective-C syntax","fromName":"Jonathan del Strother","fromEmail":"jon.delstrother@bestbefore.tv","sentAt":"2008-09-16T23:21:37Z","receivedAt":"2008-09-16T23:21:37Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"Add support for recognition of Objective-C class & instance methods, C functions, and class implementation/interfaces.\n\nSigned-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>\n---\n Documentation/gitattributes.txt |    2 ++\n diff.c                          |    6 ++++++\n 2 files changed, 8 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt\nindex 6f3551d..c1f13e2 100644\n--- a/Documentation/gitattributes.txt\n+++ b/Documentation/gitattributes.txt\n@@ -315,6 +315,8 @@ patterns are available:\n \n - `java` suitable for source code in the Java language.\n \n+- `objc` suitable for source code in the Objective-C language.\n+\n - `pascal` suitable for source code in the Pascal/Delphi language.\n \n - `php` suitable for source code in the PHP language.\ndiff --git a/diff.c b/diff.c\nindex 998dcaa..6ed8322 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1403,6 +1403,12 @@ static struct builtin_funcname_pattern {\n \t\t\t\"^[ \t]*\\\\(\\\\([ \t]*\"\n \t\t\t\"[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}\"\n \t\t\t\"[ \t]*([^;]*\\\\)$\" },\n+\t{ \"objc\", \"^[\\t ]*\\\\([-+][\\t ]*([\\t ]*[A-Za-z_][A-Za-z_0-9]*.*).*\\\\)$\"      // Objective-C methods\n+\t\t\t\"\\\\|\"\n+\t\t\t\"^[\\t ]*\\\\(\\\\([\\t ]*[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}[\\t ]*([^;]*\\\\)$\" // C functions\n+\t\t\t\"\\\\|\"\n+\t\t\t\"^@\\\\(implementation\\\\|interface\\\\|protocol\\\\).*\"   // Objective-C class/protocol definitions\n+\t\t\t},\n \t{ \"pascal\", \"^\\\\(\\\\(procedure\\\\|function\\\\|constructor\\\\|\"\n \t\t\t\"destructor\\\\|interface\\\\|implementation\\\\|\"\n \t\t\t\"initialization\\\\|finalization\\\\)[ \\t]*.*\\\\)$\"\n-- \n1.6.0.2\n"},{"id":"90879","messageId":"20080916233923.GF4829@genesis.frugalware.org","threadId":"15559","inReplyTo":"1221607297-33212-1-git-send-email-jon.delStrother@bestbefore.tv","subject":"Re: [PATCH] Teach git diff about Objective-C syntax","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-09-16T23:39:23Z","receivedAt":"2008-09-16T23:39:23Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Wed, Sep 17, 2008 at 12:21:37AM +0100, Jonathan del Strother <jon.delStrother@bestbefore.tv> wrote:\n> +\t{ \"objc\", \"^[\\t ]*\\\\([-+][\\t ]*([\\t ]*[A-Za-z_][A-Za-z_0-9]*.*).*\\\\)$\"      // Objective-C methods\n> +\t\t\t\"\\\\|\"\n> +\t\t\t\"^[\\t ]*\\\\(\\\\([\\t ]*[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}[\\t ]*([^;]*\\\\)$\" // C functions\n> +\t\t\t\"\\\\|\"\n> +\t\t\t\"^@\\\\(implementation\\\\|interface\\\\|protocol\\\\).*\"   // Objective-C class/protocol definitions\n\nPlease avoid C++-style comments. Just use /* */.\n\nThanks.\n"},{"id":"90885","messageId":"1221610063-33610-1-git-send-email-jon.delStrother@bestbefore.tv","threadId":"15559","inReplyTo":"20080916233923.GF4829@genesis.frugalware.org","subject":"[PATCH] Teach git diff about Objective-C syntax","fromName":"Jonathan del Strother","fromEmail":"jon.delstrother@bestbefore.tv","sentAt":"2008-09-17T00:07:43Z","receivedAt":"2008-09-17T00:07:43Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"Add support for recognition of Objective-C class & instance methods, C functions, and class implementation/interfaces.\n\nSigned-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>\n---\n Documentation/gitattributes.txt |    2 ++\n diff.c                          |    6 ++++++\n 2 files changed, 8 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt\nindex 6f3551d..c1f13e2 100644\n--- a/Documentation/gitattributes.txt\n+++ b/Documentation/gitattributes.txt\n@@ -315,6 +315,8 @@ patterns are available:\n \n - `java` suitable for source code in the Java language.\n \n+- `objc` suitable for source code in the Objective-C language.\n+\n - `pascal` suitable for source code in the Pascal/Delphi language.\n \n - `php` suitable for source code in the PHP language.\ndiff --git a/diff.c b/diff.c\nindex 998dcaa..5f4e63b 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1403,6 +1403,12 @@ static struct builtin_funcname_pattern {\n \t\t\t\"^[ \t]*\\\\(\\\\([ \t]*\"\n \t\t\t\"[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}\"\n \t\t\t\"[ \t]*([^;]*\\\\)$\" },\n+\t{ \"objc\", \"^[\\t ]*\\\\([-+][\\t ]*([\\t ]*[A-Za-z_][A-Za-z_0-9]*.*).*\\\\)$\" /* Objective-C methods */\n+\t\t\t\"\\\\|\"\n+\t\t\t\"^[\\t ]*\\\\(\\\\([\\t ]*[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}[\\t ]*([^;]*\\\\)$\" /* C functions */\n+\t\t\t\"\\\\|\"\n+\t\t\t\"^@\\\\(implementation\\\\|interface\\\\|protocol\\\\).*\" /* Objective-C class/protocol definitions */\n+\t\t\t},\n \t{ \"pascal\", \"^\\\\(\\\\(procedure\\\\|function\\\\|constructor\\\\|\"\n \t\t\t\"destructor\\\\|interface\\\\|implementation\\\\|\"\n \t\t\t\"initialization\\\\|finalization\\\\)[ \\t]*.*\\\\)$\"\n-- \n1.6.0.2\n"},{"id":"90917","messageId":"1221648564-56239-1-git-send-email-jon.delStrother@bestbefore.tv","threadId":"15559","inReplyTo":"1221610063-33610-1-git-send-email-jon.delStrother@bestbefore.tv","subject":"[PATCH] Teach git diff about Objective-C syntax","fromName":"Jonathan del Strother","fromEmail":"jon.delstrother@bestbefore.tv","sentAt":"2008-09-17T10:49:24Z","receivedAt":"2008-09-17T10:49:24Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"Add support for recognition of Objective-C class & instance methods, C functions, and class implementation/interfaces.\n\nSigned-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>\n---\n\nThis version of the patch adds the negate line to avoid picking up if()/while()/etc statements as funcnames\nI also took the liberty of replacing the invisible tab characters in the java pattern with \\t's - is that OK?\n\n Documentation/gitattributes.txt |    2 ++\n diff.c                          |   19 ++++++++++++++-----\n 2 files changed, 16 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt\nindex 6f3551d..c1f13e2 100644\n--- a/Documentation/gitattributes.txt\n+++ b/Documentation/gitattributes.txt\n@@ -315,6 +315,8 @@ patterns are available:\n \n - `java` suitable for source code in the Java language.\n \n+- `objc` suitable for source code in the Objective-C language.\n+\n - `pascal` suitable for source code in the Pascal/Delphi language.\n \n - `php` suitable for source code in the PHP language.\ndiff --git a/diff.c b/diff.c\nindex 998dcaa..fdfdf26 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1398,17 +1398,26 @@ static struct builtin_funcname_pattern {\n } builtin_funcname_pattern[] = {\n \t{ \"bibtex\", \"\\\\(@[a-zA-Z]\\\\{1,\\\\}[ \\t]*{\\\\{0,1\\\\}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*\\\\).*$\" },\n \t{ \"html\", \"^\\\\s*\\\\(<[Hh][1-6]\\\\s.*>.*\\\\)$\" },\n-\t{ \"java\", \"!^[ \t]*\\\\(catch\\\\|do\\\\|for\\\\|if\\\\|instanceof\\\\|\"\n+\n+\t{ \"java\", \"!^[ \\t]*\\\\(catch\\\\|do\\\\|for\\\\|if\\\\|instanceof\\\\|\"\n \t\t\t\"new\\\\|return\\\\|switch\\\\|throw\\\\|while\\\\)\\n\"\n-\t\t\t\"^[ \t]*\\\\(\\\\([ \t]*\"\n+\t\t\t\"^[ \\t]*\\\\(\\\\([ \\t]*\"\n \t\t\t\"[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}\"\n-\t\t\t\"[ \t]*([^;]*\\\\)$\" },\n+\t\t\t\"[ \\t]*([^;]*\\\\)$\" },\n+\n+\t{ \"objc\", \"![ \\t]*\\\\(do\\\\|for\\\\|if\\\\|else\\\\|return\\\\|switch\\\\|while\\\\)\\n\" /* Negate C statements that can look like functions */\n+\t\t\t\"^[ \\t]*\\\\([-+][ \\t]*([ \\t]*[A-Za-z_][A-Za-z_0-9]*.*).*\\\\)$\" /* Objective-C methods */\n+\t\t\t\"\\\\|\"\n+\t\t\t\"^[ \\t]*\\\\(\\\\([ \\t]*[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}[ \\t]*([^;]*\\\\)$\" /* C functions */\n+\t\t\t\"\\\\|\"\n+\t\t\t\"^@\\\\(implementation\\\\|interface\\\\|protocol\\\\).*\"}, /* Objective-C class/protocol definitions */\n+\n \t{ \"pascal\", \"^\\\\(\\\\(procedure\\\\|function\\\\|constructor\\\\|\"\n \t\t\t\"destructor\\\\|interface\\\\|implementation\\\\|\"\n \t\t\t\"initialization\\\\|finalization\\\\)[ \\t]*.*\\\\)$\"\n \t\t\t\"\\\\|\"\n-\t\t\t\"^\\\\(.*=[ \\t]*\\\\(class\\\\|record\\\\).*\\\\)$\"\n-\t\t\t},\n+\t\t\t\"^\\\\(.*=[ \\t]*\\\\(class\\\\|record\\\\).*\\\\)$\"},\n+\n \t{ \"php\", \"^[\\t ]*\\\\(\\\\(function\\\\|class\\\\).*\\\\)\" },\n \t{ \"python\", \"^\\\\s*\\\\(\\\\(class\\\\|def\\\\)\\\\s.*\\\\)$\" },\n \t{ \"ruby\", \"^\\\\s*\\\\(\\\\(class\\\\|module\\\\|def\\\\)\\\\s.*\\\\)$\" },\n-- \n1.6.0.2.250.g2fdd2.dirty\n"},{"id":"90921","messageId":"alpine.DEB.1.00.0809171205430.14329@racer","threadId":"15559","inReplyTo":"1221648564-56239-1-git-send-email-jon.delStrother@bestbefore.tv","subject":"Re: [PATCH] Teach git diff about Objective-C syntax","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-09-17T11:06:18Z","receivedAt":"2008-09-17T11:06:18Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 17 Sep 2008, Jonathan del Strother wrote:\n\n> -\t\t\t\"^[ \t]*\\\\(\\\\([ \t]*\"\n> +\t\t\t\"^[ \\t]*\\\\(\\\\([ \\t]*\"\n\nWhy?\n\n>  \t\t\t\"[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}\"\n> -\t\t\t\"[ \t]*([^;]*\\\\)$\" },\n> +\t\t\t\"[ \\t]*([^;]*\\\\)$\" },\n> +\n> +\t{ \"objc\", \"![ \\t]*\\\\(do\\\\|for\\\\|if\\\\|else\\\\|return\\\\|switch\\\\|while\\\\)\\n\" /* Negate C statements that can look like functions */\n> +\t\t\t\"^[ \\t]*\\\\([-+][ \\t]*([ \\t]*[A-Za-z_][A-Za-z_0-9]*.*).*\\\\)$\" /* Objective-C methods */\n\nI see you still have these awfully long lines.\n\nCiao,\nDscho\n"},{"id":"90931","messageId":"57518fd10809170526i5c1e7dadgc38bb00e8073ba55@mail.gmail.com","threadId":"15559","inReplyTo":"alpine.DEB.1.00.0809171205430.14329@racer","subject":"Re: [PATCH] Teach git diff about Objective-C syntax","fromName":"Jonathan del Strother","fromEmail":"maillist@steelskies.com","sentAt":"2008-09-17T12:26:50Z","receivedAt":"2008-09-17T12:26:50Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"On Wed, Sep 17, 2008 at 12:06 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n>\n> On Wed, 17 Sep 2008, Jonathan del Strother wrote:\n>\n>> -                     \"^[     ]*\\\\(\\\\([       ]*\"\n>> +                     \"^[ \\t]*\\\\(\\\\([ \\t]*\"\n>\n> Why?\n>\n>>                       \"[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}\"\n>> -                     \"[      ]*([^;]*\\\\)$\" },\n>> +                     \"[ \\t]*([^;]*\\\\)$\" },\n>> +\n>> +     { \"objc\", \"![ \\t]*\\\\(do\\\\|for\\\\|if\\\\|else\\\\|return\\\\|switch\\\\|while\\\\)\\n\" /* Negate C statements that can look like functions */\n>> +                     \"^[ \\t]*\\\\([-+][ \\t]*([ \\t]*[A-Za-z_][A-Za-z_0-9]*.*).*\\\\)$\" /* Objective-C methods */\n>\n> I see you still have these awfully long lines.\n\nI was hoping I'd get away with it since the overlong parts are just comments...\n\nYou'd prefer something like\n\t{ \"objc\",\n\t\t\t/* Negate C statements that can look like functions */\n\t\t\t\"![ \\t]*\\\\(do\\\\|for\\\\|if\\\\|else\\\\|return\\\\|switch\\\\|while\\\\)\\n\"\n\t\t\t/* Objective-C methods */\n\t\t\t\"^[ \\t]*\\\\([-+][ \\t]*([ \\t]*[A-Za-z_][A-Za-z_0-9]*.*).*\\\\)$\"\n\t\t\t\"\\\\|\"\n\t\t\t/* C functions */\n\t\t\t\"^[ \\t]*\\\\(\\\\([ \\t]*[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}[ \\t]*([^;]*\\\\)$\"\n\t\t\t\"\\\\|\"\n\t\t\t/* Objective-C class/protocol definitions */\n\t\t\t\"^@\\\\(implementation\\\\|interface\\\\|protocol\\\\).*\"},\n\n?\n"},{"id":"90940","messageId":"1221658141-75698-1-git-send-email-jon.delStrother@bestbefore.tv","threadId":"15559","inReplyTo":"57518fd10809170526i5c1e7dadgc38bb00e8073ba55@mail.gmail.com","subject":"[PATCH] Teach git diff about Objective-C syntax","fromName":"Jonathan del Strother","fromEmail":"jon.delstrother@bestbefore.tv","sentAt":"2008-09-17T13:29:01Z","receivedAt":"2008-09-17T13:29:01Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"Add support for recognition of Objective-C class & instance methods, C functions, and class implementation/interfaces.\n\nSigned-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>\n---\nThis version anchors the negated match to the beginning of the line, and shuffles the comments around to avoid the excessively long lines.  Better?\n\n\n Documentation/gitattributes.txt |    2 ++\n diff.c                          |   24 +++++++++++++++++++-----\n 2 files changed, 21 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt\nindex 6f3551d..c1f13e2 100644\n--- a/Documentation/gitattributes.txt\n+++ b/Documentation/gitattributes.txt\n@@ -315,6 +315,8 @@ patterns are available:\n \n - `java` suitable for source code in the Java language.\n \n+- `objc` suitable for source code in the Objective-C language.\n+\n - `pascal` suitable for source code in the Pascal/Delphi language.\n \n - `php` suitable for source code in the PHP language.\ndiff --git a/diff.c b/diff.c\nindex 998dcaa..e5ec503 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1398,17 +1398,31 @@ static struct builtin_funcname_pattern {\n } builtin_funcname_pattern[] = {\n \t{ \"bibtex\", \"\\\\(@[a-zA-Z]\\\\{1,\\\\}[ \\t]*{\\\\{0,1\\\\}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*\\\\).*$\" },\n \t{ \"html\", \"^\\\\s*\\\\(<[Hh][1-6]\\\\s.*>.*\\\\)$\" },\n-\t{ \"java\", \"!^[ \t]*\\\\(catch\\\\|do\\\\|for\\\\|if\\\\|instanceof\\\\|\"\n+\n+\t{ \"java\", \"!^[ \\t]*\\\\(catch\\\\|do\\\\|for\\\\|if\\\\|instanceof\\\\|\"\n \t\t\t\"new\\\\|return\\\\|switch\\\\|throw\\\\|while\\\\)\\n\"\n-\t\t\t\"^[ \t]*\\\\(\\\\([ \t]*\"\n+\t\t\t\"^[ \\t]*\\\\(\\\\([ \\t]*\"\n \t\t\t\"[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}\"\n-\t\t\t\"[ \t]*([^;]*\\\\)$\" },\n+\t\t\t\"[ \\t]*([^;]*\\\\)$\" },\n+\n+\t{ \"objc\",\n+\t\t\t/* Negate C statements that can look like functions */\n+\t\t\t\"!^[ \\t]*\\\\(do\\\\|for\\\\|if\\\\|else\\\\|return\\\\|switch\\\\|while\\\\)\\n\"\n+\t\t\t/* Objective-C methods */\n+\t\t\t\"^[ \\t]*\\\\([-+][ \\t]*([ \\t]*[A-Za-z_][A-Za-z_0-9]*.*).*\\\\)$\"\n+\t\t\t\"\\\\|\"\n+\t\t\t/* C functions */\n+\t\t\t\"^[ \\t]*\\\\(\\\\([ \\t]*[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}[ \\t]*([^;]*\\\\)$\"\n+\t\t\t\"\\\\|\"\n+\t\t\t/* Objective-C class/protocol definitions */\n+\t\t\t\"^@\\\\(implementation\\\\|interface\\\\|protocol\\\\).*\"},\n+\n \t{ \"pascal\", \"^\\\\(\\\\(procedure\\\\|function\\\\|constructor\\\\|\"\n \t\t\t\"destructor\\\\|interface\\\\|implementation\\\\|\"\n \t\t\t\"initialization\\\\|finalization\\\\)[ \\t]*.*\\\\)$\"\n \t\t\t\"\\\\|\"\n-\t\t\t\"^\\\\(.*=[ \\t]*\\\\(class\\\\|record\\\\).*\\\\)$\"\n-\t\t\t},\n+\t\t\t\"^\\\\(.*=[ \\t]*\\\\(class\\\\|record\\\\).*\\\\)$\"},\n+\n \t{ \"php\", \"^[\\t ]*\\\\(\\\\(function\\\\|class\\\\).*\\\\)\" },\n \t{ \"python\", \"^\\\\s*\\\\(\\\\(class\\\\|def\\\\)\\\\s.*\\\\)$\" },\n \t{ \"ruby\", \"^\\\\s*\\\\(\\\\(class\\\\|module\\\\|def\\\\)\\\\s.*\\\\)$\" },\n-- \n1.6.0.2.250.ge7a3b.dirty\n"},{"id":"90942","messageId":"57518fd10809170637n585afacbs94fdddc5b8bb61b6@mail.gmail.com","threadId":"15559","inReplyTo":"alpine.DEB.1.00.0809171205430.14329@racer","subject":"Re: [PATCH] Teach git diff about Objective-C syntax","fromName":"Jonathan del Strother","fromEmail":"maillist@steelskies.com","sentAt":"2008-09-17T13:37:34Z","receivedAt":"2008-09-17T13:37:34Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"On Wed, Sep 17, 2008 at 12:06 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n>\n> On Wed, 17 Sep 2008, Jonathan del Strother wrote:\n>\n>> -                     \"^[     ]*\\\\(\\\\([       ]*\"\n>> +                     \"^[ \\t]*\\\\(\\\\([ \\t]*\"\n>\n> Why?\n\nSorry - missed that in the original reply.  You really prefer having\nan invisible tab character to an explicit \\t ?\n"},{"id":"90946","messageId":"alpine.DEB.1.00.0809171528120.14329@racer","threadId":"15559","inReplyTo":"57518fd10809170637n585afacbs94fdddc5b8bb61b6@mail.gmail.com","subject":"Re: [PATCH] Teach git diff about Objective-C syntax","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-09-17T14:28:58Z","receivedAt":"2008-09-17T14:28:58Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 17 Sep 2008, Jonathan del Strother wrote:\n\n> On Wed, Sep 17, 2008 at 12:06 PM, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n> > Hi,\n> >\n> > On Wed, 17 Sep 2008, Jonathan del Strother wrote:\n> >\n> >> -                     \"^[     ]*\\\\(\\\\([       ]*\"\n> >> +                     \"^[ \\t]*\\\\(\\\\([ \\t]*\"\n> >\n> > Why?\n> \n> Sorry - missed that in the original reply.  You really prefer having\n> an invisible tab character to an explicit \\t ?\n\nNo.  But I prefer clear-cut commits, not sneaked-in changes.  This is a \nchange in the java part FYI.\n\nCiao,\nDscho\n"},{"id":"90947","messageId":"57518fd10809170732g507bc60ar4427f940b4343c37@mail.gmail.com","threadId":"15559","inReplyTo":"alpine.DEB.1.00.0809171528120.14329@racer","subject":"Re: [PATCH] Teach git diff about Objective-C syntax","fromName":"Jonathan del Strother","fromEmail":"maillist@steelskies.com","sentAt":"2008-09-17T14:32:29Z","receivedAt":"2008-09-17T14:32:29Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"On Wed, Sep 17, 2008 at 3:28 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n>\n> On Wed, 17 Sep 2008, Jonathan del Strother wrote:\n>\n>> On Wed, Sep 17, 2008 at 12:06 PM, Johannes Schindelin\n>> <Johannes.Schindelin@gmx.de> wrote:\n>> > Hi,\n>> >\n>> > On Wed, 17 Sep 2008, Jonathan del Strother wrote:\n>> >\n>> >> -                     \"^[     ]*\\\\(\\\\([       ]*\"\n>> >> +                     \"^[ \\t]*\\\\(\\\\([ \\t]*\"\n>> >\n>> > Why?\n>>\n>> Sorry - missed that in the original reply.  You really prefer having\n>> an invisible tab character to an explicit \\t ?\n>\n> No.  But I prefer clear-cut commits, not sneaked-in changes.  This is a\n> change in the java part FYI.\n>\n\nSorry, I considered it to be a formatting change & didn't think it\nwould matter.  I'll separate them out & repost later\n"},{"id":"90949","messageId":"48D11C3C.5070707@op5.se","threadId":"15559","inReplyTo":"1221658141-75698-1-git-send-email-jon.delStrother@bestbefore.tv","subject":"Re: [PATCH] Teach git diff about Objective-C syntax","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-09-17T15:03:24Z","receivedAt":"2008-09-17T15:03:24Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Jonathan del Strother wrote:\n> Add support for recognition of Objective-C class & instance methods, C functions, and class implementation/interfaces.\n> \n> Signed-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>\n> ---\n> This version anchors the negated match to the beginning of the line, and shuffles the comments around to avoid the excessively long lines.  Better?\n> \n\nWhy do you insist on touching surrounding patterns? I've left them in\nfrom your patch below so you can see where you're going wrong. Those\nchanges provide no value and make your patch harder to read. If you\nwant to make that cleanup, submit it separately, as it has nothing\nto do with teaching git diff about objective C methods.\n\n\n> diff --git a/diff.c b/diff.c\n> index 998dcaa..e5ec503 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -1398,17 +1398,31 @@ static struct builtin_funcname_pattern {\n>  } builtin_funcname_pattern[] = {\n>  \t{ \"bibtex\", \"\\\\(@[a-zA-Z]\\\\{1,\\\\}[ \\t]*{\\\\{0,1\\\\}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*\\\\).*$\" },\n>  \t{ \"html\", \"^\\\\s*\\\\(<[Hh][1-6]\\\\s.*>.*\\\\)$\" },\n> -\t{ \"java\", \"!^[ \t]*\\\\(catch\\\\|do\\\\|for\\\\|if\\\\|instanceof\\\\|\"\n> +\n> +\t{ \"java\", \"!^[ \\t]*\\\\(catch\\\\|do\\\\|for\\\\|if\\\\|instanceof\\\\|\"\n>  \t\t\t\"new\\\\|return\\\\|switch\\\\|throw\\\\|while\\\\)\\n\"\n> -\t\t\t\"^[ \t]*\\\\(\\\\([ \t]*\"\n> +\t\t\t\"^[ \\t]*\\\\(\\\\([ \\t]*\"\n>  \t\t\t\"[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}\"\n> -\t\t\t\"[ \t]*([^;]*\\\\)$\" },\n> +\t\t\t\"[ \\t]*([^;]*\\\\)$\" },\n> +\n\nThe above should be in a separate patch.\n\n>  \t{ \"pascal\", \"^\\\\(\\\\(procedure\\\\|function\\\\|constructor\\\\|\"\n>  \t\t\t\"destructor\\\\|interface\\\\|implementation\\\\|\"\n>  \t\t\t\"initialization\\\\|finalization\\\\)[ \\t]*.*\\\\)$\"\n>  \t\t\t\"\\\\|\"\n> -\t\t\t\"^\\\\(.*=[ \\t]*\\\\(class\\\\|record\\\\).*\\\\)$\"\n> -\t\t\t},\n> +\t\t\t\"^\\\\(.*=[ \\t]*\\\\(class\\\\|record\\\\).*\\\\)$\"},\n> +\n\nThis last change is just pure nonsense. Please remove it altogether.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"90951","messageId":"57518fd10809170831x6d84aeb0m9b0b2c4095a1de70@mail.gmail.com","threadId":"15559","inReplyTo":"48D11C3C.5070707@op5.se","subject":"Re: [PATCH] Teach git diff about Objective-C syntax","fromName":"Jonathan del Strother","fromEmail":"maillist@steelskies.com","sentAt":"2008-09-17T15:31:17Z","receivedAt":"2008-09-17T15:31:17Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"On Wed, Sep 17, 2008 at 4:03 PM, Andreas Ericsson <ae@op5.se> wrote:\n> Jonathan del Strother wrote:\n>>        { \"pascal\", \"^\\\\(\\\\(procedure\\\\|function\\\\|constructor\\\\|\"\n>>                        \"destructor\\\\|interface\\\\|implementation\\\\|\"\n>>                        \"initialization\\\\|finalization\\\\)[ \\t]*.*\\\\)$\"\n>>                        \"\\\\|\"\n>> -                       \"^\\\\(.*=[ \\t]*\\\\(class\\\\|record\\\\).*\\\\)$\"\n>> -                       },\n>> +                       \"^\\\\(.*=[ \\t]*\\\\(class\\\\|record\\\\).*\\\\)$\"},\n>> +\n>\n> This last change is just pure nonsense. Please remove it altogether.\n>\n\n\nI was changing it to match the style in the existing java pattern (and\nmy objc pattern).  You think the java one should be changed to match\nthe pascal one, then?\n"},{"id":"90952","messageId":"20080917155505.GH4829@genesis.frugalware.org","threadId":"15559","inReplyTo":"57518fd10809170831x6d84aeb0m9b0b2c4095a1de70@mail.gmail.com","subject":"Re: [PATCH] Teach git diff about Objective-C syntax","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-09-17T15:55:05Z","receivedAt":"2008-09-17T15:55:05Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Wed, Sep 17, 2008 at 04:31:17PM +0100, Jonathan del Strother <maillist@steelskies.com> wrote:\n> I was changing it to match the style in the existing java pattern (and\n> my objc pattern).  You think the java one should be changed to match\n> the pascal one, then?\n\nThe point is that it's unrelated, so you should not change that part in\nthe same patch. Send a separate patch if you want to do something\nunrelated to Objective-C.\n"},{"id":"90964","messageId":"57518fd10809171214u3b5b3b96yc432c1c410faf8b4@mail.gmail.com","threadId":"15559","inReplyTo":"20080917155505.GH4829@genesis.frugalware.org","subject":"Re: [PATCH] Teach git diff about Objective-C syntax","fromName":"Jonathan del Strother","fromEmail":"maillist@steelskies.com","sentAt":"2008-09-17T19:14:02Z","receivedAt":"2008-09-17T19:14:02Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"On Wed, Sep 17, 2008 at 4:55 PM, Miklos Vajna <vmiklos@frugalware.org> wrote:\n> On Wed, Sep 17, 2008 at 04:31:17PM +0100, Jonathan del Strother <maillist@steelskies.com> wrote:\n>> I was changing it to match the style in the existing java pattern (and\n>> my objc pattern).  You think the java one should be changed to match\n>> the pascal one, then?\n>\n> The point is that it's unrelated, so you should not change that part in\n> the same patch. Send a separate patch if you want to do something\n> unrelated to Objective-C.\n\nJohannes already convinced me to do it as a separate patch.  Andreas\nseems to think that even if that change were in a separate patch, it\nis pure nonsense.  I think it's pretty subjective - I was just making\nthings consistent.\n"},{"id":"90965","messageId":"7vljxq4i5p.fsf@gitster.siamese.dyndns.org","threadId":"15559","inReplyTo":"57518fd10809171214u3b5b3b96yc432c1c410faf8b4@mail.gmail.com","subject":"Re: [PATCH] Teach git diff about Objective-C syntax","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-17T20:44:02Z","receivedAt":"2008-09-17T20:44:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Jonathan del Strother\" <maillist@steelskies.com> writes:\n\n> Johannes already convinced me to do it as a separate patch.  Andreas\n> seems to think that even if that change were in a separate patch, it\n> is pure nonsense.  I think it's pretty subjective - I was just making\n> things consistent.\n\nI think the discussion is getting into personal preference, but I do agree\nmaking things consistent is good.\n\nShort and simple ones can stay the same as before, but I'd actually prefer\ndoing ones on multiple lines like this:\n\n\t{ \"java\",\n\t  /* Do not match these keywords */\n\t  \"!^[ \\t]*\\\\(catch\\\\|do\\\\|for\\\\|if\\\\|instanceof\\\\|\"\n\t\t\"new\\\\|return\\\\|switch\\\\|throw\\\\|while\\\\)\\n\"\n\n\t  /* possibly indented \"foo bar(...\" */\n\t  \"^[ \\t]*\\\\(\\\\([ \\t]*[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}[ \\t]*([^;]*\\\\)$\"\n\t},\n\n\t{ \"objc\",\n\t  /* Do not match with these C statements */\n\t  \"!^[ \\t]*\\\\(do\\\\|for\\\\|if\\\\|else\\\\|return\\\\|switch\\\\|while\\\\)\\n\"\n\n\t  /* Objective-C methods \"-(fo*&^)%*&%$^\" or \"+(bar&^)%$#$%\" */\n\t  \"^[ \\t]*\\\\([-+][ \\t]*([ \\t]*[A-Za-z_][A-Za-z_0-9]*.*).*\\\\)$\"\n\n\t  \"\\\\|\" /* C functions \"foo bar(...\" */\n\t  \"^[ \\t]*\\\\(\\\\([ \\t]*[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}[ \\t]*([^;]*\\\\)$\"\n\n\t  \"\\\\|\" /* Objective-C class/protocol definitions */\n\t  \"^@\\\\(implementation\\\\|interface\\\\|protocol\\\\).*\"\n\t},\n\nThat is:\n\n - The pattern string indented to align with the pattern name;\n - Indent second and later lines of a single alternatives list that is\n   split over multiple physical lines;\n\nAre you sure the regexp you have for Objective-C methods quotes a dot \".\"\ncorrectly, by the way?  It appears to match almost anything enclosed in a\npair of parentheses, as long as you have two alpha after open paren.\n\nAlso I am not sure if you can do the pattern alternates the way you did.\nIf you have this:\n\n\t\"...\\\\(A\\\\|B\\\\)$\"\n        \"\\\\|\"\n        \"...\\\\(C\\\\|D\\\\)$\"\n\nA and B will be captured as $1 but wouldn't C or D captured as $2?\n"},{"id":"90981","messageId":"57518fd10809171630v97485aalcc5089f96082c0fc@mail.gmail.com","threadId":"15559","inReplyTo":"7vljxq4i5p.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Teach git diff about Objective-C syntax","fromName":"Jonathan del Strother","fromEmail":"maillist@steelskies.com","sentAt":"2008-09-17T23:30:08Z","receivedAt":"2008-09-17T23:30:08Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"On Wed, Sep 17, 2008 at 9:44 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Are you sure the regexp you have for Objective-C methods quotes a dot \".\"\n> correctly, by the way?  It appears to match almost anything enclosed in a\n> pair of parentheses, as long as you have two alpha after open paren.\n\nIt could be a little more restrictive, but I'm not sure how much\nfurther it could be taken without it getting ridiculous.  Just as some\nexamples, it needs to match :\n+(id)someClassMethod\n-(id)someInstanceMethod\n-(NSNumber*)numberWithNumerator:(int)n denominator:(int)d\n-(NSString*)stringWithVariableArguments:(NSString*)format ...\n\n(I seem to remember that if your method returns 'id' you can skip the\nreturn type, eg \"- someInstanceMethod\", but I don't think there's any\nhope for people that use that notation...)\n\n^[ \\t]*\\\\([-+][ \\t]*([ \\t]*[A-Za-z_][A-Za-z_0-9* \\t]*)[ \\t]*_?[A-Za-z]*\\\\)$\nwould be a small improvement - that is, a plus or minus, brackets\naround the return type, then at least one letter for the method name,\npotentially preceded by an underscore.  Can anyone suggest anything\nbetter?\n\nAlso, why can't I use \\s for whitespace, \\w for word characters etc?\nI thought we were using the gnu regex library?\n\n\n> Also I am not sure if you can do the pattern alternates the way you did.\n> If you have this:\n>\n>        \"...\\\\(A\\\\|B\\\\)$\"\n>        \"\\\\|\"\n>        \"...\\\\(C\\\\|D\\\\)$\"\n>\n> A and B will be captured as $1 but wouldn't C or D captured as $2?\n\nHmm, hadn't considered that.  It appears to work fine, but I haven't\nyet had chance to track down exactly where the funcname regexp match\noccurs to see what the code is doing with the different matches.  I'll\ntry and take a look tomorrow, unless someone can enlighten me before\nthen...\n"},{"id":"91001","messageId":"48D1FA3E.6020102@op5.se","threadId":"15559","inReplyTo":"57518fd10809171214u3b5b3b96yc432c1c410faf8b4@mail.gmail.com","subject":"Re: [PATCH] Teach git diff about Objective-C syntax","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-09-18T06:50:38Z","receivedAt":"2008-09-18T06:50:38Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Jonathan del Strother wrote:\n> On Wed, Sep 17, 2008 at 4:55 PM, Miklos Vajna <vmiklos@frugalware.org> wrote:\n>> On Wed, Sep 17, 2008 at 04:31:17PM +0100, Jonathan del Strother <maillist@steelskies.com> wrote:\n>>> I was changing it to match the style in the existing java pattern (and\n>>> my objc pattern).  You think the java one should be changed to match\n>>> the pascal one, then?\n>> The point is that it's unrelated, so you should not change that part in\n>> the same patch. Send a separate patch if you want to do something\n>> unrelated to Objective-C.\n> \n> Johannes already convinced me to do it as a separate patch.  Andreas\n> seems to think that even if that change were in a separate patch, it\n> is pure nonsense.  I think it's pretty subjective - I was just making\n> things consistent.\n\nMy apologies. I started writing that reply before Dscho's one got to the\nlist. Then it was lunch-time, so I didn't send it until Dscho's reply\nwas already answered by you.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"91998","messageId":"1222818394-11547-1-git-send-email-jon.delStrother@bestbefore.tv","threadId":"15559","inReplyTo":"57518fd10809171630v97485aalcc5089f96082c0fc@mail.gmail.com","subject":"[PATCH v2] Teach git diff about Objective-C syntax","fromName":"Jonathan del Strother","fromEmail":"jon.delstrother@bestbefore.tv","sentAt":"2008-09-30T23:46:34Z","receivedAt":"2008-09-30T23:46:34Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"Add support for recognition of Objective-C class & instance methods, C functions, and class implementation/interfaces.\n\nSigned-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>\n---\nThis 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.\n\nI'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.\nEvery 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.\nThat is, a line containing just \"FUNCNAME\" (terminated by a newline) will be matched by the pattern \"^(FUNCNAME.$)\" but not \"^(FUNCNAME$)\".\nWhy is this?\n\n\n Documentation/gitattributes.txt |    2 ++\n diff.c                          |   10 ++++++++++\n 2 files changed, 12 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt\nindex 2ae771f..2694559 100644\n--- a/Documentation/gitattributes.txt\n+++ b/Documentation/gitattributes.txt\n@@ -315,6 +315,8 @@ patterns are available:\n \n - `java` suitable for source code in the Java language.\n \n+- `objc` suitable for source code in the Objective-C language.\n+\n - `pascal` suitable for source code in the Pascal/Delphi language.\n \n - `php` suitable for source code in the PHP language.\ndiff --git a/diff.c b/diff.c\nindex b001d7b..3694602 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1429,6 +1429,16 @@ static const struct funcname_pattern_entry builtin_funcname_pattern[] = {\n \t  \"!^[ \\t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\\n\"\n \t  \"^[ \\t]*(([ \\t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \\t]*\\\\([^;]*)$\",\n \t  REG_EXTENDED },\n+\t{ \"objc\",\n+\t  /* Negate C statements that can look like functions */\n+\t  \"!^[ \\t]*(do|for|if|else|return|switch|while)\\n\"\n+\t  /* Objective-C methods */\n+\t  \"^[ \\t]*([-+][ \\t]*\\\\([ \\t]*[A-Za-z_][A-Za-z_0-9* \\t]*\\\\)[ \\t]*[A-Za-z_].*)$\\n\"\n+\t  /* C functions */\n+\t  \"^[ \\t]*(([ \\t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \\t]*\\\\([^;]*)$\\n\"\n+\t  /* Objective-C class/protocol definitions */\n+\t  \"^(@(implementation|interface|protocol)[ \\t].*)$\",\n+\t  REG_EXTENDED },\n \t{ \"pascal\",\n \t  \"^((procedure|function|constructor|destructor|interface|\"\n \t\t\"implementation|initialization|finalization)[ \\t]*.*)$\"\n-- \n1.6.0.2.416.g8cab.dirty\n"},{"id":"92005","messageId":"mJtumbyBuR0sRaFjwb6O5_D_ps0fVfz6APTAAjYMixV0MvzP8nEZRw@cipher.nrlssc.navy.mil","threadId":"15559","inReplyTo":"1222818394-11547-1-git-send-email-jon.delStrother@bestbefore.tv","subject":"Re: [PATCH v2] Teach git diff about Objective-C syntax","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-10-01T00:52:11Z","receivedAt":"2008-10-01T00:52:11Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Jonathan del Strother wrote:\n> Add support for recognition of Objective-C class & instance methods, C functions, and class implementation/interfaces.\n> \n> Signed-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>\n> ---\n> 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.\n> \n> 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.\n> 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.\n> That is, a line containing just \"FUNCNAME\" (terminated by a newline) will be matched by the pattern \"^(FUNCNAME.$)\" but not \"^(FUNCNAME$)\".\n> Why is this?\n\nI think it is the newline which git is not removing from the string passed to regexec.\n\nSee: http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_02\n\n   \"...In the regular expression processing described in IEEE Std 1003.1-2001,\n    the <newline> is regarded as an ordinary character and both a period and a\n    non-matching list can match one.\"\n\n   \"...Those utilities (like grep) that do not allow <newline>s to match are\n    responsible for eliminating any <newline> from strings before matching against\n    the RE.\"\n\n\nPossibly something like:\n\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 8bab82e..f471c7c 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -191,7 +191,7 @@ struct ff_regs {\n static long ff_regexp(const char *line, long len,\n\t\tchar *buffer, long buffer_size, void *priv)\n {\n-\tchar *line_buffer = xstrndup(line, len); /* make NUL terminated */\n+\tchar *line_buffer = xstrndup(line, len-1); /* make NUL terminated */\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n \tint i;\n"},{"id":"92081","messageId":"o5dqpNECJusQHKCTvRWiIqN2ZJ7w-fyC-0vM99FajJIgLsOwP3RNug@cipher.nrlssc.navy.mil","threadId":"15559","inReplyTo":"mJtumbyBuR0sRaFjwb6O5_D_ps0fVfz6APTAAjYMixV0MvzP8nEZRw@cipher.nrlssc.navy.mil","subject":"[PATCH] xdiff-interface.c: strip newline (and cr) from line before pattern matching","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-10-01T19:28:26Z","receivedAt":"2008-10-01T19:28:26Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"POSIX doth sayeth:\n\n   \"In the regular expression processing described in IEEE Std 1003.1-2001,\n    the <newline> is regarded as an ordinary character and both a period and\n    a non-matching list can match one. ... Those utilities (like grep) that\n    do not allow <newline>s to match are responsible for eliminating any\n    <newline> from strings before matching against the RE.\"\n\nThus far git has not been removing the trailing newline from strings matched\nagainst regular expression patterns. This has the effect that (quoting\nJonathan del Strother) \"... a line containing just 'FUNCNAME' (terminated by\na newline) will be matched by the pattern '^(FUNCNAME.$)' but not\n'^(FUNCNAME$)'\", and more simply not '^FUNCNAME$'.\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n\n\nThis could be a little simpler if I knew what was guaranteed from xdiff.\nSuch as whether the len elements of line were guaranteed to be newline\nterminated, or be greater than zero. But, the code in def_ff() in xemit.c\nis wrapped in 'if (len > 0)', so..\n\n-brandon\n\n\n xdiff-interface.c |   12 +++++++++++-\n 1 files changed, 11 insertions(+), 1 deletions(-)\n\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 8bab82e..61f5dab 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -191,12 +191,22 @@ struct ff_regs {\n static long ff_regexp(const char *line, long len,\n \t\tchar *buffer, long buffer_size, void *priv)\n {\n-\tchar *line_buffer = xstrndup(line, len); /* make NUL terminated */\n+\tchar *line_buffer;\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n \tint i;\n \tint result = -1;\n \n+\t/* Exclude terminating newline (and cr) from matching */\n+\tif (len > 0 && line[len-1] == '\\n') {\n+\t\tif (len > 1 && line[len-2] == '\\r')\n+\t\t\tlen -= 2;\n+\t\telse\n+\t\t\tlen--;\n+\t}\n+\n+\tline_buffer = xstrndup(line, len); /* make NUL terminated */\n+\n \tfor (i = 0; i < regs->nr; i++) {\n \t\tstruct ff_reg *reg = regs->array + i;\n \t\tif (!regexec(&reg->re, line_buffer, 2, pmatch, 0)) {\n-- \n1.6.0.2.323.g7c850\n"},{"id":"92088","messageId":"alpine.DEB.1.00.0810012204280.22125@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"15559","inReplyTo":"o5dqpNECJusQHKCTvRWiIqN2ZJ7w-fyC-0vM99FajJIgLsOwP3RNug@cipher.nrlssc.navy.mil","subject":"Re: [PATCH] xdiff-interface.c: strip newline (and cr) from line before pattern matching","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-10-01T20:05:05Z","receivedAt":"2008-10-01T20:05:05Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 1 Oct 2008, Brandon Casey wrote:\n\n> POSIX doth sayeth:\n> \n>    \"In the regular expression processing described in IEEE Std 1003.1-2001,\n>     the <newline> is regarded as an ordinary character and both a period and\n>     a non-matching list can match one. ... Those utilities (like grep) that\n>     do not allow <newline>s to match are responsible for eliminating any\n>     <newline> from strings before matching against the RE.\"\n> \n> Thus far git has not been removing the trailing newline from strings matched\n> against regular expression patterns. This has the effect that (quoting\n> Jonathan del Strother) \"... a line containing just 'FUNCNAME' (terminated by\n> a newline) will be matched by the pattern '^(FUNCNAME.$)' but not\n> '^(FUNCNAME$)'\", and more simply not '^FUNCNAME$'.\n\nPersonally, I find the second paragraph pretty convincing.  Which is good, \nbecause the first fails to do that.\n\nCiao,\nDscho\n"},{"id":"92134","messageId":"57518fd10810020329w257d91f1u3e2205fdaed888eb@mail.gmail.com","threadId":"15559","inReplyTo":"o5dqpNECJusQHKCTvRWiIqN2ZJ7w-fyC-0vM99FajJIgLsOwP3RNug@cipher.nrlssc.navy.mil","subject":"Re: [PATCH] xdiff-interface.c: strip newline (and cr) from line before pattern matching","fromName":"Jonathan del Strother","fromEmail":"maillist@steelskies.com","sentAt":"2008-10-02T10:29:27Z","receivedAt":"2008-10-02T10:29:27Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"On Wed, Oct 1, 2008 at 8:28 PM, Brandon Casey <casey@nrlssc.navy.mil> wrote:\n> POSIX doth sayeth:\n>\n>   \"In the regular expression processing described in IEEE Std 1003.1-2001,\n>    the <newline> is regarded as an ordinary character and both a period and\n>    a non-matching list can match one. ... Those utilities (like grep) that\n>    do not allow <newline>s to match are responsible for eliminating any\n>    <newline> from strings before matching against the RE.\"\n>\n> Thus far git has not been removing the trailing newline from strings matched\n> against regular expression patterns. This has the effect that (quoting\n> Jonathan del Strother) \"... a line containing just 'FUNCNAME' (terminated by\n> a newline) will be matched by the pattern '^(FUNCNAME.$)' but not\n> '^(FUNCNAME$)'\", and more simply not '^FUNCNAME$'.\n>\n> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n> ---\n>\n>\n> This could be a little simpler if I knew what was guaranteed from xdiff.\n> Such as whether the len elements of line were guaranteed to be newline\n> terminated, or be greater than zero. But, the code in def_ff() in xemit.c\n> is wrapped in 'if (len > 0)', so..\n>\n> -brandon\n>\n>\n>  xdiff-interface.c |   12 +++++++++++-\n>  1 files changed, 11 insertions(+), 1 deletions(-)\n>\n> diff --git a/xdiff-interface.c b/xdiff-interface.c\n> index 8bab82e..61f5dab 100644\n> --- a/xdiff-interface.c\n> +++ b/xdiff-interface.c\n> @@ -191,12 +191,22 @@ struct ff_regs {\n>  static long ff_regexp(const char *line, long len,\n>                char *buffer, long buffer_size, void *priv)\n>  {\n> -       char *line_buffer = xstrndup(line, len); /* make NUL terminated */\n> +       char *line_buffer;\n>        struct ff_regs *regs = priv;\n>        regmatch_t pmatch[2];\n>        int i;\n>        int result = -1;\n>\n> +       /* Exclude terminating newline (and cr) from matching */\n> +       if (len > 0 && line[len-1] == '\\n') {\n> +               if (len > 1 && line[len-2] == '\\r')\n> +                       len -= 2;\n> +               else\n> +                       len--;\n> +       }\n> +\n> +       line_buffer = xstrndup(line, len); /* make NUL terminated */\n> +\n>        for (i = 0; i < regs->nr; i++) {\n>                struct ff_reg *reg = regs->array + i;\n>                if (!regexec(&reg->re, line_buffer, 2, pmatch, 0)) {\n> --\n> 1.6.0.2.323.g7c850\n>\n>\n\nLooks good to me, or at least, works as advertised with a bunch of my\nfuncname patterns.\n"},{"id":"92135","messageId":"57518fd10810020340t15d9441av521b7ef088ea09ca@mail.gmail.com","threadId":"15559","inReplyTo":"1222818394-11547-1-git-send-email-jon.delStrother@bestbefore.tv","subject":"Re: [PATCH v2] Teach git diff about Objective-C syntax","fromName":"Jonathan del Strother","fromEmail":"maillist@steelskies.com","sentAt":"2008-10-02T10:40:14Z","receivedAt":"2008-10-02T10:40:14Z","isPatch":true,"sender":{"key":"jon.delstrother@bestbefore.tv","avatar":"https://gravatar.com/avatar/754e21ab701c00e2d21fc261187254c34b2a1c0b959d9ee5be1a295990be3081?d=mp&s=160"},"body":"On Wed, Oct 1, 2008 at 12:46 AM, Jonathan del Strother\n<jon.delStrother@bestbefore.tv> wrote:\n> Add support for recognition of Objective-C class & instance methods, C functions, and class implementation/interfaces.\n>\n> Signed-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>\n> ---\n> 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.\n>\n>  Documentation/gitattributes.txt |    2 ++\n>  diff.c                          |   10 ++++++++++\n>  2 files changed, 12 insertions(+), 0 deletions(-)\n>\n> diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt\n> index 2ae771f..2694559 100644\n> --- a/Documentation/gitattributes.txt\n> +++ b/Documentation/gitattributes.txt\n> @@ -315,6 +315,8 @@ patterns are available:\n>\n>  - `java` suitable for source code in the Java language.\n>\n> +- `objc` suitable for source code in the Objective-C language.\n> +\n>  - `pascal` suitable for source code in the Pascal/Delphi language.\n>\n>  - `php` suitable for source code in the PHP language.\n> diff --git a/diff.c b/diff.c\n> index b001d7b..3694602 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -1429,6 +1429,16 @@ static const struct funcname_pattern_entry builtin_funcname_pattern[] = {\n>          \"!^[ \\t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\\n\"\n>          \"^[ \\t]*(([ \\t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \\t]*\\\\([^;]*)$\",\n>          REG_EXTENDED },\n> +       { \"objc\",\n> +         /* Negate C statements that can look like functions */\n> +         \"!^[ \\t]*(do|for|if|else|return|switch|while)\\n\"\n> +         /* Objective-C methods */\n> +         \"^[ \\t]*([-+][ \\t]*\\\\([ \\t]*[A-Za-z_][A-Za-z_0-9* \\t]*\\\\)[ \\t]*[A-Za-z_].*)$\\n\"\n> +         /* C functions */\n> +         \"^[ \\t]*(([ \\t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \\t]*\\\\([^;]*)$\\n\"\n> +         /* Objective-C class/protocol definitions */\n> +         \"^(@(implementation|interface|protocol)[ \\t].*)$\",\n> +         REG_EXTENDED },\n>        { \"pascal\",\n>          \"^((procedure|function|constructor|destructor|interface|\"\n>                \"implementation|initialization|finalization)[ \\t]*.*)$\"\n> --\n\n\nGiven Brandon's \"strip newline (and cr) from line before pattern\nmatching\" patch, the objective C line could be changed to\n\"^[ \\t]*([-+][ \\t]*\\\\([ \\t]*[A-Za-z_][A-Za-z_0-9* \\t]*\\\\)[\n\\t]*[A-Za-z_][A-Za-z_0-9:{()*& \\t]*)$\\n\"\nto be more specific about what's allowed to occur on a method line.\nDepends how often we really care about getting the funcname right -\nfor instance, do we want to deal with cases like :\n\n-(void)doStuff:(NSString*)foo {    // TODO : This is a %@^$#@ method\nname, change it.\n\n?   I suspect the additional complexity that would be added to the\nregex isn't worth the small gain - any thoughts?\n"}]}