X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=xdiff-interface.c;h=3bf83f81e38d4a4cc114f3c577241cf7b9eddc7e;hb=f6276b788f26c3c148c2d5465a6b03fc09bb785c;hp=2c81f40cb657f6e49bc6a7431f830a037713ab38;hpb=edb7e82f72106add9f2fbaf9d99d9532a72e3f91;p=git.git diff --git a/xdiff-interface.c b/xdiff-interface.c index 2c81f40cb..3bf83f81e 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -179,11 +179,21 @@ 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 result = 0, i; + /* 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 (reg->negate ^ !!regexec(®->re,