]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.3846: no error when using control character for 'lcs' or 'fcs' v8.2.3846
authorzeertzjq <zeertzjq@outlook.com>
Sat, 18 Dec 2021 15:32:46 +0000 (15:32 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 18 Dec 2021 15:32:46 +0000 (15:32 +0000)
Problem:    No error when using control character for 'lcs' or 'fcs'.
Solution:   Use char2cells() to check the width. (closes #9369)

src/screen.c
src/testdir/test_display.vim
src/testdir/test_listchars.vim
src/version.c

index aee18d8e4432c276249136fa1998505f01c27850..695318b89c9eee6f6b97e400b8545295d8f8f296 100644 (file)
@@ -4914,19 +4914,19 @@ set_chars_option(win_T *wp, char_u **varp)
                    c2 = c3 = 0;
                    s = p + len + 1;
                    c1 = get_encoded_char_adv(&s);
-                   if (mb_char2cells(c1) > 1)
+                   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 (mb_char2cells(c2) > 1)
+                       if (char2cells(c2) > 1)
                            return e_invarg;
                        if (!(*s == ',' || *s == NUL))
                        {
                            c3 = get_encoded_char_adv(&s);
-                           if (mb_char2cells(c3) > 1)
+                           if (char2cells(c3) > 1)
                                return e_invarg;
                        }
                    }
@@ -4968,7 +4968,7 @@ set_chars_option(win_T *wp, char_u **varp)
                        while (*s != NUL && *s != ',')
                        {
                            c1 = get_encoded_char_adv(&s);
-                           if (mb_char2cells(c1) > 1)
+                           if (char2cells(c1) > 1)
                                return e_invarg;
                            ++multispace_len;
                        }
index 964220cacda4422193d555074264e0cf89c7b891..c14dc7812fa1be94ac4e963cb6ae552bdc89f582 100644 (file)
@@ -266,6 +266,8 @@ func Test_eob_fillchars()
   call assert_fails(':set fillchars=eob:xy', 'E474:')
   call assert_fails(':set fillchars=eob:\255', 'E474:')
   call assert_fails(':set fillchars=eob:<ff>', 'E474:')
+  call assert_fails(":set fillchars=eob:\x01", 'E474:')
+  call assert_fails(':set fillchars=eob:\\x01', 'E474:')
   " default is ~
   new
   redraw
index 9cf215213bb9af5b6e71c1c74cb6a6ce527ebbd7..90e3d6b24195de4f4f612e78a6756713c204c066 100644 (file)
@@ -333,7 +333,7 @@ func Test_listchars_invalid()
   call assert_fails('set listchars=space:xx', 'E474:')
   call assert_fails('set listchars=tab:xxxx', 'E474:')
 
-  " Has non-single width character
+  " 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,6 +341,20 @@ func Test_listchars_invalid()
   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
index 262a330c66ddee8029f86dd3a85ad4ad8ee04a5d..92612d5a3d0d8fe5ce90b48654ae6fd170edc843 100644 (file)
@@ -749,6 +749,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3846,
 /**/
     3845,
 /**/