Merge #8863 'refactor: Remove mb_head_off() '

This commit is contained in:
Justin M. Keyes
2018-08-28 23:37:30 +02:00
20 changed files with 120 additions and 160 deletions

View File

@@ -722,9 +722,7 @@ static int command_line_execute(VimState *state, int key)
s->j = ccline.cmdpos;
s->i = (int)(s->xpc.xp_pattern - ccline.cmdbuff);
while (--s->j > s->i) {
if (has_mbyte) {
s->j -= (*mb_head_off)(ccline.cmdbuff, ccline.cmdbuff + s->j);
}
s->j -= utf_head_off(ccline.cmdbuff, ccline.cmdbuff + s->j);
if (vim_ispathsep(ccline.cmdbuff[s->j])) {
found = true;
break;
@@ -744,9 +742,7 @@ static int command_line_execute(VimState *state, int key)
s->j = ccline.cmdpos - 1;
s->i = (int)(s->xpc.xp_pattern - ccline.cmdbuff);
while (--s->j > s->i) {
if (has_mbyte) {
s->j -= (*mb_head_off)(ccline.cmdbuff, ccline.cmdbuff + s->j);
}
s->j -= utf_head_off(ccline.cmdbuff, ccline.cmdbuff + s->j);
if (vim_ispathsep(ccline.cmdbuff[s->j])
#ifdef BACKSLASH_IN_FILENAME
&& vim_strchr((const char_u *)" *?[{`$%#", ccline.cmdbuff[s->j + 1])
@@ -1432,20 +1428,17 @@ static int command_line_handle_key(CommandLineState *s)
return command_line_not_changed(s);
}
do {
--ccline.cmdpos;
if (has_mbyte) { // move to first byte of char
ccline.cmdpos -= (*mb_head_off)(ccline.cmdbuff,
ccline.cmdbuff + ccline.cmdpos);
}
ccline.cmdpos--;
// Move to first byte of possibly multibyte char.
ccline.cmdpos -= utf_head_off(ccline.cmdbuff,
ccline.cmdbuff + ccline.cmdpos);
ccline.cmdspos -= cmdline_charsize(ccline.cmdpos);
} while (ccline.cmdpos > 0
&& (s->c == K_S_LEFT || s->c == K_C_LEFT
|| (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)))
&& ccline.cmdbuff[ccline.cmdpos - 1] != ' ');
if (has_mbyte) {
set_cmdspos_cursor();
}
set_cmdspos_cursor();
return command_line_not_changed(s);
@@ -2271,14 +2264,10 @@ getexmodeline (
if (c1 == BS || c1 == K_BS || c1 == DEL || c1 == K_DEL || c1 == K_KDEL) {
if (!GA_EMPTY(&line_ga)) {
if (has_mbyte) {
p = (char_u *)line_ga.ga_data;
p[line_ga.ga_len] = NUL;
len = (*mb_head_off)(p, p + line_ga.ga_len - 1) + 1;
line_ga.ga_len -= len;
} else {
line_ga.ga_len--;
}
p = (char_u *)line_ga.ga_data;
p[line_ga.ga_len] = NUL;
len = utf_head_off(p, p + line_ga.ga_len - 1) + 1;
line_ga.ga_len -= len;
goto redraw;
}
continue;
@@ -3159,18 +3148,15 @@ void put_on_cmdline(char_u *str, int len, int redraw)
i = 0;
c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos);
while (ccline.cmdpos > 0 && utf_iscomposing(c)) {
i = (*mb_head_off)(ccline.cmdbuff,
ccline.cmdbuff + ccline.cmdpos - 1) + 1;
i = utf_head_off(ccline.cmdbuff, ccline.cmdbuff + ccline.cmdpos - 1) + 1;
ccline.cmdpos -= i;
len += i;
c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos);
}
if (i == 0 && ccline.cmdpos > 0 && arabic_maycombine(c)) {
/* Check the previous character for Arabic combining pair. */
i = (*mb_head_off)(ccline.cmdbuff,
ccline.cmdbuff + ccline.cmdpos - 1) + 1;
if (arabic_combine(utf_ptr2char(ccline.cmdbuff
+ ccline.cmdpos - i), c)) {
// Check the previous character for Arabic combining pair.
i = utf_head_off(ccline.cmdbuff, ccline.cmdbuff + ccline.cmdpos - 1) + 1;
if (arabic_combine(utf_ptr2char(ccline.cmdbuff + ccline.cmdpos - i), c)) {
ccline.cmdpos -= i;
len += i;
} else