diff options
Diffstat (limited to 'xdiff-interface.c')
-rw-r--r-- | xdiff-interface.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/xdiff-interface.c b/xdiff-interface.c index f3f6db3297..49e06af710 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)) { |