Skip to content

Commit

Permalink
Merge branch 'bc/xdiffnl'
Browse files Browse the repository at this point in the history
* bc/xdiffnl:
  xdiff-interface.c: strip newline (and cr) from line before pattern matching
  • Loading branch information
Shawn O. Pearce committed Oct 9, 2008
2 parents ed187bd + a5a5a04 commit bc36540
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion xdiff-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(&reg->re, line_buffer, 2, pmatch, 0)) {
Expand Down

0 comments on commit bc36540

Please sign in to comment.