@@ -4693,6 +4693,8 @@ static struct charstab lcstab[] =
46934693#else
46944694 {NULL , "conceal" },
46954695#endif
4696+ {NULL , "multispace" },
4697+ {NULL , "leadmultispace" },
46964698};
46974699
46984700/*
@@ -4706,7 +4708,7 @@ static struct charstab lcstab[] =
47064708 static char *
47074709set_chars_option (win_T * wp , char_u * value , int is_listchars , int apply )
47084710{
4709- int round , i , len , len2 , entries ;
4711+ int round , i , len , entries ;
47104712 char_u * p , * s ;
47114713 int c1 = 0 , c2 = 0 , c3 = 0 ;
47124714 char_u * last_multispace = NULL ; // Last occurrence of "multispace:"
@@ -4784,58 +4786,12 @@ set_chars_option(win_T *wp, char_u *value, int is_listchars, int apply)
47844786 for (i = 0 ; i < entries ; ++ i )
47854787 {
47864788 len = (int )STRLEN (tab [i ].name );
4787- if (STRNCMP (p , tab [i ].name , len ) == 0
4789+ if (!( STRNCMP (p , tab [i ].name , len ) == 0
47884790 && p [len ] == ':'
4789- && p [len + 1 ] != NUL )
4790- {
4791- c2 = c3 = 0 ;
4792- s = p + len + 1 ;
4793- c1 = get_encoded_char_adv (& s );
4794- if (char2cells (c1 ) > 1 )
4795- return e_invalid_argument ;
4796- if (tab [i ].cp == & lcs_chars .tab2 )
4797- {
4798- if (* s == NUL )
4799- return e_invalid_argument ;
4800- c2 = get_encoded_char_adv (& s );
4801- if (char2cells (c2 ) > 1 )
4802- return e_invalid_argument ;
4803- if (!(* s == ',' || * s == NUL ))
4804- {
4805- c3 = get_encoded_char_adv (& s );
4806- if (char2cells (c3 ) > 1 )
4807- return e_invalid_argument ;
4808- }
4809- }
4791+ && p [len + 1 ] != NUL ))
4792+ continue ;
48104793
4811- if (* s == ',' || * s == NUL )
4812- {
4813- if (round > 0 )
4814- {
4815- if (tab [i ].cp == & lcs_chars .tab2 )
4816- {
4817- lcs_chars .tab1 = c1 ;
4818- lcs_chars .tab2 = c2 ;
4819- lcs_chars .tab3 = c3 ;
4820- }
4821- else if (tab [i ].cp != NULL )
4822- * (tab [i ].cp ) = c1 ;
4823-
4824- }
4825- p = s ;
4826- break ;
4827- }
4828- }
4829- }
4830-
4831- if (i == entries )
4832- {
4833- len = (int )STRLEN ("multispace" );
4834- len2 = (int )STRLEN ("leadmultispace" );
4835- if (is_listchars
4836- && STRNCMP (p , "multispace" , len ) == 0
4837- && p [len ] == ':'
4838- && p [len + 1 ] != NUL )
4794+ if (is_listchars && strcmp (tab [i ].name , "multispace" ) == 0 )
48394795 {
48404796 s = p + len + 1 ;
48414797 if (round == 0 )
@@ -4867,14 +4823,12 @@ set_chars_option(win_T *wp, char_u *value, int is_listchars, int apply)
48674823 }
48684824 p = s ;
48694825 }
4826+ break ;
48704827 }
48714828
4872- else if (is_listchars
4873- && STRNCMP (p , "leadmultispace" , len2 ) == 0
4874- && p [len2 ] == ':'
4875- && p [len2 + 1 ] != NUL )
4829+ if (is_listchars && strcmp (tab [i ].name , "leadmultispace" ) == 0 )
48764830 {
4877- s = p + len2 + 1 ;
4831+ s = p + len + 1 ;
48784832 if (round == 0 )
48794833 {
48804834 // get length of lcs-leadmultispace string in first
@@ -4905,11 +4859,51 @@ set_chars_option(win_T *wp, char_u *value, int is_listchars, int apply)
49054859 }
49064860 p = s ;
49074861 }
4862+ break ;
49084863 }
4909- else
4864+
4865+ c2 = c3 = 0 ;
4866+ s = p + len + 1 ;
4867+ c1 = get_encoded_char_adv (& s );
4868+ if (char2cells (c1 ) > 1 )
49104869 return e_invalid_argument ;
4870+ if (tab [i ].cp == & lcs_chars .tab2 )
4871+ {
4872+ if (* s == NUL )
4873+ return e_invalid_argument ;
4874+ c2 = get_encoded_char_adv (& s );
4875+ if (char2cells (c2 ) > 1 )
4876+ return e_invalid_argument ;
4877+ if (!(* s == ',' || * s == NUL ))
4878+ {
4879+ c3 = get_encoded_char_adv (& s );
4880+ if (char2cells (c3 ) > 1 )
4881+ return e_invalid_argument ;
4882+ }
4883+ }
4884+
4885+ if (* s == ',' || * s == NUL )
4886+ {
4887+ if (round > 0 )
4888+ {
4889+ if (tab [i ].cp == & lcs_chars .tab2 )
4890+ {
4891+ lcs_chars .tab1 = c1 ;
4892+ lcs_chars .tab2 = c2 ;
4893+ lcs_chars .tab3 = c3 ;
4894+ }
4895+ else if (tab [i ].cp != NULL )
4896+ * (tab [i ].cp ) = c1 ;
4897+
4898+ }
4899+ p = s ;
4900+ break ;
4901+ }
49114902 }
49124903
4904+ if (i == entries )
4905+ return e_invalid_argument ;
4906+
49134907 if (* p == ',' )
49144908 ++ p ;
49154909 }
0 commit comments