]> 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 b001d7b5072e71616fb36bed938d57b83e027178..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]*.*)$"
@@ -1439,8 +1449,6 @@ static const struct funcname_pattern_entry builtin_funcname_pattern[] = {
        { "python", "^[ \t]*((class|def)[ \t].*)$", REG_EXTENDED },
        { "ruby", "^[ \t]*((class|module|def)[ \t].*)$",
          REG_EXTENDED },
-       { "bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$",
-         REG_EXTENDED },
        { "tex",
          "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$",
          REG_EXTENDED },
@@ -1511,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";
@@ -3089,7 +3101,7 @@ static void diff_summary(FILE *file, struct diff_filepair *p)
 }
 
 struct patch_id_t {
-       SHA_CTX *ctx;
+       git_SHA_CTX *ctx;
        int patchlen;
 };
 
@@ -3117,7 +3129,7 @@ static void patch_id_consume(void *priv, char *line, unsigned long len)
 
        new_len = remove_space(line, len);
 
-       SHA1_Update(data->ctx, line, new_len);
+       git_SHA1_Update(data->ctx, line, new_len);
        data->patchlen += new_len;
 }
 
@@ -3126,11 +3138,11 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
 {
        struct diff_queue_struct *q = &diff_queued_diff;
        int i;
-       SHA_CTX ctx;
+       git_SHA_CTX ctx;
        struct patch_id_t data;
        char buffer[PATH_MAX * 4 + 20];
 
-       SHA1_Init(&ctx);
+       git_SHA1_Init(&ctx);
        memset(&data, 0, sizeof(struct patch_id_t));
        data.ctx = &ctx;
 
@@ -3192,7 +3204,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
                                        len2, p->two->path,
                                        len1, p->one->path,
                                        len2, p->two->path);
-               SHA1_Update(&ctx, buffer, len1);
+               git_SHA1_Update(&ctx, buffer, len1);
 
                xpp.flags = XDF_NEED_MINIMAL;
                xecfg.ctxlen = 3;
@@ -3201,7 +3213,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
                              &xpp, &xecfg, &ecb);
        }
 
-       SHA1_Final(sha1, &ctx);
+       git_SHA1_Final(sha1, &ctx);
        return 0;
 }