mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 22:18:33 +00:00
vim-patch:8.0.1372: profile log may be truncated halfway a character
Problem: Profile log may be truncated halfway a character.
Solution: Find the start of the character. (Ozaki Kiichi, closes vim/vim#2385)
ac112f01a6
nvim does not support "--clean" yet but "-es" should suffice for the test.
This commit is contained in:

committed by
Jan Edmund Lazo

parent
4352d41db0
commit
c1ee5e0694
@@ -1152,6 +1152,21 @@ static void script_dump_profile(FILE *fd)
|
||||
if (vim_fgets(IObuff, IOSIZE, sfd)) {
|
||||
break;
|
||||
}
|
||||
// When a line has been truncated, append NL, taking care
|
||||
// of multi-byte characters .
|
||||
if (IObuff[IOSIZE - 2] != NUL && IObuff[IOSIZE - 2] != NL) {
|
||||
int n = IOSIZE - 2;
|
||||
|
||||
// Move to the first byte of this char.
|
||||
// utf_head_off() doesn't work, because it checks
|
||||
// for a truncated character.
|
||||
while (n > 0 && (IObuff[n] & 0xc0) == 0x80) {
|
||||
n--;
|
||||
}
|
||||
|
||||
IObuff[n] = NL;
|
||||
IObuff[n + 1] = NUL;
|
||||
}
|
||||
if (i < si->sn_prl_ga.ga_len
|
||||
&& (pp = &PRL_ITEM(si, i))->snp_count > 0) {
|
||||
fprintf(fd, "%5d ", pp->snp_count);
|
||||
|
Reference in New Issue
Block a user