]> asedeno.scripts.mit.edu Git - git.git/blobdiff - diff.c
Merge branch 'js/objc-funchdr'
[git.git] / diff.c
diff --git a/diff.c b/diff.c
index 4e4e439e03f13a2bd9aaf63179ce50e4b72ed48e..2af3a974872e3bafeead339503a0d1eab051779d 100644 (file)
--- 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]*.*)$"
@@ -1509,6 +1519,10 @@ static void builtin_diff(const char *name_a,
                b_prefix = o->b_prefix;
        }
 
+       /* Never use a non-valid filename anywhere if at all possible */
+       name_a = DIFF_FILE_VALID(one) ? name_a : name_b;
+       name_b = DIFF_FILE_VALID(two) ? name_b : name_a;
+
        a_one = quote_two(a_prefix, name_a + (*name_a == '/'));
        b_two = quote_two(b_prefix, name_b + (*name_b == '/'));
        lbl[0] = DIFF_FILE_VALID(one) ? a_one : "/dev/null";