Re: [PATCH 3/6] Make diff -w handle trailing-spaces on incomplete lines.
- From
Thell Fowler <git@tbfowler.name>
- Date
- Aug 20, 2009, 23:09 UTC
- Message-ID
- <alpine.DEB.2.00.0908201803170.2012@GWPortableVCS>
- In-Reply-To
- <alpine.DEB.2.00.0908191725440.2012@GWPortableVCS>
Thell Fowler (git@tbfowler.name) wrote on Aug 19, 2009:
Show 15 quoted lines
> - When processing trailing spaces with --ignore-all-space a diff
> would be found whenever one side had 0 spaces and either (or both)
> sides was an incomplete line. xdl_recmatch should process the
> full length of the record instead of assuming both sides have a
> terminator.
>
> @@ -191,14 +191,14 @@ int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags)
> int i1, i2;
>
> if (flags & XDF_IGNORE_WHITESPACE) {
> - for (i1 = i2 = 0; i1 < s1 && i2 < s2; ) {
> + for (i1 = i2 = 0; i1 <= s1 && i2 <= s2; ) {
> if (isspace(l1[i1]))
> - while (isspace(l1[i1]) && i1 < s1)
> + while (isspace(l1[i1]) && i1 <= s1)The change from '<' to <=' obviously did do jack-diddly-squat, which I should have noticed earlier.
> i1++; > if (isspace(l2[i2])) > - while (isspace(l2[i2]) && i2 < s2) > + while (isspace(l2[i2]) && i2 <= s2)
Here too.
Show 7 quoted lines
> i2++; > - if (i1 < s1 && i2 < s2 && l1[i1++] != l2[i2++]) > + if (i1 <= s1 && i2 <= s2 && l1[i1++] != l2[i2++]) > return 0; > } > return (i1 >= s1 && i2 >= s2); >
Those will be corrected for v2.
-- Thell