mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
Merge pull request #16316 from bfredl/macroman
refactor(macros): delete multibyte macros which just are aliases
This commit is contained in:
commit
2f37ffb719
@ -778,7 +778,7 @@ int del_bytes(colnr_T count, bool fixpos_arg, bool use_delcombine)
|
||||
col = n;
|
||||
count = utf_ptr2len(oldp + n);
|
||||
n += count;
|
||||
} while (UTF_COMPOSINGLIKE(oldp + col, oldp + n));
|
||||
} while (utf_composinglike(oldp + col, oldp + n));
|
||||
fixpos = false;
|
||||
}
|
||||
}
|
||||
|
@ -744,7 +744,7 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din)
|
||||
char_u cbuf[MB_MAXBYTES + 1];
|
||||
|
||||
// xdiff doesn't support ignoring case, fold-case the text.
|
||||
int c = PTR2CHAR(s);
|
||||
int c = utf_ptr2char(s);
|
||||
c = utf_fold(c);
|
||||
const int orig_len = utfc_ptr2len(s);
|
||||
if (utf_char2bytes(c, cbuf) != orig_len) {
|
||||
|
@ -708,7 +708,7 @@ static int insert_execute(VimState *state, int key)
|
||||
|
||||
if (str != NULL) {
|
||||
for (p = str; *p != NUL; MB_PTR_ADV(p)) {
|
||||
ins_compl_addleader(PTR2CHAR(p));
|
||||
ins_compl_addleader(utf_ptr2char(p));
|
||||
}
|
||||
xfree(str);
|
||||
} else {
|
||||
@ -1283,7 +1283,7 @@ normalchar:
|
||||
if (*str != NUL && stop_arrow() != FAIL) {
|
||||
// Insert the new value of v:char literally.
|
||||
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) {
|
||||
ins_eol(s->c);
|
||||
} else {
|
||||
@ -3547,7 +3547,7 @@ static void ins_compl_addfrommatch(void)
|
||||
}
|
||||
}
|
||||
p += len;
|
||||
c = PTR2CHAR(p);
|
||||
c = utf_ptr2char(p);
|
||||
ins_compl_addleader(c);
|
||||
}
|
||||
|
||||
@ -5177,10 +5177,10 @@ static int ins_complete(int c, bool enable_pum)
|
||||
char_u *p = line + startcol;
|
||||
|
||||
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);
|
||||
}
|
||||
if (p == line && vim_isfilec(PTR2CHAR(p))) {
|
||||
if (p == line && vim_isfilec(utf_ptr2char(p))) {
|
||||
startcol = 0;
|
||||
} else {
|
||||
startcol = (int)(p - line) + 1;
|
||||
|
@ -4969,11 +4969,11 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
|
||||
FALLTHROUGH;
|
||||
|
||||
default:
|
||||
MB_COPY_CHAR(p, name);
|
||||
mb_copy_char((const char_u **)&p, &name);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
MB_COPY_CHAR(p, name);
|
||||
mb_copy_char((const char_u **)&p, &name);
|
||||
}
|
||||
}
|
||||
*name = NUL;
|
||||
@ -5033,7 +5033,7 @@ static int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate)
|
||||
}
|
||||
++p;
|
||||
}
|
||||
MB_COPY_CHAR(p, str);
|
||||
mb_copy_char((const char_u **)&p, &str);
|
||||
}
|
||||
*str = NUL;
|
||||
*arg = p + 1;
|
||||
|
@ -10628,7 +10628,7 @@ static void f_strgetchar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
break;
|
||||
}
|
||||
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 (nchar > 0) {
|
||||
while (nchar > 0 && (size_t)nbyte < slen) {
|
||||
nbyte += MB_CPTR2LEN((const char_u *)p + nbyte);
|
||||
nbyte += utf_ptr2len((const char_u *)p + nbyte);
|
||||
nchar--;
|
||||
}
|
||||
} else {
|
||||
@ -10761,7 +10761,7 @@ static void f_strcharpart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
if (off < 0) {
|
||||
len += 1;
|
||||
} else {
|
||||
len += (size_t)MB_CPTR2LEN((const char_u *)p + off);
|
||||
len += utf_ptr2len((const char_u *)p + off);
|
||||
}
|
||||
charlen--;
|
||||
}
|
||||
@ -11739,14 +11739,14 @@ static void f_trim(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
if (dir == 0 || dir == 1) {
|
||||
// Trim leading characters
|
||||
while (*head != NUL) {
|
||||
c1 = PTR2CHAR(head);
|
||||
c1 = utf_ptr2char(head);
|
||||
if (mask == NULL) {
|
||||
if (c1 > ' ' && c1 != 0xa0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
for (p = mask; *p != NUL; MB_PTR_ADV(p)) {
|
||||
if (c1 == PTR2CHAR(p)) {
|
||||
if (c1 == utf_ptr2char(p)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -11764,14 +11764,14 @@ static void f_trim(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
for (; tail > head; tail = prev) {
|
||||
prev = tail;
|
||||
MB_PTR_BACK(head, prev);
|
||||
c1 = PTR2CHAR(prev);
|
||||
c1 = utf_ptr2char(prev);
|
||||
if (mask == NULL) {
|
||||
if (c1 > ' ' && c1 != 0xa0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
for (p = mask; *p != NUL; MB_PTR_ADV(p)) {
|
||||
if (c1 == PTR2CHAR(p)) {
|
||||
if (c1 == utf_ptr2char(p)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2565,7 +2565,7 @@ static void append_command(char_u *cmd)
|
||||
STRCPY(d, "<a0>");
|
||||
d += 4;
|
||||
} else {
|
||||
MB_COPY_CHAR(s, d);
|
||||
mb_copy_char((const char_u **)&s, &d);
|
||||
}
|
||||
}
|
||||
*d = NUL;
|
||||
@ -5806,7 +5806,7 @@ static char_u *uc_split_args(char_u *arg, size_t *lenp)
|
||||
*q++ = ',';
|
||||
*q++ = '"';
|
||||
} else {
|
||||
MB_COPY_CHAR(p, q);
|
||||
mb_copy_char((const char_u **)&p, &q);
|
||||
}
|
||||
}
|
||||
*q++ = '"';
|
||||
|
@ -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;) {
|
||||
c1 = PTR2CHAR(s1 + i);
|
||||
c2 = PTR2CHAR(s2 + j);
|
||||
c1 = utf_ptr2char(s1 + i);
|
||||
c2 = utf_ptr2char(s2 + j);
|
||||
|
||||
if ((p_fic ? mb_tolower(c1) != mb_tolower(c2) : c1 != c2)
|
||||
&& (prev1 != '*' || prev2 != '*')) {
|
||||
|
@ -3996,8 +3996,8 @@ char_u *vim_strsave_escape_csi(char_u *p)
|
||||
} else {
|
||||
// Add character, possibly multi-byte to destination, escaping
|
||||
// CSI and K_SPECIAL. Be careful, it can be an illegal byte!
|
||||
d = add_char2buf(PTR2CHAR(s), d);
|
||||
s += MB_CPTR2LEN(s);
|
||||
d = add_char2buf(utf_ptr2char(s), d);
|
||||
s += utf_ptr2len(s);
|
||||
}
|
||||
}
|
||||
*d = NUL;
|
||||
|
@ -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);
|
||||
}
|
||||
if (modifiers != 0 && last_dash[l + 1] == '>') {
|
||||
key = PTR2CHAR(last_dash + off);
|
||||
key = utf_ptr2char(last_dash + off);
|
||||
} else {
|
||||
key = get_special_key_code(last_dash + off);
|
||||
if (!keep_x_key) {
|
||||
|
@ -92,29 +92,18 @@
|
||||
|
||||
#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
|
||||
// multi-byte characters if needed.
|
||||
// MB_PTR_BACK(): backup a pointer to the previous character, taking care of
|
||||
// multi-byte characters if needed.
|
||||
// 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.
|
||||
// multi-byte characters if needed. Skip over composing chars.
|
||||
#define MB_PTR_ADV(p) (p += utfc_ptr2len((char_u *)p))
|
||||
|
||||
// Advance multi-byte pointer, do not skip over composing chars.
|
||||
#define MB_CPTR_ADV(p) (p += utf_ptr2len(p))
|
||||
// Backup multi-byte pointer. Only use with "p" > "s" !
|
||||
|
||||
// MB_PTR_BACK(): backup a pointer to the previous character, taking care of
|
||||
// multi-byte characters if needed. Only use with "p" > "s" !
|
||||
#define MB_PTR_BACK(s, p) \
|
||||
(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_CHARLEN(p) mb_charlen(p)
|
||||
#define PTR2CHAR(p) utf_ptr2char(p)
|
||||
|
||||
#define RESET_BINDING(wp) \
|
||||
do { \
|
||||
|
@ -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.
|
||||
if ((len > 1 || *p < 0x80)
|
||||
&& p[len] >= 0x80
|
||||
&& UTF_COMPOSINGLIKE(p, p + len)) {
|
||||
&& utf_composinglike(p, p + len)) {
|
||||
cc = utf_ptr2char(p + len);
|
||||
for (;; ) {
|
||||
pcc[i++] = cc;
|
||||
@ -791,9 +791,6 @@ int utfc_ptr2char(const char_u *p, int *pcc)
|
||||
*/
|
||||
int utfc_ptr2char_len(const char_u *p, int *pcc, int maxlen)
|
||||
{
|
||||
#define IS_COMPOSING(s1, s2, s3) \
|
||||
(i == 0 ? UTF_COMPOSINGLIKE((s1), (s2)) : utf_iscomposing((s3)))
|
||||
|
||||
assert(maxlen > 0);
|
||||
|
||||
int i = 0;
|
||||
@ -809,7 +806,7 @@ int utfc_ptr2char_len(const char_u *p, int *pcc, int maxlen)
|
||||
int len_cc = utf_ptr2len_len(p + len, maxlen - len);
|
||||
safe = len_cc > 1 && len_cc <= maxlen - len;
|
||||
if (!safe || (pcc[i] = utf_ptr2char(p + len)) < 0x80
|
||||
|| !IS_COMPOSING(p, p + len, pcc[i])) {
|
||||
|| !(i == 0 ? utf_composinglike(p, p+len) : utf_iscomposing(pcc[i]))) {
|
||||
break;
|
||||
}
|
||||
len += len_cc;
|
||||
@ -914,7 +911,7 @@ int utfc_ptr2len(const char_u *const p)
|
||||
// skip all of them (otherwise the cursor would get stuck).
|
||||
int prevlen = 0;
|
||||
for (;;) {
|
||||
if (p[len] < 0x80 || !UTF_COMPOSINGLIKE(p + prevlen, p + len)) {
|
||||
if (p[len] < 0x80 || !utf_composinglike(p + prevlen, p + len)) {
|
||||
return len;
|
||||
}
|
||||
|
||||
@ -964,14 +961,14 @@ int utfc_ptr2len_len(const char_u *p, int size)
|
||||
|
||||
/*
|
||||
* 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);
|
||||
if (len_next_char > size - len) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!UTF_COMPOSINGLIKE(p + prevlen, p + len)) {
|
||||
if (!utf_composinglike(p + prevlen, p + len)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -359,8 +359,8 @@ int path_fnamencmp(const char *const fname1, const char *const fname2, size_t le
|
||||
const char *p1 = fname1;
|
||||
const char *p2 = fname2;
|
||||
while (len > 0) {
|
||||
c1 = PTR2CHAR((const char_u *)p1);
|
||||
c2 = PTR2CHAR((const char_u *)p2);
|
||||
c1 = utf_ptr2char((const char_u *)p1);
|
||||
c2 = utf_ptr2char((const char_u *)p2);
|
||||
if ((c1 == NUL || c2 == NUL
|
||||
|| (!((c1 == '/' || c1 == '\\') && (c2 == '\\' || 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
|
||||
#ifndef WIN32
|
||||
|| (!p_fic && (flags & EW_ICASE)
|
||||
&& isalpha(PTR2CHAR(path_end)))
|
||||
&& isalpha(utf_ptr2char(path_end)))
|
||||
#endif
|
||||
)) {
|
||||
e = p;
|
||||
@ -1937,8 +1937,8 @@ int pathcmp(const char *p, const char *q, int maxlen)
|
||||
const char *s = NULL;
|
||||
|
||||
for (i = 0, j = 0; maxlen < 0 || (i < maxlen && j < maxlen);) {
|
||||
c1 = PTR2CHAR((char_u *)p + i);
|
||||
c2 = PTR2CHAR((char_u *)q + j);
|
||||
c1 = utf_ptr2char((char_u *)p + i);
|
||||
c2 = utf_ptr2char((char_u *)q + j);
|
||||
|
||||
// End of "p": check if "q" also ends or just has a slash.
|
||||
if (c1 == NUL) {
|
||||
@ -1980,8 +1980,8 @@ int pathcmp(const char *p, const char *q, int maxlen)
|
||||
return 0;
|
||||
}
|
||||
|
||||
c1 = PTR2CHAR((char_u *)s + i);
|
||||
c2 = PTR2CHAR((char_u *)s + i + utfc_ptr2len((char_u *)s + i));
|
||||
c1 = utf_ptr2char((char_u *)s + i);
|
||||
c2 = utf_ptr2char((char_u *)s + i + utfc_ptr2len((char_u *)s + i));
|
||||
// ignore a trailing slash, but not "//" or ":/"
|
||||
if (c2 == NUL
|
||||
&& i > 0
|
||||
|
@ -424,7 +424,7 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he
|
||||
col %= numberextra;
|
||||
}
|
||||
if (*sbr != NUL) {
|
||||
sbrlen = (colnr_T)MB_CHARLEN(sbr);
|
||||
sbrlen = (colnr_T)mb_charlen(sbr);
|
||||
if (col >= sbrlen) {
|
||||
col -= sbrlen;
|
||||
}
|
||||
|
@ -2509,8 +2509,9 @@ do_multibyte:
|
||||
/* Need to get composing character too. */
|
||||
for (;; ) {
|
||||
l = utf_ptr2len(regparse);
|
||||
if (!UTF_COMPOSINGLIKE(regparse, regparse + l))
|
||||
if (!utf_composinglike(regparse, regparse + l)) {
|
||||
break;
|
||||
}
|
||||
regmbc(utf_ptr2char(regparse));
|
||||
skipchr();
|
||||
}
|
||||
@ -4127,7 +4128,7 @@ static bool regmatch(
|
||||
break;
|
||||
|
||||
case PRINT:
|
||||
if (!vim_isprintc(PTR2CHAR(rex.input))) {
|
||||
if (!vim_isprintc(utf_ptr2char(rex.input))) {
|
||||
status = RA_NOMATCH;
|
||||
} else {
|
||||
ADVANCE_REGINPUT();
|
||||
@ -4135,7 +4136,7 @@ static bool regmatch(
|
||||
break;
|
||||
|
||||
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;
|
||||
} else {
|
||||
ADVANCE_REGINPUT();
|
||||
@ -4294,7 +4295,7 @@ static bool regmatch(
|
||||
// Check for following composing character, unless %C
|
||||
// follows (skips over all composing chars).
|
||||
if (status != RA_NOMATCH
|
||||
&& UTF_COMPOSINGLIKE(rex.input, rex.input + len)
|
||||
&& utf_composinglike(rex.input, rex.input + len)
|
||||
&& !rex.reg_icombine
|
||||
&& OP(next) != RE_COMPOSING) {
|
||||
// raaron: This code makes a composing character get
|
||||
@ -5269,7 +5270,7 @@ regrepeat (
|
||||
case SIDENT:
|
||||
case SIDENT + ADD_NL:
|
||||
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);
|
||||
} else if (*scan == NUL) {
|
||||
if (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline
|
||||
@ -5326,7 +5327,7 @@ regrepeat (
|
||||
case SFNAME:
|
||||
case SFNAME + ADD_NL:
|
||||
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);
|
||||
} else if (*scan == NUL) {
|
||||
if (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline
|
||||
@ -5364,7 +5365,7 @@ regrepeat (
|
||||
if (got_int) {
|
||||
break;
|
||||
}
|
||||
} else if (vim_isprintc(PTR2CHAR(scan)) == 1
|
||||
} else if (vim_isprintc(utf_ptr2char(scan)) == 1
|
||||
&& (testval || !ascii_isdigit(*scan))) {
|
||||
MB_PTR_ADV(scan);
|
||||
} else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) {
|
||||
|
@ -1310,9 +1310,10 @@ static int nfa_regatom(void)
|
||||
return FAIL;
|
||||
}
|
||||
for (lp = reg_prev_sub; *lp != NUL; MB_CPTR_ADV(lp)) {
|
||||
EMIT(PTR2CHAR(lp));
|
||||
if (lp != reg_prev_sub)
|
||||
EMIT(utf_ptr2char(lp));
|
||||
if (lp != reg_prev_sub) {
|
||||
EMIT(NFA_CONCAT);
|
||||
}
|
||||
}
|
||||
EMIT(NFA_NOPEN);
|
||||
break;
|
||||
@ -1722,9 +1723,10 @@ collection:
|
||||
}
|
||||
}
|
||||
|
||||
/* Normal printable char */
|
||||
if (startc == -1)
|
||||
startc = PTR2CHAR(regparse);
|
||||
// Normal printable char
|
||||
if (startc == -1) {
|
||||
startc = utf_ptr2char(regparse);
|
||||
}
|
||||
|
||||
/* Previous char was '-', so this char is end of 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
|
||||
while (*s1) {
|
||||
int c1_len = PTR2LEN(s1);
|
||||
int c1 = PTR2CHAR(s1);
|
||||
int c1 = utf_ptr2char(s1);
|
||||
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)))
|
||||
|| c1_len != c2_len) {
|
||||
@ -5010,7 +5012,7 @@ static long find_match_text(colnr_T startcol, int regstart, char_u *match_text)
|
||||
}
|
||||
if (match
|
||||
// check that no composing char follows
|
||||
&& !utf_iscomposing(PTR2CHAR(s2))) {
|
||||
&& !utf_iscomposing(utf_ptr2char(s2))) {
|
||||
cleanup_subexpr();
|
||||
if (REG_MULTI) {
|
||||
rex.reg_startpos[0].lnum = rex.lnum;
|
||||
@ -5808,12 +5810,12 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start,
|
||||
break;
|
||||
|
||||
case NFA_PRINT: // \p
|
||||
result = vim_isprintc(PTR2CHAR(rex.input));
|
||||
result = vim_isprintc(utf_ptr2char(rex.input));
|
||||
ADD_STATE_IF_MATCH(t->state);
|
||||
break;
|
||||
|
||||
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);
|
||||
break;
|
||||
|
||||
@ -6306,7 +6308,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start,
|
||||
} else {
|
||||
// Checking if the required start character matches is
|
||||
// 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
|
||||
&& (!rex.reg_ic
|
||||
|| utf_fold(c) != utf_fold(prog->regstart))) {
|
||||
|
@ -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) {
|
||||
need_showbreak = false;
|
||||
}
|
||||
vcol_sbr = vcol + MB_CHARLEN(sbr);
|
||||
vcol_sbr = vcol + mb_charlen(sbr);
|
||||
// Correct end of highlighted area for 'showbreak',
|
||||
// required when 'linebreak' is also set.
|
||||
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
|
||||
// space for it again.
|
||||
if (vcol == vcol_sbr) {
|
||||
n_extra -= MB_CHARLEN(get_showbreak_value(wp));
|
||||
n_extra -= mb_charlen(get_showbreak_value(wp));
|
||||
if (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
|
||||
// showbreak value was drawn.
|
||||
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_len = tabstop_padding(vcol_adjusted,
|
||||
|
@ -1871,7 +1871,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|
||||
--pos.col;
|
||||
}
|
||||
for (;; ) {
|
||||
initc = PTR2CHAR(linep + pos.col);
|
||||
initc = utf_ptr2char(linep + pos.col);
|
||||
if (initc == NUL) {
|
||||
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
|
||||
* 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) {
|
||||
case NUL:
|
||||
// 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.
|
||||
*/
|
||||
// 'matchpairs' is "x:y,x:y"
|
||||
for (p = curbuf->b_p_mps; *p != NUL; ++p) {
|
||||
if (PTR2CHAR(p) == c && (curwin->w_p_rl ^ p_ri)) {
|
||||
for (p = curbuf->b_p_mps; *p != NUL; p++) {
|
||||
if (utf_ptr2char(p) == c && (curwin->w_p_rl ^ p_ri)) {
|
||||
break;
|
||||
}
|
||||
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;
|
||||
}
|
||||
p += utfc_ptr2len(p);
|
||||
|
@ -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
|
||||
|
||||
if (use_camel_case) {
|
||||
c = PTR2CHAR(mi.mi_fend);
|
||||
c = utf_ptr2char(mi.mi_fend);
|
||||
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);
|
||||
if (use_camel_case) {
|
||||
const bool prev_upper = this_upper;
|
||||
c = PTR2CHAR(mi.mi_fend);
|
||||
c = utf_ptr2char(mi.mi_fend);
|
||||
this_upper = SPELL_ISUPPER(c);
|
||||
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) {
|
||||
// Check word starting with capital letter.
|
||||
c = PTR2CHAR(ptr);
|
||||
c = utf_ptr2char(ptr);
|
||||
if (!SPELL_ISUPPER(c)) {
|
||||
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.
|
||||
for (; end == NULL ? *p != NUL : p < end; MB_PTR_ADV(p)) {
|
||||
if (spell_iswordp_nmw(p, curwin)) {
|
||||
c = PTR2CHAR(p);
|
||||
c = utf_ptr2char(p);
|
||||
if (!SPELL_ISUPPER(c)) {
|
||||
// UUl -> KEEPCAP
|
||||
if (past_second && allcap) {
|
||||
@ -2464,7 +2464,7 @@ static int badword_captype(char_u *word, char_u *end)
|
||||
l = u = 0;
|
||||
first = false;
|
||||
for (p = word; p < end; MB_PTR_ADV(p)) {
|
||||
c = PTR2CHAR(p);
|
||||
c = utf_ptr2char(p);
|
||||
if (SPELL_ISUPPER(c)) {
|
||||
++u;
|
||||
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
|
||||
// word to be bad then it might need to be capitalised. Add a suggestion
|
||||
// for that.
|
||||
c = PTR2CHAR(su->su_badptr);
|
||||
c = utf_ptr2char(su->su_badptr);
|
||||
if (!SPELL_ISUPPER(c) && attr == HLF_COUNT) {
|
||||
make_case_word(su->su_badword, buf, WF_ONECAP);
|
||||
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;
|
||||
}
|
||||
|
||||
n = MB_CPTR2LEN(p);
|
||||
n = utf_ptr2len(p);
|
||||
c = utf_ptr2char(p);
|
||||
if (p[n] == 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
|
||||
// "fword" here, it's changed back afterwards at STATE_UNSWAP3.
|
||||
p = fword + sp->ts_fidx;
|
||||
n = MB_CPTR2LEN(p);
|
||||
n = utf_ptr2len(p);
|
||||
c = utf_ptr2char(p);
|
||||
fl = MB_CPTR2LEN(p + n);
|
||||
fl = utf_ptr2len(p + n);
|
||||
c2 = utf_ptr2char(p + n);
|
||||
if (!soundfold && !spell_iswordp(p + n + fl, curwin)) {
|
||||
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;
|
||||
++depth;
|
||||
p = fword + sp->ts_fidx;
|
||||
n = MB_CPTR2LEN(p);
|
||||
n = utf_ptr2len(p);
|
||||
c = utf_ptr2char(p);
|
||||
fl = MB_CPTR2LEN(p + n);
|
||||
fl += MB_CPTR2LEN(p + n + fl);
|
||||
fl = utf_ptr2len(p + n);
|
||||
fl += utf_ptr2len(p + n + fl);
|
||||
memmove(p, p + n, fl);
|
||||
utf_char2bytes(c, p + 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;
|
||||
++depth;
|
||||
p = fword + sp->ts_fidx;
|
||||
n = MB_CPTR2LEN(p);
|
||||
n += MB_CPTR2LEN(p + n);
|
||||
n = utf_ptr2len(p);
|
||||
n += utf_ptr2len(p + n);
|
||||
c = utf_ptr2char(p + n);
|
||||
tl = MB_CPTR2LEN(p + n);
|
||||
tl = utf_ptr2len(p + n);
|
||||
memmove(p + tl, p, n);
|
||||
utf_char2bytes(c, p);
|
||||
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 {
|
||||
// round[depth] == 1: Try using the folded-case character.
|
||||
// round[depth] == 2: Try using the upper-case character.
|
||||
flen = MB_CPTR2LEN(fword + fwordidx[depth]);
|
||||
ulen = MB_CPTR2LEN(uword + uwordidx[depth]);
|
||||
flen = utf_ptr2len(fword + fwordidx[depth]);
|
||||
ulen = utf_ptr2len(uword + uwordidx[depth]);
|
||||
if (round[depth] == 1) {
|
||||
p = fword + fwordidx[depth];
|
||||
l = flen;
|
||||
@ -5512,9 +5512,9 @@ badword:
|
||||
// lower to upper case. Helps for "tath" -> "Kath", which is
|
||||
// less common than "tath" -> "path". Don't do it when the
|
||||
// letter is the same, that has already been counted.
|
||||
gc = PTR2CHAR(p);
|
||||
gc = utf_ptr2char(p);
|
||||
if (SPELL_ISUPPER(gc)) {
|
||||
bc = PTR2CHAR(su->su_badword);
|
||||
bc = utf_ptr2char(su->su_badword);
|
||||
if (!SPELL_ISUPPER(bc)
|
||||
&& SPELL_TOFOLD(bc) != SPELL_TOFOLD(gc)) {
|
||||
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
|
||||
// upper-case letter in word_up[].
|
||||
c = PTR2CHAR(word);
|
||||
c = utf_ptr2char(word);
|
||||
if (SPELL_TOUPPER(c) != c) {
|
||||
onecap_copy(word, word_up, true);
|
||||
has_word_up = true;
|
||||
|
@ -2508,15 +2508,15 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
||||
NUL) {
|
||||
int c, c_up;
|
||||
|
||||
c = PTR2CHAR(aff_entry->ae_chop);
|
||||
c = utf_ptr2char(aff_entry->ae_chop);
|
||||
c_up = SPELL_TOUPPER(c);
|
||||
if (c_up != c
|
||||
&& (aff_entry->ae_cond == NULL
|
||||
|| PTR2CHAR(aff_entry->ae_cond) == c)) {
|
||||
|| utf_ptr2char(aff_entry->ae_cond) == c)) {
|
||||
p = aff_entry->ae_add
|
||||
+ STRLEN(aff_entry->ae_add);
|
||||
MB_PTR_BACK(aff_entry->ae_add, p);
|
||||
if (PTR2CHAR(p) == c_up) {
|
||||
if (utf_ptr2char(p) == c_up) {
|
||||
upper = true;
|
||||
aff_entry->ae_chop = NULL;
|
||||
*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) {
|
||||
// Remove chop string.
|
||||
p = newword + STRLEN(newword);
|
||||
i = (int)MB_CHARLEN(ae->ae_chop);
|
||||
i = mb_charlen(ae->ae_chop);
|
||||
for (; i > 0; i--) {
|
||||
MB_PTR_BACK(newword, p);
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ char_u *vim_strsave_shellescape(const char_u *string, bool do_special, bool do_n
|
||||
continue;
|
||||
}
|
||||
|
||||
MB_COPY_CHAR(p, d);
|
||||
mb_copy_char(&p, &d);
|
||||
}
|
||||
|
||||
// add terminating quote and finish with a NUL
|
||||
|
Loading…
Reference in New Issue
Block a user