diff options
Diffstat (limited to 'src/nvim/regexp.c')
-rw-r--r-- | src/nvim/regexp.c | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index bbc161ee3e..4f51a8b4cf 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -2538,12 +2538,11 @@ static void regc(int b) */ static void regmbc(int c) { - if (!has_mbyte && c > 0xff) - return; - if (regcode == JUST_CALC_SIZE) - regsize += (*mb_char2len)(c); - else - regcode += (*mb_char2bytes)(c, regcode); + if (regcode == JUST_CALC_SIZE) { + regsize += utf_char2len(c); + } else { + regcode += utf_char2bytes(c, regcode); + } } /* @@ -6759,27 +6758,23 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, cc = c; } - if (has_mbyte) { - int totlen = mb_ptr2len(src - 1); + int totlen = utfc_ptr2len(src - 1); - if (copy) - mb_char2bytes(cc, dst); - dst += mb_char2len(cc) - 1; - if (enc_utf8) { - int clen = utf_ptr2len(src - 1); + if (copy) { + utf_char2bytes(cc, dst); + } + dst += utf_char2len(cc) - 1; + int clen = utf_ptr2len(src - 1); - /* If the character length is shorter than "totlen", there - * are composing characters; copy them as-is. */ - if (clen < totlen) { - if (copy) - memmove(dst + 1, src - 1 + clen, - (size_t)(totlen - clen)); - dst += totlen - clen; - } + // If the character length is shorter than "totlen", there + // are composing characters; copy them as-is. + if (clen < totlen) { + if (copy) { + memmove(dst + 1, src - 1 + clen, (size_t)(totlen - clen)); } - src += totlen - 1; - } else if (copy) - *dst = cc; + dst += totlen - clen; + } + src += totlen - 1; dst++; } else { if (REG_MULTI) { @@ -6856,20 +6851,19 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, if (has_mbyte) { int l; - /* Copy composing characters separately, one - * at a time. */ - if (enc_utf8) - l = utf_ptr2len(s) - 1; - else - l = mb_ptr2len(s) - 1; + // Copy composing characters separately, one + // at a time. + l = utf_ptr2len(s) - 1; s += l; len -= l; - if (copy) - mb_char2bytes(cc, dst); - dst += mb_char2len(cc) - 1; - } else if (copy) + if (copy) { + utf_char2bytes(cc, dst); + } + dst += utf_char2len(cc) - 1; + } else if (copy) { *dst = cc; + } dst++; } |