diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-28 18:30:05 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-28 18:30:05 +0000 |
commit | 06f6095623cfcc72da08748c058d13b465652fd4 (patch) | |
tree | 383d299d0fdfe09e47d7268aa64b67057225c0b6 /src/diff.c | |
parent | 7473a84cf935f64ddd4ea7fe7eee0f9c51c50b60 (diff) |
patch 8.2.3925: diff mode confused by NUL bytesv8.2.3925
Problem: Diff mode confused by NUL bytes.
Solution: Handle NUL bytes differently. (Christian Brabandt, closes #9421,
closes #9418)
Diffstat (limited to 'src/diff.c')
-rw-r--r-- | src/diff.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/diff.c b/src/diff.c index ceb73a6bd9..9fb8726b4d 100644 --- a/src/diff.c +++ b/src/diff.c @@ -777,9 +777,14 @@ diff_write_buffer(buf_T *buf, diffin_T *din) int orig_len; char_u cbuf[MB_MAXBYTES + 1]; - // xdiff doesn't support ignoring case, fold-case the text. - c = PTR2CHAR(s); - c = MB_CASEFOLD(c); + if (*s == NL) + c = NUL; + else + { + // xdiff doesn't support ignoring case, fold-case the text. + c = PTR2CHAR(s); + c = MB_CASEFOLD(c); + } orig_len = mb_ptr2len(s); if (mb_char2bytes(c, cbuf) != orig_len) // TODO: handle byte length difference @@ -791,7 +796,10 @@ diff_write_buffer(buf_T *buf, diffin_T *din) len += orig_len; } else - ptr[len++] = *s++; + { + ptr[len++] = *s == NL ? NUL : *s; + s++; + } } ptr[len++] = NL; } |