Mercurial > vim
diff src/diff.c @ 26794:83a99f08d1e8 v8.2.3925
patch 8.2.3925: diff mode confused by NUL bytes
Commit: https://github.com/vim/vim/commit/06f6095623cfcc72da08748c058d13b465652fd4
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Dec 28 18:30:05 2021 +0000
patch 8.2.3925: diff mode confused by NUL bytes
Problem: Diff mode confused by NUL bytes.
Solution: Handle NUL bytes differently. (Christian Brabandt, closes https://github.com/vim/vim/issues/9421,
closes #9418)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 28 Dec 2021 19:45:04 +0100 |
parents | b802798e4a26 |
children | 77ff030699d2 |
line wrap: on
line diff
--- a/src/diff.c +++ b/src/diff.c @@ -777,9 +777,14 @@ diff_write_buffer(buf_T *buf, diffin_T * 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 * len += orig_len; } else - ptr[len++] = *s++; + { + ptr[len++] = *s == NL ? NUL : *s; + s++; + } } ptr[len++] = NL; }