X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=xdiff-interface.c;h=e8ef46d10dc53a1ee1781d07685984734bc3160f;hb=b43b73666be32ecdc27384d67dc88e4b4869efa1;hp=70794c71fcbf198c7425a49789a912369fba28ad;hpb=86295bb6bac1482d29650d1f77f19d8e7a7cc2fe;p=git.git diff --git a/xdiff-interface.c b/xdiff-interface.c index 70794c71f..e8ef46d10 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -254,6 +254,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)) {