verify_dotfile: mention case-insensitivity in comment
[gitweb.git] / xdiff-interface.c
index f34ea762e477d9874ef8d75e24f54230520a6e4b..060038c2d6b92512e6625d0f5d94ed5439cd249c 100644 (file)
@@ -178,20 +178,20 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
        return 0;
 }
 
-void read_mmblob(mmfile_t *ptr, const unsigned char *sha1)
+void read_mmblob(mmfile_t *ptr, const struct object_id *oid)
 {
        unsigned long size;
        enum object_type type;
 
-       if (!hashcmp(sha1, null_sha1)) {
+       if (!oidcmp(oid, &null_oid)) {
                ptr->ptr = xstrdup("");
                ptr->size = 0;
                return;
        }
 
-       ptr->ptr = read_sha1_file(sha1, &type, &size);
+       ptr->ptr = read_sha1_file(oid->hash, &type, &size);
        if (!ptr->ptr || type != OBJ_BLOB)
-               die("unable to read blob object %s", sha1_to_hex(sha1));
+               die("unable to read blob object %s", oid_to_hex(oid));
        ptr->size = size;
 }
 
@@ -214,11 +214,10 @@ struct ff_regs {
 static long ff_regexp(const char *line, long len,
                char *buffer, long buffer_size, void *priv)
 {
-       char *line_buffer;
        struct ff_regs *regs = priv;
        regmatch_t pmatch[2];
        int i;
-       int result = -1;
+       int result;
 
        /* Exclude terminating newline (and cr) from matching */
        if (len > 0 && line[len-1] == '\n') {
@@ -228,18 +227,16 @@ static long ff_regexp(const char *line, long len,
                        len--;
        }
 
-       line_buffer = xstrndup(line, len); /* make NUL terminated */
-
        for (i = 0; i < regs->nr; i++) {
                struct ff_reg *reg = regs->array + i;
-               if (!regexec(&reg->re, line_buffer, 2, pmatch, 0)) {
+               if (!regexec_buf(&reg->re, line, len, 2, pmatch, 0)) {
                        if (reg->negate)
-                               goto fail;
+                               return -1;
                        break;
                }
        }
        if (regs->nr <= i)
-               goto fail;
+               return -1;
        i = pmatch[1].rm_so >= 0 ? 1 : 0;
        line += pmatch[i].rm_so;
        result = pmatch[i].rm_eo - pmatch[i].rm_so;
@@ -248,8 +245,6 @@ static long ff_regexp(const char *line, long len,
        while (result > 0 && (isspace(line[result - 1])))
                result--;
        memcpy(buffer, line, result);
- fail:
-       free(line_buffer);
        return result;
 }