- Allow xdl_recmatch to recognize and continue processing when at the end of an incomplete line. Resolves issue with --ignore-space-change when an incomplete line terminated before the eol whitespace handling started by allowing the processing loop to continue when one side has reached the end and includes a check for being at the eol on an incomplete line. Signed-off-by: Thell Fowler <git@xxxxxxxxxxxxx> --- xdiff/xutils.c | 25 ++++++++++++++++++------- 1 files changed, 18 insertions(+), 7 deletions(-) diff --git a/xdiff/xutils.c b/xdiff/xutils.c index e22b4bb..54bb235 100644 --- a/xdiff/xutils.c +++ b/xdiff/xutils.c @@ -205,16 +205,27 @@ int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags) } return (i1 >= s1 && i2 >= s2); } else if (flags & XDF_IGNORE_WHITESPACE_CHANGE) { - for (i1 = i2 = 0; i1 < s1 && i2 < s2; ) { - if (isspace(l1[i1])) { - if (!isspace(l2[i2])) + for (i1 = i2 = 0; i1 < s1 || i2 < s2;) { + if (isspace(l1[i1]) || i1 == s1) { + if (!isspace(l2[i2]) && i2 != s2 && l2[s2] != '\n') return 0; - while (isspace(l1[i1]) && i1 < s1) + while ((isspace(l1[i1]) && i1 < s1) + || (i1 + 1 == s1 && l1[s1] != '\n')) i1++; - while (isspace(l2[i2]) && i2 < s2) + while ((isspace(l2[i2]) && i2 < s2) + || (i2 + 1 == s2 && l2[s2] != '\n')) i2++; - } else if (l1[i1++] != l2[i2++]) - return 0; + } else { + if (l1[i1] != l2[i2] && ((i1 != s1 && l1[s1] != '\n') + || (i2 != s2 && l2[s2] != '\n'))) + return 0; + else { + if (i1 < s1) + i1++; + if (i2 < s2) + i2++; + } + } } return (i1 >= s1 && i2 >= s2); } else if (flags & XDF_IGNORE_WHITESPACE_AT_EOL) { -- 1.6.4.176.g556a4 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html