Skip to content

Commit 1b6ecba

Browse files
drafnelgitster
authored andcommitted
xdiff-interface.c: always trim trailing space from xfuncname matches
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ef5644e commit 1b6ecba

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

xdiff-interface.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,8 @@ static long ff_regexp(const char *line, long len,
286286
result = pmatch[i].rm_eo - pmatch[i].rm_so;
287287
if (result > buffer_size)
288288
result = buffer_size;
289-
else
290-
while (result > 0 && (isspace(line[result - 1])))
291-
result--;
289+
while (result > 0 && (isspace(line[result - 1])))
290+
result--;
292291
memcpy(buffer, line, result);
293292
fail:
294293
free(line_buffer);

0 commit comments

Comments
 (0)