mirror of
https://github.com/neovim/neovim.git
synced 2025-10-16 23:06:14 +00:00
vim-patch:8.1.0810: too many #ifdefs
Problem: Too many #ifdefs.
Solution: Graduate FEAT_MBYTE, part 4.
264b74fa54
This commit is contained in:
@@ -218,14 +218,11 @@ char_u *reverse_text(char_u *s) FUNC_ATTR_NONNULL_RET
|
||||
size_t len = STRLEN(s);
|
||||
char_u *rev = xmalloc(len + 1);
|
||||
size_t rev_i = len;
|
||||
for (size_t s_i = 0; s_i < len; ++s_i) {
|
||||
if (has_mbyte) {
|
||||
int mb_len = (*mb_ptr2len)(s + s_i);
|
||||
rev_i -= mb_len;
|
||||
memmove(rev + rev_i, s + s_i, mb_len);
|
||||
s_i += mb_len - 1;
|
||||
} else
|
||||
rev[--rev_i] = s[s_i];
|
||||
for (size_t s_i = 0; s_i < len; s_i++) {
|
||||
const int mb_len = utfc_ptr2len(s + s_i);
|
||||
rev_i -= mb_len;
|
||||
memmove(rev + rev_i, s + s_i, mb_len);
|
||||
s_i += mb_len - 1;
|
||||
}
|
||||
rev[len] = NUL;
|
||||
|
||||
@@ -594,8 +591,8 @@ int searchit(
|
||||
// is zero.
|
||||
if (pos->col == MAXCOL) {
|
||||
start_char_len = 0;
|
||||
} else if (has_mbyte
|
||||
&& pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count
|
||||
} else if (pos->lnum >= 1
|
||||
&& pos->lnum <= buf->b_ml.ml_line_count
|
||||
&& pos->col < MAXCOL - 2) {
|
||||
// Watch out for the "col" being MAXCOL - 2, used in a closed fold.
|
||||
ptr = ml_get_buf(buf, pos->lnum, false);
|
||||
@@ -1553,34 +1550,26 @@ int searchc(cmdarg_T *cap, int t_cmd)
|
||||
len = (int)STRLEN(p);
|
||||
|
||||
while (count--) {
|
||||
if (has_mbyte) {
|
||||
for (;; ) {
|
||||
if (dir > 0) {
|
||||
col += (*mb_ptr2len)(p + col);
|
||||
if (col >= len)
|
||||
return FAIL;
|
||||
} else {
|
||||
if (col == 0)
|
||||
return FAIL;
|
||||
col -= utf_head_off(p, p + col - 1) + 1;
|
||||
}
|
||||
if (lastc_bytelen == 1) {
|
||||
if (p[col] == c && stop) {
|
||||
break;
|
||||
}
|
||||
} else if (STRNCMP(p + col, lastc_bytes, lastc_bytelen) == 0 && stop) {
|
||||
break;
|
||||
}
|
||||
stop = true;
|
||||
}
|
||||
} else {
|
||||
for (;; ) {
|
||||
if ((col += dir) < 0 || col >= len)
|
||||
for (;; ) {
|
||||
if (dir > 0) {
|
||||
col += utfc_ptr2len(p + col);
|
||||
if (col >= len) {
|
||||
return FAIL;
|
||||
if (p[col] == c && stop)
|
||||
break;
|
||||
stop = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (col == 0) {
|
||||
return FAIL;
|
||||
}
|
||||
col -= utf_head_off(p, p + col - 1) + 1;
|
||||
}
|
||||
if (lastc_bytelen == 1) {
|
||||
if (p[col] == c && stop) {
|
||||
break;
|
||||
}
|
||||
} else if (STRNCMP(p + col, lastc_bytes, lastc_bytelen) == 0 && stop) {
|
||||
break;
|
||||
}
|
||||
stop = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1964,10 +1953,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|
||||
if (lisp) /* find comment pos in new line */
|
||||
comment_col = check_linecomment(linep);
|
||||
} else {
|
||||
if (has_mbyte)
|
||||
pos.col += (*mb_ptr2len)(linep + pos.col);
|
||||
else
|
||||
++pos.col;
|
||||
pos.col += utfc_ptr2len(linep + pos.col);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user