X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=xdiff-interface.c;h=49e06af710ceee5538eb10f0c6cf9c30f31748b4;hb=310d188f7e1d1fbbeace17d5c62e422fd0b5a824;hp=f3f6db3297e4fd367d7af05a4755037aaf2aaf42;hpb=bc36540e6e1c94cefc1dc1a201800e832eb99194;p=git.git diff --git a/xdiff-interface.c b/xdiff-interface.c index f3f6db329..49e06af71 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -207,6 +207,16 @@ static long ff_regexp(const char *line, long 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)) {