X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=xdiff-interface.c;h=49e06af710ceee5538eb10f0c6cf9c30f31748b4;hb=efcce2e1f0b37aed045d3e2b747380adf418bdd2;hp=8bab82ed7fd1fcfea4dd13f6d020476758a18031;hpb=78a935d48b28ebf5b1af348d7e57763f2955afd1;p=git.git diff --git a/xdiff-interface.c b/xdiff-interface.c index 8bab82ed7..49e06af71 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -191,12 +191,32 @@ struct ff_regs { static long ff_regexp(const char *line, long len, char *buffer, long buffer_size, void *priv) { - char *line_buffer = xstrndup(line, len); /* make NUL terminated */ + char *line_buffer; struct ff_regs *regs = priv; regmatch_t pmatch[2]; int i; int result = -1; + /* Exclude terminating newline (and cr) from matching */ + if (len > 0 && line[len-1] == '\n') { + if (len > 1 && line[len-2] == '\r') + len -= 2; + else + len--; + } + + line_buffer = xstrndup(line, len); /* make NUL terminated */ + + /* Exclude terminating newline (and cr) from matching */ + if (len > 0 && line[len-1] == '\n') { + if (len > 1 && line[len-2] == '\r') + len -= 2; + else + 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(®->re, line_buffer, 2, pmatch, 0)) {