To: vim_dev@googlegroups.com Subject: Patch 8.2.3846 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3846 Problem: No error when using control character for 'lcs' or 'fcs'. Solution: Use char2cells() to check the width. (closes #9369) Files: src/screen.c, src/testdir/test_display.vim, src/testdir/test_listchars.vim *** ../vim-8.2.3845/src/screen.c 2021-11-17 20:39:29.135019718 +0000 --- src/screen.c 2021-12-18 15:07:15.178678770 +0000 *************** *** 4914,4932 **** c2 = c3 = 0; s = p + len + 1; c1 = get_encoded_char_adv(&s); ! if (mb_char2cells(c1) > 1) return e_invarg; if (tab[i].cp == &lcs_chars.tab2) { if (*s == NUL) return e_invarg; c2 = get_encoded_char_adv(&s); ! if (mb_char2cells(c2) > 1) return e_invarg; if (!(*s == ',' || *s == NUL)) { c3 = get_encoded_char_adv(&s); ! if (mb_char2cells(c3) > 1) return e_invarg; } } --- 4914,4932 ---- c2 = c3 = 0; s = p + len + 1; c1 = get_encoded_char_adv(&s); ! if (char2cells(c1) > 1) return e_invarg; if (tab[i].cp == &lcs_chars.tab2) { if (*s == NUL) return e_invarg; c2 = get_encoded_char_adv(&s); ! if (char2cells(c2) > 1) return e_invarg; if (!(*s == ',' || *s == NUL)) { c3 = get_encoded_char_adv(&s); ! if (char2cells(c3) > 1) return e_invarg; } } *************** *** 4968,4974 **** while (*s != NUL && *s != ',') { c1 = get_encoded_char_adv(&s); ! if (mb_char2cells(c1) > 1) return e_invarg; ++multispace_len; } --- 4968,4974 ---- while (*s != NUL && *s != ',') { c1 = get_encoded_char_adv(&s); ! if (char2cells(c1) > 1) return e_invarg; ++multispace_len; } *** ../vim-8.2.3845/src/testdir/test_display.vim 2021-05-29 16:56:33.833094008 +0100 --- src/testdir/test_display.vim 2021-12-18 15:07:15.178678770 +0000 *************** *** 266,271 **** --- 266,273 ---- call assert_fails(':set fillchars=eob:xy', 'E474:') call assert_fails(':set fillchars=eob:\255', 'E474:') call assert_fails(':set fillchars=eob:', 'E474:') + call assert_fails(":set fillchars=eob:\x01", 'E474:') + call assert_fails(':set fillchars=eob:\\x01', 'E474:') " default is ~ new redraw *** ../vim-8.2.3845/src/testdir/test_listchars.vim 2021-11-02 20:56:04.189640051 +0000 --- src/testdir/test_listchars.vim 2021-12-18 15:07:15.178678770 +0000 *************** *** 333,339 **** call assert_fails('set listchars=space:xx', 'E474:') call assert_fails('set listchars=tab:xxxx', 'E474:') ! " Has non-single width character call assert_fails('set listchars=space:·', 'E474:') call assert_fails('set listchars=tab:·x', 'E474:') call assert_fails('set listchars=tab:x·', 'E474:') --- 333,339 ---- call assert_fails('set listchars=space:xx', 'E474:') call assert_fails('set listchars=tab:xxxx', 'E474:') ! " Has double-width character call assert_fails('set listchars=space:·', 'E474:') call assert_fails('set listchars=tab:·x', 'E474:') call assert_fails('set listchars=tab:x·', 'E474:') *************** *** 341,346 **** --- 341,360 ---- call assert_fails('set listchars=multispace:·', 'E474:') call assert_fails('set listchars=multispace:xxx·', 'E474:') + " Has control character + call assert_fails("set listchars=space:\x01", 'E474:') + call assert_fails("set listchars=tab:\x01x", 'E474:') + call assert_fails("set listchars=tab:x\x01", 'E474:') + call assert_fails("set listchars=tab:xx\x01", 'E474:') + call assert_fails("set listchars=multispace:\x01", 'E474:') + call assert_fails("set listchars=multispace:xxx\x01", 'E474:') + call assert_fails('set listchars=space:\\x01', 'E474:') + call assert_fails('set listchars=tab:\\x01x', 'E474:') + call assert_fails('set listchars=tab:x\\x01', 'E474:') + call assert_fails('set listchars=tab:xx\\x01', 'E474:') + call assert_fails('set listchars=multispace:\\x01', 'E474:') + call assert_fails('set listchars=multispace:xxx\\x01', 'E474:') + enew! set ambiwidth& listchars& ff& endfunction *** ../vim-8.2.3845/src/version.c 2021-12-18 12:40:48.950087774 +0000 --- src/version.c 2021-12-18 15:08:59.246651704 +0000 *************** *** 751,752 **** --- 751,754 ---- { /* Add new patch number below this line */ + /**/ + 3846, /**/ -- hundred-and-one symptoms of being an internet addict: 64. The remote to the T.V. is missing...and you don't even care. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///