[PATCH 2/4] xdiff-interface.c: always trim trailing space from xfuncname matches
- From
Brandon Casey <casey@nrlssc.navy.mil>
- Date
- Sep 9, 2010, 19:02 UTC
- Message-ID
- <rRj7JpFIk_D_n7-wGkkucCda_kClmekHTPEHOGwmU5nYdmNhqqgzF59v609YFx69vv526WtEpyU@cipher.nrlssc.navy.mil>
- In-Reply-To
- <rRj7JpFIk_D_n7-wGkkucFJE0330IabsqMoSzalswHpjT-Z1HCuOFaIgMsaPgIuQSp0KUMW97Wo@cipher.nrlssc.navy.mil>
From: Brandon Casey <drafnel@gmail.com>
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> --- xdiff-interface.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/xdiff-interface.c b/xdiff-interface.c index cd2285d..e1e054e 100644 --- a/xdiff-interface.c +++ b/xdiff-interface.c @@ -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);
-- 1.7.2.1