From cbdbc4f63d68a6b17b9eea5c67130e37d3d0f278 Mon Sep 17 00:00:00 2001 From: ZviRackover Date: Sun, 2 Sep 2018 00:58:30 +0300 Subject: Refactor: Remove occurences of mb_char2bytes --- src/nvim/regexp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/regexp.c') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index bbc161ee3e..7152a38815 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -2543,7 +2543,7 @@ static void regmbc(int c) if (regcode == JUST_CALC_SIZE) regsize += (*mb_char2len)(c); else - regcode += (*mb_char2bytes)(c, regcode); + regcode += utf_char2bytes(c, regcode); } /* @@ -6763,7 +6763,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int totlen = mb_ptr2len(src - 1); if (copy) - mb_char2bytes(cc, dst); + utf_char2bytes(cc, dst); dst += mb_char2len(cc) - 1; if (enc_utf8) { int clen = utf_ptr2len(src - 1); @@ -6866,7 +6866,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, s += l; len -= l; if (copy) - mb_char2bytes(cc, dst); + utf_char2bytes(cc, dst); dst += mb_char2len(cc) - 1; } else if (copy) *dst = cc; -- cgit From ac13e65ae0ce98516e816ba4fcf468d19e750c30 Mon Sep 17 00:00:00 2001 From: ZviRackover Date: Sun, 2 Sep 2018 01:36:18 +0300 Subject: Remove has_mbytes local to lines changed in parent commit --- src/nvim/regexp.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'src/nvim/regexp.c') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 7152a38815..085b70ad7e 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -2538,10 +2538,8 @@ 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); + regsize += utf_char2len(c); else regcode += utf_char2bytes(c, regcode); } @@ -6759,27 +6757,22 @@ 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) utf_char2bytes(cc, dst); - dst += mb_char2len(cc) - 1; - if (enc_utf8) { - 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; - } + 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; } src += totlen - 1; - } else if (copy) - *dst = cc; dst++; } else { if (REG_MULTI) { @@ -6861,13 +6854,13 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, if (enc_utf8) l = utf_ptr2len(s) - 1; else - l = mb_ptr2len(s) - 1; + l = utfc_ptr2len(s) - 1; s += l; len -= l; if (copy) utf_char2bytes(cc, dst); - dst += mb_char2len(cc) - 1; + dst += utf_char2len(cc) - 1; } else if (copy) *dst = cc; dst++; -- cgit From 329cfc3303cffd5c9aad7b2ad7f4323354d68b0d Mon Sep 17 00:00:00 2001 From: ZviRackover Date: Sun, 2 Sep 2018 02:14:47 +0300 Subject: lint: clean-up after parent commits --- src/nvim/regexp.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'src/nvim/regexp.c') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 085b70ad7e..4f51a8b4cf 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -2538,10 +2538,11 @@ static void regc(int b) */ static void regmbc(int c) { - if (regcode == JUST_CALC_SIZE) + if (regcode == JUST_CALC_SIZE) { regsize += utf_char2len(c); - else + } else { regcode += utf_char2bytes(c, regcode); + } } /* @@ -6757,22 +6758,23 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, cc = c; } - int totlen = utfc_ptr2len(src - 1); + int totlen = utfc_ptr2len(src - 1); - if (copy) - utf_char2bytes(cc, dst); - dst += utf_char2len(cc) - 1; - 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; + dst += totlen - clen; + } + src += totlen - 1; dst++; } else { if (REG_MULTI) { @@ -6849,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 = utfc_ptr2len(s) - 1; + // Copy composing characters separately, one + // at a time. + l = utf_ptr2len(s) - 1; s += l; len -= l; - if (copy) + if (copy) { utf_char2bytes(cc, dst); + } dst += utf_char2len(cc) - 1; - } else if (copy) + } else if (copy) { *dst = cc; + } dst++; } -- cgit