@@ -4167,9 +4167,6 @@ build_stl_str_hl(
4167
4167
4168
4168
if (fillchar == 0 )
4169
4169
fillchar = ' ' ;
4170
- // Can't handle a multi-byte fill character yet.
4171
- else if (mb_char2len (fillchar ) > 1 )
4172
- fillchar = '-' ;
4173
4170
4174
4171
// The cursor in windows other than the current one isn't always
4175
4172
// up-to-date, esp. because of autocommands and timers.
@@ -4345,7 +4342,7 @@ build_stl_str_hl(
4345
4342
4346
4343
// Fill up space left over by half a double-wide char.
4347
4344
while (++ l < stl_items [stl_groupitem [groupdepth ]].stl_minwid )
4348
- * p ++ = fillchar ;
4345
+ MB_CHAR2BYTES ( fillchar , p ) ;
4349
4346
4350
4347
// correct the start of the items for the truncation
4351
4348
for (l = stl_groupitem [groupdepth ] + 1 ; l < curitem ; l ++ )
@@ -4364,20 +4361,20 @@ build_stl_str_hl(
4364
4361
// fill by appending characters
4365
4362
n = 0 - n ;
4366
4363
while (l ++ < n && p + 1 < out + outlen )
4367
- * p ++ = fillchar ;
4364
+ MB_CHAR2BYTES ( fillchar , p ) ;
4368
4365
}
4369
4366
else
4370
4367
{
4371
4368
// fill by inserting characters
4372
- mch_memmove ( t + n - l , t , ( size_t )( p - t ) );
4373
- l = n - l ;
4369
+ l = ( n - l ) * MB_CHAR2LEN ( fillchar );
4370
+ mch_memmove ( t + l , t , ( size_t )( p - t )) ;
4374
4371
if (p + l >= out + outlen )
4375
4372
l = (long )((out + outlen ) - p - 1 );
4376
4373
p += l ;
4377
4374
for (n = stl_groupitem [groupdepth ] + 1 ; n < curitem ; n ++ )
4378
4375
stl_items [n ].stl_start += l ;
4379
4376
for ( ; l > 0 ; l -- )
4380
- * t ++ = fillchar ;
4377
+ MB_CHAR2BYTES ( fillchar , t ) ;
4381
4378
}
4382
4379
}
4383
4380
continue ;
@@ -4756,23 +4753,24 @@ build_stl_str_hl(
4756
4753
if (l + 1 == minwid && fillchar == '-' && VIM_ISDIGIT (* t ))
4757
4754
* p ++ = ' ' ;
4758
4755
else
4759
- * p ++ = fillchar ;
4756
+ MB_CHAR2BYTES ( fillchar , p ) ;
4760
4757
}
4761
4758
minwid = 0 ;
4762
4759
}
4763
4760
else
4764
4761
minwid *= -1 ;
4765
- while ( * t && p + 1 < out + outlen )
4762
+ for (; * t && p + 1 < out + outlen ; t ++ )
4766
4763
{
4767
- * p ++ = * t ++ ;
4768
4764
// Change a space by fillchar, unless fillchar is '-' and a
4769
4765
// digit follows.
4770
- if (fillable && p [-1 ] == ' '
4771
- && (!VIM_ISDIGIT (* t ) || fillchar != '-' ))
4772
- p [-1 ] = fillchar ;
4766
+ if (fillable && * t == ' '
4767
+ && (!VIM_ISDIGIT (* (t + 1 )) || fillchar != '-' ))
4768
+ MB_CHAR2BYTES (fillchar , p );
4769
+ else
4770
+ * p ++ = * t ;
4773
4771
}
4774
4772
for (; l < minwid && p + 1 < out + outlen ; l ++ )
4775
- * p ++ = fillchar ;
4773
+ MB_CHAR2BYTES ( fillchar , p ) ;
4776
4774
}
4777
4775
else if (num >= 0 )
4778
4776
{
@@ -4875,7 +4873,7 @@ build_stl_str_hl(
4875
4873
}
4876
4874
// Fill up for half a double-wide character.
4877
4875
while (++ width < maxwidth )
4878
- * s ++ = fillchar ;
4876
+ MB_CHAR2BYTES ( fillchar , s ) ;
4879
4877
}
4880
4878
else
4881
4879
s = out + maxwidth - 1 ;
@@ -4907,7 +4905,7 @@ build_stl_str_hl(
4907
4905
while (++ width < maxwidth )
4908
4906
{
4909
4907
s = s + STRLEN (s );
4910
- * s ++ = fillchar ;
4908
+ MB_CHAR2BYTES ( fillchar , s ) ;
4911
4909
* s = NUL ;
4912
4910
}
4913
4911
@@ -4930,12 +4928,13 @@ build_stl_str_hl(
4930
4928
break ;
4931
4929
if (l < itemcnt )
4932
4930
{
4933
- p = stl_items [l ].stl_start + maxwidth - width ;
4931
+ int middlelength = (maxwidth - width ) * MB_CHAR2LEN (fillchar );
4932
+ p = stl_items [l ].stl_start + middlelength ;
4934
4933
STRMOVE (p , stl_items [l ].stl_start );
4935
- for (s = stl_items [l ].stl_start ; s < p ; s ++ )
4936
- * s = fillchar ;
4934
+ for (s = stl_items [l ].stl_start ; s < p ;)
4935
+ MB_CHAR2BYTES ( fillchar , s ) ;
4937
4936
for (l ++ ; l < itemcnt ; l ++ )
4938
- stl_items [l ].stl_start += maxwidth - width ;
4937
+ stl_items [l ].stl_start += middlelength ;
4939
4938
width = maxwidth ;
4940
4939
}
4941
4940
}
0 commit comments