Skip to content

Commit

Permalink
xdiff-interface.c: always trim trailing space from xfuncname matches
Browse files Browse the repository at this point in the history
Generally, trailing space is removed from the string matched by the
xfuncname patterns.  The exception is when the matched string exceeds the
length of the fixed-size buffer that it will be copied in to.  But, a
string that exceeds the buffer can still contain trailing space in the
portion of the string that will be copied into the buffer.  So, simplify
this code slightly, and just perform the trailing space removal always.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Brandon Casey authored and Junio C Hamano committed Sep 10, 2010
1 parent ef5644e commit 1b6ecba
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions xdiff-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,8 @@ static long ff_regexp(const char *line, long len,
result = pmatch[i].rm_eo - pmatch[i].rm_so;
if (result > buffer_size)
result = buffer_size;
else
while (result > 0 && (isspace(line[result - 1])))
result--;
while (result > 0 && (isspace(line[result - 1])))
result--;
memcpy(buffer, line, result);
fail:
free(line_buffer);
Expand Down

0 comments on commit 1b6ecba

Please sign in to comment.