Mercurial > vim
comparison src/ex_cmds2.c @ 12992:5532b5176870 v8.0.1372
patch 8.0.1372: profile log may be truncated halfway a character
commit https://github.com/vim/vim/commit/ac112f01a6930c9d15cf0360b657373699916bfd
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Dec 5 16:46:28 2017 +0100
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 https://github.com/vim/vim/issues/2385)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 05 Dec 2017 17:00:07 +0100 |
parents | 1a450ce6980c |
children | afd60028f7b7 |
comparison
equal
deleted
inserted
replaced
12991:0d7aa7f7b0aa | 12992:5532b5176870 |
---|---|
1832 * continuation lines are listed. */ | 1832 * continuation lines are listed. */ |
1833 for (i = 0; ; ++i) | 1833 for (i = 0; ; ++i) |
1834 { | 1834 { |
1835 if (vim_fgets(IObuff, IOSIZE, sfd)) | 1835 if (vim_fgets(IObuff, IOSIZE, sfd)) |
1836 break; | 1836 break; |
1837 /* When a line has been truncated, append NL, taking care | |
1838 * of multi-byte characters . */ | |
1839 if (IObuff[IOSIZE - 2] != NUL && IObuff[IOSIZE - 2] != NL) | |
1840 { | |
1841 int n = IOSIZE - 2; | |
1842 # ifdef FEAT_MBYTE | |
1843 if (enc_utf8) | |
1844 { | |
1845 /* Move to the first byte of this char. | |
1846 * utf_head_off() doesn't work, because it checks | |
1847 * for a truncated character. */ | |
1848 while (n > 0 && (IObuff[n] & 0xc0) == 0x80) | |
1849 --n; | |
1850 } | |
1851 else if (has_mbyte) | |
1852 n -= mb_head_off(IObuff, IObuff + n); | |
1853 # endif | |
1854 IObuff[n] = NL; | |
1855 IObuff[n + 1] = NUL; | |
1856 } | |
1837 if (i < si->sn_prl_ga.ga_len | 1857 if (i < si->sn_prl_ga.ga_len |
1838 && (pp = &PRL_ITEM(si, i))->snp_count > 0) | 1858 && (pp = &PRL_ITEM(si, i))->snp_count > 0) |
1839 { | 1859 { |
1840 fprintf(fd, "%5d ", pp->snp_count); | 1860 fprintf(fd, "%5d ", pp->snp_count); |
1841 if (profile_equal(&pp->sn_prl_total, &pp->sn_prl_self)) | 1861 if (profile_equal(&pp->sn_prl_total, &pp->sn_prl_self)) |