refactor(macros): delete multibyte macros which just are aliases

This commit is contained in:
Björn Linse
2021-11-14 13:34:59 +01:00
parent ede00b29d1
commit 54ff21a153
17 changed files with 85 additions and 90 deletions

View File

@@ -778,7 +778,7 @@ int del_bytes(colnr_T count, bool fixpos_arg, bool use_delcombine)
col = n; col = n;
count = utf_ptr2len(oldp + n); count = utf_ptr2len(oldp + n);
n += count; n += count;
} while (UTF_COMPOSINGLIKE(oldp + col, oldp + n)); } while (utf_composinglike(oldp + col, oldp + n));
fixpos = false; fixpos = false;
} }
} }

View File

@@ -744,7 +744,7 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din)
char_u cbuf[MB_MAXBYTES + 1]; char_u cbuf[MB_MAXBYTES + 1];
// xdiff doesn't support ignoring case, fold-case the text. // xdiff doesn't support ignoring case, fold-case the text.
int c = PTR2CHAR(s); int c = utf_ptr2char(s);
c = utf_fold(c); c = utf_fold(c);
const int orig_len = utfc_ptr2len(s); const int orig_len = utfc_ptr2len(s);
if (utf_char2bytes(c, cbuf) != orig_len) { if (utf_char2bytes(c, cbuf) != orig_len) {

View File

@@ -708,7 +708,7 @@ static int insert_execute(VimState *state, int key)
if (str != NULL) { if (str != NULL) {
for (p = str; *p != NUL; MB_PTR_ADV(p)) { for (p = str; *p != NUL; MB_PTR_ADV(p)) {
ins_compl_addleader(PTR2CHAR(p)); ins_compl_addleader(utf_ptr2char(p));
} }
xfree(str); xfree(str);
} else { } else {
@@ -1283,7 +1283,7 @@ normalchar:
if (*str != NUL && stop_arrow() != FAIL) { if (*str != NUL && stop_arrow() != FAIL) {
// Insert the new value of v:char literally. // Insert the new value of v:char literally.
for (p = str; *p != NUL; MB_PTR_ADV(p)) { for (p = str; *p != NUL; MB_PTR_ADV(p)) {
s->c = PTR2CHAR(p); s->c = utf_ptr2char(p);
if (s->c == CAR || s->c == K_KENTER || s->c == NL) { if (s->c == CAR || s->c == K_KENTER || s->c == NL) {
ins_eol(s->c); ins_eol(s->c);
} else { } else {
@@ -3547,7 +3547,7 @@ static void ins_compl_addfrommatch(void)
} }
} }
p += len; p += len;
c = PTR2CHAR(p); c = utf_ptr2char(p);
ins_compl_addleader(c); ins_compl_addleader(c);
} }
@@ -5177,10 +5177,10 @@ static int ins_complete(int c, bool enable_pum)
char_u *p = line + startcol; char_u *p = line + startcol;
MB_PTR_BACK(line, p); MB_PTR_BACK(line, p);
while (p > line && vim_isfilec(PTR2CHAR(p))) { while (p > line && vim_isfilec(utf_ptr2char(p))) {
MB_PTR_BACK(line, p); MB_PTR_BACK(line, p);
} }
if (p == line && vim_isfilec(PTR2CHAR(p))) { if (p == line && vim_isfilec(utf_ptr2char(p))) {
startcol = 0; startcol = 0;
} else { } else {
startcol = (int)(p - line) + 1; startcol = (int)(p - line) + 1;

View File

@@ -10628,7 +10628,7 @@ static void f_strgetchar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
break; break;
} }
charidx--; charidx--;
byteidx += MB_CPTR2LEN((const char_u *)str + byteidx); byteidx += utf_ptr2len((const char_u *)str + byteidx);
} }
} }
@@ -10745,7 +10745,7 @@ static void f_strcharpart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (!error) { if (!error) {
if (nchar > 0) { if (nchar > 0) {
while (nchar > 0 && (size_t)nbyte < slen) { while (nchar > 0 && (size_t)nbyte < slen) {
nbyte += MB_CPTR2LEN((const char_u *)p + nbyte); nbyte += utf_ptr2len((const char_u *)p + nbyte);
nchar--; nchar--;
} }
} else { } else {
@@ -10761,7 +10761,7 @@ static void f_strcharpart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (off < 0) { if (off < 0) {
len += 1; len += 1;
} else { } else {
len += (size_t)MB_CPTR2LEN((const char_u *)p + off); len += (size_t)utf_ptr2len((const char_u *)p + off);
} }
charlen--; charlen--;
} }
@@ -11739,14 +11739,14 @@ static void f_trim(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (dir == 0 || dir == 1) { if (dir == 0 || dir == 1) {
// Trim leading characters // Trim leading characters
while (*head != NUL) { while (*head != NUL) {
c1 = PTR2CHAR(head); c1 = utf_ptr2char(head);
if (mask == NULL) { if (mask == NULL) {
if (c1 > ' ' && c1 != 0xa0) { if (c1 > ' ' && c1 != 0xa0) {
break; break;
} }
} else { } else {
for (p = mask; *p != NUL; MB_PTR_ADV(p)) { for (p = mask; *p != NUL; MB_PTR_ADV(p)) {
if (c1 == PTR2CHAR(p)) { if (c1 == utf_ptr2char(p)) {
break; break;
} }
} }
@@ -11764,14 +11764,14 @@ static void f_trim(typval_T *argvars, typval_T *rettv, FunPtr fptr)
for (; tail > head; tail = prev) { for (; tail > head; tail = prev) {
prev = tail; prev = tail;
MB_PTR_BACK(head, prev); MB_PTR_BACK(head, prev);
c1 = PTR2CHAR(prev); c1 = utf_ptr2char(prev);
if (mask == NULL) { if (mask == NULL) {
if (c1 > ' ' && c1 != 0xa0) { if (c1 > ' ' && c1 != 0xa0) {
break; break;
} }
} else { } else {
for (p = mask; *p != NUL; MB_PTR_ADV(p)) { for (p = mask; *p != NUL; MB_PTR_ADV(p)) {
if (c1 == PTR2CHAR(p)) { if (c1 == utf_ptr2char(p)) {
break; break;
} }
} }

View File

@@ -1113,8 +1113,8 @@ static bool ff_wc_equal(char_u *s1, char_u *s2)
} }
for (i = 0, j = 0; s1[i] != NUL && s2[j] != NUL;) { for (i = 0, j = 0; s1[i] != NUL && s2[j] != NUL;) {
c1 = PTR2CHAR(s1 + i); c1 = utf_ptr2char(s1 + i);
c2 = PTR2CHAR(s2 + j); c2 = utf_ptr2char(s2 + j);
if ((p_fic ? mb_tolower(c1) != mb_tolower(c2) : c1 != c2) if ((p_fic ? mb_tolower(c1) != mb_tolower(c2) : c1 != c2)
&& (prev1 != '*' || prev2 != '*')) { && (prev1 != '*' || prev2 != '*')) {

View File

@@ -3996,8 +3996,8 @@ char_u *vim_strsave_escape_csi(char_u *p)
} else { } else {
// Add character, possibly multi-byte to destination, escaping // Add character, possibly multi-byte to destination, escaping
// CSI and K_SPECIAL. Be careful, it can be an illegal byte! // CSI and K_SPECIAL. Be careful, it can be an illegal byte!
d = add_char2buf(PTR2CHAR(s), d); d = add_char2buf(utf_ptr2char(s), d);
s += MB_CPTR2LEN(s); s += utf_ptr2len(s);
} }
} }
*d = NUL; *d = NUL;

View File

@@ -692,7 +692,7 @@ int find_special_key(const char_u **srcp, const size_t src_len, int *const modp,
l = utfc_ptr2len(last_dash + 1); l = utfc_ptr2len(last_dash + 1);
} }
if (modifiers != 0 && last_dash[l + 1] == '>') { if (modifiers != 0 && last_dash[l + 1] == '>') {
key = PTR2CHAR(last_dash + off); key = utf_ptr2char(last_dash + off);
} else { } else {
key = get_special_key_code(last_dash + off); key = get_special_key_code(last_dash + off);
if (!keep_x_key) { if (!keep_x_key) {

View File

@@ -92,14 +92,11 @@
#define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG)) #define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))
#define UTF_COMPOSINGLIKE(p1, p2) utf_composinglike((p1), (p2))
// MB_PTR_ADV(): advance a pointer to the next character, taking care of // MB_PTR_ADV(): advance a pointer to the next character, taking care of
// multi-byte characters if needed. // multi-byte characters if needed.
// MB_PTR_BACK(): backup a pointer to the previous character, taking care of // MB_PTR_BACK(): backup a pointer to the previous character, taking care of
// multi-byte characters if needed. // multi-byte characters if needed.
// MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers. // MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers.
// PTR2CHAR(): get character from pointer.
// Advance multi-byte pointer, skip over composing chars. // Advance multi-byte pointer, skip over composing chars.
#define MB_PTR_ADV(p) (p += utfc_ptr2len((char_u *)p)) #define MB_PTR_ADV(p) (p += utfc_ptr2len((char_u *)p))
@@ -108,14 +105,9 @@
// Backup multi-byte pointer. Only use with "p" > "s" ! // Backup multi-byte pointer. Only use with "p" > "s" !
#define MB_PTR_BACK(s, p) \ #define MB_PTR_BACK(s, p) \
(p -= utf_head_off((char_u *)s, (char_u *)p - 1) + 1) (p -= utf_head_off((char_u *)s, (char_u *)p - 1) + 1)
// get length of multi-byte char, not including composing chars
#define MB_CPTR2LEN(p) utf_ptr2len(p)
#define MB_COPY_CHAR(f, t) mb_copy_char((const char_u **)(&f), &t); #define MB_COPY_CHAR(f, t) mb_copy_char((const char_u **)(&f), &t);
#define MB_CHARLEN(p) mb_charlen(p)
#define PTR2CHAR(p) utf_ptr2char(p)
#define RESET_BINDING(wp) \ #define RESET_BINDING(wp) \
do { \ do { \
(wp)->w_p_scb = false; \ (wp)->w_p_scb = false; \

View File

@@ -762,7 +762,7 @@ int utfc_ptr2char(const char_u *p, int *pcc)
// Only accept a composing char when the first char isn't illegal. // Only accept a composing char when the first char isn't illegal.
if ((len > 1 || *p < 0x80) if ((len > 1 || *p < 0x80)
&& p[len] >= 0x80 && p[len] >= 0x80
&& UTF_COMPOSINGLIKE(p, p + len)) { && utf_composinglike(p, p + len)) {
cc = utf_ptr2char(p + len); cc = utf_ptr2char(p + len);
for (;; ) { for (;; ) {
pcc[i++] = cc; pcc[i++] = cc;
@@ -792,7 +792,7 @@ int utfc_ptr2char(const char_u *p, int *pcc)
int utfc_ptr2char_len(const char_u *p, int *pcc, int maxlen) int utfc_ptr2char_len(const char_u *p, int *pcc, int maxlen)
{ {
#define IS_COMPOSING(s1, s2, s3) \ #define IS_COMPOSING(s1, s2, s3) \
(i == 0 ? UTF_COMPOSINGLIKE((s1), (s2)) : utf_iscomposing((s3))) (i == 0 ? utf_composinglike((s1), (s2)) : utf_iscomposing((s3)))
assert(maxlen > 0); assert(maxlen > 0);
@@ -914,7 +914,7 @@ int utfc_ptr2len(const char_u *const p)
// skip all of them (otherwise the cursor would get stuck). // skip all of them (otherwise the cursor would get stuck).
int prevlen = 0; int prevlen = 0;
for (;;) { for (;;) {
if (p[len] < 0x80 || !UTF_COMPOSINGLIKE(p + prevlen, p + len)) { if (p[len] < 0x80 || !utf_composinglike(p + prevlen, p + len)) {
return len; return len;
} }
@@ -964,14 +964,14 @@ int utfc_ptr2len_len(const char_u *p, int size)
/* /*
* Next character length should not go beyond size to ensure that * Next character length should not go beyond size to ensure that
* UTF_COMPOSINGLIKE(...) does not read beyond size. * utf_composinglike(...) does not read beyond size.
*/ */
len_next_char = utf_ptr2len_len(p + len, size - len); len_next_char = utf_ptr2len_len(p + len, size - len);
if (len_next_char > size - len) { if (len_next_char > size - len) {
break; break;
} }
if (!UTF_COMPOSINGLIKE(p + prevlen, p + len)) { if (!utf_composinglike(p + prevlen, p + len)) {
break; break;
} }

View File

@@ -359,8 +359,8 @@ int path_fnamencmp(const char *const fname1, const char *const fname2, size_t le
const char *p1 = fname1; const char *p1 = fname1;
const char *p2 = fname2; const char *p2 = fname2;
while (len > 0) { while (len > 0) {
c1 = PTR2CHAR((const char_u *)p1); c1 = utf_ptr2char((const char_u *)p1);
c2 = PTR2CHAR((const char_u *)p2); c2 = utf_ptr2char((const char_u *)p2);
if ((c1 == NUL || c2 == NUL if ((c1 == NUL || c2 == NUL
|| (!((c1 == '/' || c1 == '\\') && (c2 == '\\' || c2 == '/')))) || (!((c1 == '/' || c1 == '\\') && (c2 == '\\' || c2 == '/'))))
&& (p_fic ? (c1 != c2 && CH_FOLD(c1) != CH_FOLD(c2)) : c1 != c2)) { && (p_fic ? (c1 != c2 && CH_FOLD(c1) != CH_FOLD(c2)) : c1 != c2)) {
@@ -631,7 +631,7 @@ static size_t do_path_expand(garray_T *gap, const char_u *path, size_t wildoff,
&& (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL && (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL
#ifndef WIN32 #ifndef WIN32
|| (!p_fic && (flags & EW_ICASE) || (!p_fic && (flags & EW_ICASE)
&& isalpha(PTR2CHAR(path_end))) && isalpha(utf_ptr2char(path_end)))
#endif #endif
)) { )) {
e = p; e = p;
@@ -1937,8 +1937,8 @@ int pathcmp(const char *p, const char *q, int maxlen)
const char *s = NULL; const char *s = NULL;
for (i = 0, j = 0; maxlen < 0 || (i < maxlen && j < maxlen);) { for (i = 0, j = 0; maxlen < 0 || (i < maxlen && j < maxlen);) {
c1 = PTR2CHAR((char_u *)p + i); c1 = utf_ptr2char((char_u *)p + i);
c2 = PTR2CHAR((char_u *)q + j); c2 = utf_ptr2char((char_u *)q + j);
// End of "p": check if "q" also ends or just has a slash. // End of "p": check if "q" also ends or just has a slash.
if (c1 == NUL) { if (c1 == NUL) {
@@ -1980,8 +1980,8 @@ int pathcmp(const char *p, const char *q, int maxlen)
return 0; return 0;
} }
c1 = PTR2CHAR((char_u *)s + i); c1 = utf_ptr2char((char_u *)s + i);
c2 = PTR2CHAR((char_u *)s + i + utfc_ptr2len((char_u *)s + i)); c2 = utf_ptr2char((char_u *)s + i + utfc_ptr2len((char_u *)s + i));
// ignore a trailing slash, but not "//" or ":/" // ignore a trailing slash, but not "//" or ":/"
if (c2 == NUL if (c2 == NUL
&& i > 0 && i > 0

View File

@@ -424,7 +424,7 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he
col %= numberextra; col %= numberextra;
} }
if (*sbr != NUL) { if (*sbr != NUL) {
sbrlen = (colnr_T)MB_CHARLEN(sbr); sbrlen = (colnr_T)mb_charlen(sbr);
if (col >= sbrlen) { if (col >= sbrlen) {
col -= sbrlen; col -= sbrlen;
} }

View File

@@ -2509,8 +2509,9 @@ do_multibyte:
/* Need to get composing character too. */ /* Need to get composing character too. */
for (;; ) { for (;; ) {
l = utf_ptr2len(regparse); l = utf_ptr2len(regparse);
if (!UTF_COMPOSINGLIKE(regparse, regparse + l)) if (!utf_composinglike(regparse, regparse + l)) {
break; break;
}
regmbc(utf_ptr2char(regparse)); regmbc(utf_ptr2char(regparse));
skipchr(); skipchr();
} }
@@ -4127,7 +4128,7 @@ static bool regmatch(
break; break;
case PRINT: case PRINT:
if (!vim_isprintc(PTR2CHAR(rex.input))) { if (!vim_isprintc(utf_ptr2char(rex.input))) {
status = RA_NOMATCH; status = RA_NOMATCH;
} else { } else {
ADVANCE_REGINPUT(); ADVANCE_REGINPUT();
@@ -4135,7 +4136,7 @@ static bool regmatch(
break; break;
case SPRINT: case SPRINT:
if (ascii_isdigit(*rex.input) || !vim_isprintc(PTR2CHAR(rex.input))) { if (ascii_isdigit(*rex.input) || !vim_isprintc(utf_ptr2char(rex.input))) {
status = RA_NOMATCH; status = RA_NOMATCH;
} else { } else {
ADVANCE_REGINPUT(); ADVANCE_REGINPUT();
@@ -4294,7 +4295,7 @@ static bool regmatch(
// Check for following composing character, unless %C // Check for following composing character, unless %C
// follows (skips over all composing chars). // follows (skips over all composing chars).
if (status != RA_NOMATCH if (status != RA_NOMATCH
&& UTF_COMPOSINGLIKE(rex.input, rex.input + len) && utf_composinglike(rex.input, rex.input + len)
&& !rex.reg_icombine && !rex.reg_icombine
&& OP(next) != RE_COMPOSING) { && OP(next) != RE_COMPOSING) {
// raaron: This code makes a composing character get // raaron: This code makes a composing character get
@@ -5269,7 +5270,7 @@ regrepeat (
case SIDENT: case SIDENT:
case SIDENT + ADD_NL: case SIDENT + ADD_NL:
while (count < maxcount) { while (count < maxcount) {
if (vim_isIDc(PTR2CHAR(scan)) && (testval || !ascii_isdigit(*scan))) { if (vim_isIDc(utf_ptr2char(scan)) && (testval || !ascii_isdigit(*scan))) {
MB_PTR_ADV(scan); MB_PTR_ADV(scan);
} else if (*scan == NUL) { } else if (*scan == NUL) {
if (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline if (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline
@@ -5326,7 +5327,7 @@ regrepeat (
case SFNAME: case SFNAME:
case SFNAME + ADD_NL: case SFNAME + ADD_NL:
while (count < maxcount) { while (count < maxcount) {
if (vim_isfilec(PTR2CHAR(scan)) && (testval || !ascii_isdigit(*scan))) { if (vim_isfilec(utf_ptr2char(scan)) && (testval || !ascii_isdigit(*scan))) {
MB_PTR_ADV(scan); MB_PTR_ADV(scan);
} else if (*scan == NUL) { } else if (*scan == NUL) {
if (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline if (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline
@@ -5364,7 +5365,7 @@ regrepeat (
if (got_int) { if (got_int) {
break; break;
} }
} else if (vim_isprintc(PTR2CHAR(scan)) == 1 } else if (vim_isprintc(utf_ptr2char(scan)) == 1
&& (testval || !ascii_isdigit(*scan))) { && (testval || !ascii_isdigit(*scan))) {
MB_PTR_ADV(scan); MB_PTR_ADV(scan);
} else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) { } else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) {

View File

@@ -1310,9 +1310,10 @@ static int nfa_regatom(void)
return FAIL; return FAIL;
} }
for (lp = reg_prev_sub; *lp != NUL; MB_CPTR_ADV(lp)) { for (lp = reg_prev_sub; *lp != NUL; MB_CPTR_ADV(lp)) {
EMIT(PTR2CHAR(lp)); EMIT(utf_ptr2char(lp));
if (lp != reg_prev_sub) if (lp != reg_prev_sub) {
EMIT(NFA_CONCAT); EMIT(NFA_CONCAT);
}
} }
EMIT(NFA_NOPEN); EMIT(NFA_NOPEN);
break; break;
@@ -1722,9 +1723,10 @@ collection:
} }
} }
/* Normal printable char */ // Normal printable char
if (startc == -1) if (startc == -1) {
startc = PTR2CHAR(regparse); startc = utf_ptr2char(regparse);
}
/* Previous char was '-', so this char is end of range. */ /* Previous char was '-', so this char is end of range. */
if (emit_range) { if (emit_range) {
@@ -4996,9 +4998,9 @@ static long find_match_text(colnr_T startcol, int regstart, char_u *match_text)
char_u *s2 = rex.line + col + regstart_len; // skip regstart char_u *s2 = rex.line + col + regstart_len; // skip regstart
while (*s1) { while (*s1) {
int c1_len = PTR2LEN(s1); int c1_len = PTR2LEN(s1);
int c1 = PTR2CHAR(s1); int c1 = utf_ptr2char(s1);
int c2_len = PTR2LEN(s2); int c2_len = PTR2LEN(s2);
int c2 = PTR2CHAR(s2); int c2 = utf_ptr2char(s2);
if ((c1 != c2 && (!rex.reg_ic || utf_fold(c1) != utf_fold(c2))) if ((c1 != c2 && (!rex.reg_ic || utf_fold(c1) != utf_fold(c2)))
|| c1_len != c2_len) { || c1_len != c2_len) {
@@ -5010,7 +5012,7 @@ static long find_match_text(colnr_T startcol, int regstart, char_u *match_text)
} }
if (match if (match
// check that no composing char follows // check that no composing char follows
&& !utf_iscomposing(PTR2CHAR(s2))) { && !utf_iscomposing(utf_ptr2char(s2))) {
cleanup_subexpr(); cleanup_subexpr();
if (REG_MULTI) { if (REG_MULTI) {
rex.reg_startpos[0].lnum = rex.lnum; rex.reg_startpos[0].lnum = rex.lnum;
@@ -5808,12 +5810,12 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start,
break; break;
case NFA_PRINT: // \p case NFA_PRINT: // \p
result = vim_isprintc(PTR2CHAR(rex.input)); result = vim_isprintc(utf_ptr2char(rex.input));
ADD_STATE_IF_MATCH(t->state); ADD_STATE_IF_MATCH(t->state);
break; break;
case NFA_SPRINT: // \P case NFA_SPRINT: // \P
result = !ascii_isdigit(curc) && vim_isprintc(PTR2CHAR(rex.input)); result = !ascii_isdigit(curc) && vim_isprintc(utf_ptr2char(rex.input));
ADD_STATE_IF_MATCH(t->state); ADD_STATE_IF_MATCH(t->state);
break; break;
@@ -6306,7 +6308,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start,
} else { } else {
// Checking if the required start character matches is // Checking if the required start character matches is
// cheaper than adding a state that won't match. // cheaper than adding a state that won't match.
const int c = PTR2CHAR(rex.input + clen); const int c = utf_ptr2char(rex.input + clen);
if (c != prog->regstart if (c != prog->regstart
&& (!rex.reg_ic && (!rex.reg_ic
|| utf_fold(c) != utf_fold(prog->regstart))) { || utf_fold(c) != utf_fold(prog->regstart))) {

View File

@@ -2944,7 +2944,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
if (wp->w_skipcol == 0 || !wp->w_p_wrap) { if (wp->w_skipcol == 0 || !wp->w_p_wrap) {
need_showbreak = false; need_showbreak = false;
} }
vcol_sbr = vcol + MB_CHARLEN(sbr); vcol_sbr = vcol + mb_charlen(sbr);
// Correct end of highlighted area for 'showbreak', // Correct end of highlighted area for 'showbreak',
// required when 'linebreak' is also set. // required when 'linebreak' is also set.
if (tocol == vcol) { if (tocol == vcol) {
@@ -3582,7 +3582,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
// We have just drawn the showbreak value, no need to add // We have just drawn the showbreak value, no need to add
// space for it again. // space for it again.
if (vcol == vcol_sbr) { if (vcol == vcol_sbr) {
n_extra -= MB_CHARLEN(get_showbreak_value(wp)); n_extra -= mb_charlen(get_showbreak_value(wp));
if (n_extra < 0) { if (n_extra < 0) {
n_extra = 0; n_extra = 0;
} }
@@ -3678,7 +3678,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
// Only adjust the tab_len, when at the first column after the // Only adjust the tab_len, when at the first column after the
// showbreak value was drawn. // showbreak value was drawn.
if (*sbr != NUL && vcol == vcol_sbr && wp->w_p_wrap) { if (*sbr != NUL && vcol == vcol_sbr && wp->w_p_wrap) {
vcol_adjusted = vcol - MB_CHARLEN(sbr); vcol_adjusted = vcol - mb_charlen(sbr);
} }
// tab amount depends on current column // tab amount depends on current column
tab_len = tabstop_padding(vcol_adjusted, tab_len = tabstop_padding(vcol_adjusted,

View File

@@ -1871,7 +1871,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
--pos.col; --pos.col;
} }
for (;; ) { for (;; ) {
initc = PTR2CHAR(linep + pos.col); initc = utf_ptr2char(linep + pos.col);
if (initc == NUL) { if (initc == NUL) {
break; break;
} }
@@ -2197,7 +2197,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
* inquote if the number of quotes in a line is even, unless this * inquote if the number of quotes in a line is even, unless this
* line or the previous one ends in a '\'. Complicated, isn't it? * line or the previous one ends in a '\'. Complicated, isn't it?
*/ */
const int c = PTR2CHAR(linep + pos.col); const int c = utf_ptr2char(linep + pos.col);
switch (c) { switch (c) {
case NUL: case NUL:
// at end of line without trailing backslash, reset inquote // at end of line without trailing backslash, reset inquote
@@ -2378,12 +2378,12 @@ void showmatch(int c)
* Only show match for chars in the 'matchpairs' option. * Only show match for chars in the 'matchpairs' option.
*/ */
// 'matchpairs' is "x:y,x:y" // 'matchpairs' is "x:y,x:y"
for (p = curbuf->b_p_mps; *p != NUL; ++p) { for (p = curbuf->b_p_mps; *p != NUL; p++) {
if (PTR2CHAR(p) == c && (curwin->w_p_rl ^ p_ri)) { if (utf_ptr2char(p) == c && (curwin->w_p_rl ^ p_ri)) {
break; break;
} }
p += utfc_ptr2len(p) + 1; p += utfc_ptr2len(p) + 1;
if (PTR2CHAR(p) == c && !(curwin->w_p_rl ^ p_ri)) { if (utf_ptr2char(p) == c && !(curwin->w_p_rl ^ p_ri)) {
break; break;
} }
p += utfc_ptr2len(p); p += utfc_ptr2len(p);

View File

@@ -397,7 +397,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou
bool this_upper = false; // init for gcc bool this_upper = false; // init for gcc
if (use_camel_case) { if (use_camel_case) {
c = PTR2CHAR(mi.mi_fend); c = utf_ptr2char(mi.mi_fend);
this_upper = SPELL_ISUPPER(c); this_upper = SPELL_ISUPPER(c);
} }
@@ -405,7 +405,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou
MB_PTR_ADV(mi.mi_fend); MB_PTR_ADV(mi.mi_fend);
if (use_camel_case) { if (use_camel_case) {
const bool prev_upper = this_upper; const bool prev_upper = this_upper;
c = PTR2CHAR(mi.mi_fend); c = utf_ptr2char(mi.mi_fend);
this_upper = SPELL_ISUPPER(c); this_upper = SPELL_ISUPPER(c);
camel_case = !prev_upper && this_upper; camel_case = !prev_upper && this_upper;
} }
@@ -414,7 +414,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou
if (capcol != NULL && *capcol == 0 && wp->w_s->b_cap_prog != NULL) { if (capcol != NULL && *capcol == 0 && wp->w_s->b_cap_prog != NULL) {
// Check word starting with capital letter. // Check word starting with capital letter.
c = PTR2CHAR(ptr); c = utf_ptr2char(ptr);
if (!SPELL_ISUPPER(c)) { if (!SPELL_ISUPPER(c)) {
wrongcaplen = (size_t)(mi.mi_fend - ptr); wrongcaplen = (size_t)(mi.mi_fend - ptr);
} }
@@ -2423,7 +2423,7 @@ int captype(char_u *word, char_u *end)
// But a word with an upper char only at start is a ONECAP. // But a word with an upper char only at start is a ONECAP.
for (; end == NULL ? *p != NUL : p < end; MB_PTR_ADV(p)) { for (; end == NULL ? *p != NUL : p < end; MB_PTR_ADV(p)) {
if (spell_iswordp_nmw(p, curwin)) { if (spell_iswordp_nmw(p, curwin)) {
c = PTR2CHAR(p); c = utf_ptr2char(p);
if (!SPELL_ISUPPER(c)) { if (!SPELL_ISUPPER(c)) {
// UUl -> KEEPCAP // UUl -> KEEPCAP
if (past_second && allcap) { if (past_second && allcap) {
@@ -2464,7 +2464,7 @@ static int badword_captype(char_u *word, char_u *end)
l = u = 0; l = u = 0;
first = false; first = false;
for (p = word; p < end; MB_PTR_ADV(p)) { for (p = word; p < end; MB_PTR_ADV(p)) {
c = PTR2CHAR(p); c = utf_ptr2char(p);
if (SPELL_ISUPPER(c)) { if (SPELL_ISUPPER(c)) {
++u; ++u;
if (p == word) { if (p == word) {
@@ -3314,7 +3314,7 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
// If the word is not capitalised and spell_check() doesn't consider the // If the word is not capitalised and spell_check() doesn't consider the
// word to be bad then it might need to be capitalised. Add a suggestion // word to be bad then it might need to be capitalised. Add a suggestion
// for that. // for that.
c = PTR2CHAR(su->su_badptr); c = utf_ptr2char(su->su_badptr);
if (!SPELL_ISUPPER(c) && attr == HLF_COUNT) { if (!SPELL_ISUPPER(c) && attr == HLF_COUNT) {
make_case_word(su->su_badword, buf, WF_ONECAP); make_case_word(su->su_badword, buf, WF_ONECAP);
add_suggestion(su, &su->su_ga, buf, su->su_badlen, SCORE_ICASE, add_suggestion(su, &su->su_ga, buf, su->su_badlen, SCORE_ICASE,
@@ -4609,7 +4609,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
break; break;
} }
n = MB_CPTR2LEN(p); n = utf_ptr2len(p);
c = utf_ptr2char(p); c = utf_ptr2char(p);
if (p[n] == NUL) { if (p[n] == NUL) {
c2 = NUL; c2 = NUL;
@@ -4669,9 +4669,9 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// Swap two bytes, skipping one: "123" -> "321". We change // Swap two bytes, skipping one: "123" -> "321". We change
// "fword" here, it's changed back afterwards at STATE_UNSWAP3. // "fword" here, it's changed back afterwards at STATE_UNSWAP3.
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
n = MB_CPTR2LEN(p); n = utf_ptr2len(p);
c = utf_ptr2char(p); c = utf_ptr2char(p);
fl = MB_CPTR2LEN(p + n); fl = utf_ptr2len(p + n);
c2 = utf_ptr2char(p + n); c2 = utf_ptr2char(p + n);
if (!soundfold && !spell_iswordp(p + n + fl, curwin)) { if (!soundfold && !spell_iswordp(p + n + fl, curwin)) {
c3 = c; // don't swap non-word char c3 = c; // don't swap non-word char
@@ -4746,10 +4746,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
sp->ts_state = STATE_UNROT3L; sp->ts_state = STATE_UNROT3L;
++depth; ++depth;
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
n = MB_CPTR2LEN(p); n = utf_ptr2len(p);
c = utf_ptr2char(p); c = utf_ptr2char(p);
fl = MB_CPTR2LEN(p + n); fl = utf_ptr2len(p + n);
fl += MB_CPTR2LEN(p + n + fl); fl += utf_ptr2len(p + n + fl);
memmove(p, p + n, fl); memmove(p, p + n, fl);
utf_char2bytes(c, p + fl); utf_char2bytes(c, p + fl);
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl; stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
@@ -4783,10 +4783,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
sp->ts_state = STATE_UNROT3R; sp->ts_state = STATE_UNROT3R;
++depth; ++depth;
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
n = MB_CPTR2LEN(p); n = utf_ptr2len(p);
n += MB_CPTR2LEN(p + n); n += utf_ptr2len(p + n);
c = utf_ptr2char(p + n); c = utf_ptr2char(p + n);
tl = MB_CPTR2LEN(p + n); tl = utf_ptr2len(p + n);
memmove(p + tl, p, n); memmove(p + tl, p, n);
utf_char2bytes(c, p); utf_char2bytes(c, p);
stack[depth].ts_fidxtry = sp->ts_fidx + n + tl; stack[depth].ts_fidxtry = sp->ts_fidx + n + tl;
@@ -5021,8 +5021,8 @@ static void find_keepcap_word(slang_T *slang, char_u *fword, char_u *kword)
} else { } else {
// round[depth] == 1: Try using the folded-case character. // round[depth] == 1: Try using the folded-case character.
// round[depth] == 2: Try using the upper-case character. // round[depth] == 2: Try using the upper-case character.
flen = MB_CPTR2LEN(fword + fwordidx[depth]); flen = utf_ptr2len(fword + fwordidx[depth]);
ulen = MB_CPTR2LEN(uword + uwordidx[depth]); ulen = utf_ptr2len(uword + uwordidx[depth]);
if (round[depth] == 1) { if (round[depth] == 1) {
p = fword + fwordidx[depth]; p = fword + fwordidx[depth];
l = flen; l = flen;
@@ -5512,9 +5512,9 @@ badword:
// lower to upper case. Helps for "tath" -> "Kath", which is // lower to upper case. Helps for "tath" -> "Kath", which is
// less common than "tath" -> "path". Don't do it when the // less common than "tath" -> "path". Don't do it when the
// letter is the same, that has already been counted. // letter is the same, that has already been counted.
gc = PTR2CHAR(p); gc = utf_ptr2char(p);
if (SPELL_ISUPPER(gc)) { if (SPELL_ISUPPER(gc)) {
bc = PTR2CHAR(su->su_badword); bc = utf_ptr2char(su->su_badword);
if (!SPELL_ISUPPER(bc) if (!SPELL_ISUPPER(bc)
&& SPELL_TOFOLD(bc) != SPELL_TOFOLD(gc)) { && SPELL_TOFOLD(bc) != SPELL_TOFOLD(gc)) {
goodscore += SCORE_ICASE / 2; goodscore += SCORE_ICASE / 2;
@@ -7185,7 +7185,7 @@ static linenr_T dump_prefixes(slang_T *slang, char_u *word, char_u *pat, Directi
// If the word starts with a lower-case letter make the word with an // If the word starts with a lower-case letter make the word with an
// upper-case letter in word_up[]. // upper-case letter in word_up[].
c = PTR2CHAR(word); c = utf_ptr2char(word);
if (SPELL_TOUPPER(c) != c) { if (SPELL_TOUPPER(c) != c) {
onecap_copy(word, word_up, true); onecap_copy(word, word_up, true);
has_word_up = true; has_word_up = true;

View File

@@ -2508,15 +2508,15 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
NUL) { NUL) {
int c, c_up; int c, c_up;
c = PTR2CHAR(aff_entry->ae_chop); c = utf_ptr2char(aff_entry->ae_chop);
c_up = SPELL_TOUPPER(c); c_up = SPELL_TOUPPER(c);
if (c_up != c if (c_up != c
&& (aff_entry->ae_cond == NULL && (aff_entry->ae_cond == NULL
|| PTR2CHAR(aff_entry->ae_cond) == c)) { || utf_ptr2char(aff_entry->ae_cond) == c)) {
p = aff_entry->ae_add p = aff_entry->ae_add
+ STRLEN(aff_entry->ae_add); + STRLEN(aff_entry->ae_add);
MB_PTR_BACK(aff_entry->ae_add, p); MB_PTR_BACK(aff_entry->ae_add, p);
if (PTR2CHAR(p) == c_up) { if (utf_ptr2char(p) == c_up) {
upper = true; upper = true;
aff_entry->ae_chop = NULL; aff_entry->ae_chop = NULL;
*p = NUL; *p = NUL;
@@ -3501,7 +3501,7 @@ static int store_aff_word(spellinfo_T *spin, char_u *word, char_u *afflist, afff
if (ae->ae_chop != NULL) { if (ae->ae_chop != NULL) {
// Remove chop string. // Remove chop string.
p = newword + STRLEN(newword); p = newword + STRLEN(newword);
i = (int)MB_CHARLEN(ae->ae_chop); i = (int)mb_charlen(ae->ae_chop);
for (; i > 0; i--) { for (; i > 0; i--) {
MB_PTR_BACK(newword, p); MB_PTR_BACK(newword, p);
} }