refactor(macroman): get rid of MB_COPY_CHAR macro

clean up docs for MB_PTR_ADV and MB_PTR_BACK
This commit is contained in:
Björn Linse
2021-11-14 13:39:14 +01:00
parent 54ff21a153
commit 1450a6f753
7 changed files with 15 additions and 21 deletions

View File

@@ -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;

View File

@@ -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)utf_ptr2len((const char_u *)p + off);
len += utf_ptr2len((const char_u *)p + off);
}
charlen--;
}

View File

@@ -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++ = '"';

View File

@@ -92,22 +92,19 @@
#define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))
// 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.
// Advance multi-byte pointer, skip over composing chars.
// MB_PTR_ADV(): advance a pointer to the next character, taking care of
// 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)
#define MB_COPY_CHAR(f, t) mb_copy_char((const char_u **)(&f), &t);
#define RESET_BINDING(wp) \
do { \
(wp)->w_p_scb = false; \

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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