diff options
author | ZviRackover <zvirack@gmail.com> | 2018-06-30 16:21:37 +0300 |
---|---|---|
committer | ZviRackover <zvirack@gmail.com> | 2018-08-06 20:48:07 +0300 |
commit | 071aab51488e03a0e09a0a60aec6c0abc0277279 (patch) | |
tree | 6323eb69ad229bb7c9c43ee26c4fa566ef6fd6f8 /src/nvim/regexp.c | |
parent | cd3b2e4b6bea9501b3bd7ddf7b4d7ca31f1e6dd5 (diff) | |
download | rneovim-071aab51488e03a0e09a0a60aec6c0abc0277279.tar.gz rneovim-071aab51488e03a0e09a0a60aec6c0abc0277279.tar.bz2 rneovim-071aab51488e03a0e09a0a60aec6c0abc0277279.zip |
Remove some occrrences of enc_utf8 and has_mbyte
Removing uses and related dead code in the locallity of changes of
the two parent commits.
Diffstat (limited to 'src/nvim/regexp.c')
-rw-r--r-- | src/nvim/regexp.c | 115 |
1 files changed, 35 insertions, 80 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 1b711bd881..a4fb16280c 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -772,14 +772,9 @@ static int get_equi_class(char_u **pp) char_u *p = *pp; if (p[1] == '=') { - if (has_mbyte) - l = (*mb_ptr2len)(p + 2); + l = (*mb_ptr2len)(p + 2); if (p[l + 2] == '=' && p[l + 3] == ']') { - if (has_mbyte) { - c = utf_ptr2char(p + 2); - } else { - c = p[2]; - } + c = utf_ptr2char(p + 2); *pp += l + 4; return c; } @@ -1108,14 +1103,9 @@ static int get_coll_element(char_u **pp) char_u *p = *pp; if (p[0] != NUL && p[1] == '.') { - if (has_mbyte) - l = (*mb_ptr2len)(p + 2); + l = (*mb_ptr2len)(p + 2); if (p[l + 2] == '.' && p[l + 3] == ']') { - if (has_mbyte) { - c = utf_ptr2char(p + 2); - } else { - c = p[2]; - } + c = utf_ptr2char(p + 2); *pp += l + 4; return c; } @@ -1301,11 +1291,7 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags) } if (OP(scan) == EXACTLY) { - if (has_mbyte) { - r->regstart = utf_ptr2char(OPERAND(scan)); - } else { - r->regstart = *OPERAND(scan); - } + r->regstart = utf_ptr2char(OPERAND(scan)); } else if (OP(scan) == BOW || OP(scan) == EOW || OP(scan) == NOTHING @@ -1313,11 +1299,7 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags) || OP(scan) == MCLOSE + 0 || OP(scan) == NCLOSE) { char_u *regnext_scan = regnext(scan); if (OP(regnext_scan) == EXACTLY) { - if (has_mbyte) { - r->regstart = utf_ptr2char(OPERAND(regnext_scan)); - } else { - r->regstart = *OPERAND(regnext_scan); - } + r->regstart = utf_ptr2char(OPERAND(regnext_scan)); } } @@ -2416,20 +2398,16 @@ collection: break; } } else { - if (has_mbyte) { - int len; - - /* produce a multibyte character, including any - * following composing characters */ - startc = utf_ptr2char(regparse); - len = (*mb_ptr2len)(regparse); - if (enc_utf8 && utf_char2len(startc) != len) - startc = -1; /* composing chars */ - while (--len >= 0) - regc(*regparse++); - } else { - startc = *regparse++; - regc(startc); + // produce a multibyte character, including any + // following composing characters. + startc = utf_ptr2char(regparse); + int len = utfc_ptr2len(regparse); + if (utf_char2len(startc) != len) { + // composing chars + startc = -1; + } + while (--len >= 0) { + regc(*regparse++); } } } @@ -2910,19 +2888,13 @@ static int peekchr(void) * Next character can never be (made) magic? * Then backslashing it won't do anything. */ - if (has_mbyte) { - curchr = utf_ptr2char(regparse + 1); - } else { - curchr = c; - } + curchr = utf_ptr2char(regparse + 1); } break; } default: - if (has_mbyte) { - curchr = utf_ptr2char(regparse); - } + curchr = utf_ptr2char(regparse); } return curchr; @@ -3474,11 +3446,7 @@ static long bt_regexec_both(char_u *line, if (prog->regmust != NULL) { int c; - if (has_mbyte) { - c = utf_ptr2char(prog->regmust); - } else { - c = *prog->regmust; - } + c = utf_ptr2char(prog->regmust); s = line + col; // This is used very often, esp. for ":global". Use two versions of @@ -3509,17 +3477,11 @@ static long bt_regexec_both(char_u *line, /* Simplest case: Anchored match need be tried only once. */ if (prog->reganch) { - int c; - - if (has_mbyte) { - c = utf_ptr2char(regline + col); - } else { - c = regline[col]; - } + int c = utf_ptr2char(regline + col); if (prog->regstart == NUL || prog->regstart == c || (rex.reg_ic - && (((enc_utf8 && utf_fold(prog->regstart) == utf_fold(c))) + && (utf_fold(prog->regstart) == utf_fold(c) || (c < 255 && prog->regstart < 255 && mb_tolower(prog->regstart) == mb_tolower(c))))) { retval = regtry(prog, col); @@ -3866,13 +3828,10 @@ regmatch ( } else if (rex.reg_line_lbr && WITH_NL(op) && *reginput == '\n') { ADVANCE_REGINPUT(); } else { - if (WITH_NL(op)) + if (WITH_NL(op)) { op -= ADD_NL; - if (has_mbyte) { - c = utf_ptr2char(reginput); - } else { - c = *reginput; } + c = utf_ptr2char(reginput); switch (op) { case BOL: if (reginput != regline) @@ -6791,20 +6750,20 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, } c = *src++; } - } else if (has_mbyte) { + } else { c = utf_ptr2char(src - 1); } - - /* Write to buffer, if copy is set. */ - if (func_one != (fptr_T)NULL) - /* Turbo C complains without the typecast */ + // Write to buffer, if copy is set. + if (func_one != NULL) { func_one = (fptr_T)(func_one(&cc, c)); - else if (func_all != (fptr_T)NULL) - /* Turbo C complains without the typecast */ - func_all = (fptr_T)(func_all(&cc, c)); - else /* just copy */ - cc = c; - + } else { + if (func_all != NULL) { + func_all = (fptr_T)(func_all(&cc, c)); + } else { + // just copy + cc = c; + } + } if (has_mbyte) { int totlen = mb_ptr2len(src - 1); @@ -6888,11 +6847,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, } dst += 2; } else { - if (has_mbyte) { - c = utf_ptr2char(s); - } else { - c = *s; - } + c = utf_ptr2char(s); if (func_one != (fptr_T)NULL) /* Turbo C complains without the typecast */ |