diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2008-10-09 10:24:24 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2008-10-09 10:24:24 -0700 |
commit | bc36540e6e1c94cefc1dc1a201800e832eb99194 (patch) | |
tree | a1372a10a6e3054421cdf9244f1644fedb845043 | |
parent | ed187bd5936267744aa579ab1a33f0b07862a74b (diff) | |
parent | a5a5a04863036678919705979b9c0f3579fa3710 (diff) | |
download | git-bc36540e6e1c94cefc1dc1a201800e832eb99194.tar.gz git-bc36540e6e1c94cefc1dc1a201800e832eb99194.tar.xz |
Merge branch 'bc/xdiffnl'
* bc/xdiffnl:
xdiff-interface.c: strip newline (and cr) from line before pattern matching
-rw-r--r-- | xdiff-interface.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/xdiff-interface.c b/xdiff-interface.c index 8bab82ed7..f3f6db329 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -191,12 +191,22 @@ 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 */ + for (i = 0; i < regs->nr; i++) { struct ff_reg *reg = regs->array + i; if (!regexec(®->re, line_buffer, 2, pmatch, 0)) { |