mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 21:48:35 +00:00
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:
@@ -4969,11 +4969,11 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
|
|||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
MB_COPY_CHAR(p, name);
|
mb_copy_char((const char_u **)&p, &name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MB_COPY_CHAR(p, name);
|
mb_copy_char((const char_u **)&p, &name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*name = NUL;
|
*name = NUL;
|
||||||
@@ -5033,7 +5033,7 @@ static int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate)
|
|||||||
}
|
}
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
MB_COPY_CHAR(p, str);
|
mb_copy_char((const char_u **)&p, &str);
|
||||||
}
|
}
|
||||||
*str = NUL;
|
*str = NUL;
|
||||||
*arg = p + 1;
|
*arg = p + 1;
|
||||||
|
@@ -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)utf_ptr2len((const char_u *)p + off);
|
len += utf_ptr2len((const char_u *)p + off);
|
||||||
}
|
}
|
||||||
charlen--;
|
charlen--;
|
||||||
}
|
}
|
||||||
|
@@ -2565,7 +2565,7 @@ static void append_command(char_u *cmd)
|
|||||||
STRCPY(d, "<a0>");
|
STRCPY(d, "<a0>");
|
||||||
d += 4;
|
d += 4;
|
||||||
} else {
|
} else {
|
||||||
MB_COPY_CHAR(s, d);
|
mb_copy_char((const char_u **)&s, &d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*d = NUL;
|
*d = NUL;
|
||||||
@@ -5806,7 +5806,7 @@ static char_u *uc_split_args(char_u *arg, size_t *lenp)
|
|||||||
*q++ = ',';
|
*q++ = ',';
|
||||||
*q++ = '"';
|
*q++ = '"';
|
||||||
} else {
|
} else {
|
||||||
MB_COPY_CHAR(p, q);
|
mb_copy_char((const char_u **)&p, &q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*q++ = '"';
|
*q++ = '"';
|
||||||
|
@@ -92,22 +92,19 @@
|
|||||||
|
|
||||||
#define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))
|
#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))
|
#define MB_PTR_ADV(p) (p += utfc_ptr2len((char_u *)p))
|
||||||
|
|
||||||
// Advance multi-byte pointer, do not skip over composing chars.
|
// Advance multi-byte pointer, do not skip over composing chars.
|
||||||
#define MB_CPTR_ADV(p) (p += utf_ptr2len(p))
|
#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) \
|
#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)
|
||||||
|
|
||||||
#define MB_COPY_CHAR(f, t) mb_copy_char((const char_u **)(&f), &t);
|
|
||||||
|
|
||||||
#define RESET_BINDING(wp) \
|
#define RESET_BINDING(wp) \
|
||||||
do { \
|
do { \
|
||||||
(wp)->w_p_scb = false; \
|
(wp)->w_p_scb = false; \
|
||||||
|
@@ -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)
|
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);
|
assert(maxlen > 0);
|
||||||
|
|
||||||
int i = 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);
|
int len_cc = utf_ptr2len_len(p + len, maxlen - len);
|
||||||
safe = len_cc > 1 && len_cc <= maxlen - len;
|
safe = len_cc > 1 && len_cc <= maxlen - len;
|
||||||
if (!safe || (pcc[i] = utf_ptr2char(p + len)) < 0x80
|
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;
|
break;
|
||||||
}
|
}
|
||||||
len += len_cc;
|
len += len_cc;
|
||||||
|
@@ -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 = mb_charlen(ae->ae_chop);
|
||||||
for (; i > 0; i--) {
|
for (; i > 0; i--) {
|
||||||
MB_PTR_BACK(newword, p);
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MB_COPY_CHAR(p, d);
|
mb_copy_char(&p, &d);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add terminating quote and finish with a NUL
|
// add terminating quote and finish with a NUL
|
||||||
|
Reference in New Issue
Block a user