diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2022-07-28 00:08:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-28 06:08:20 +0800 |
commit | 48608a1f46abfba130faa96d59bdf4b8283fe0ac (patch) | |
tree | f1e5b0f74a1ef14418de9c4ba9c790a80731ea69 /src/nvim/regexp_bt.c | |
parent | e0c433833f638fc5e21b00d298661a5fa7c4b5be (diff) | |
download | rneovim-48608a1f46abfba130faa96d59bdf4b8283fe0ac.tar.gz rneovim-48608a1f46abfba130faa96d59bdf4b8283fe0ac.tar.bz2 rneovim-48608a1f46abfba130faa96d59bdf4b8283fe0ac.zip |
refactor: enable -Wconversion warning for regexp files (#19521)
Work on https://github.com/neovim/neovim/issues/567
Diffstat (limited to 'src/nvim/regexp_bt.c')
-rw-r--r-- | src/nvim/regexp_bt.c | 76 |
1 files changed, 37 insertions, 39 deletions
diff --git a/src/nvim/regexp_bt.c b/src/nvim/regexp_bt.c index f82006bede..5bb17e0939 100644 --- a/src/nvim/regexp_bt.c +++ b/src/nvim/regexp_bt.c @@ -492,7 +492,7 @@ static void regc(int b) if (regcode == JUST_CALC_SIZE) { regsize++; } else { - *regcode++ = b; + *regcode++ = (char_u)b; } } @@ -1493,7 +1493,7 @@ static char_u *regnode(int op) if (ret == JUST_CALC_SIZE) { regsize += 3; } else { - *regcode++ = op; + *regcode++ = (char_u)op; *regcode++ = NUL; // Null "next" pointer. *regcode++ = NUL; } @@ -1610,7 +1610,7 @@ static void reginsert(int op, char_u *opnd) } place = opnd; // Op node, where operand used to be. - *place++ = op; + *place++ = (char_u)op; *place++ = NUL; *place = NUL; } @@ -1637,7 +1637,7 @@ static void reginsert_nr(int op, long val, char_u *opnd) } place = opnd; // Op node, where operand used to be. - *place++ = op; + *place++ = (char_u)op; *place++ = NUL; *place++ = NUL; assert(val >= 0 && (uintmax_t)val <= UINT32_MAX); @@ -1668,7 +1668,7 @@ static void reginsert_limits(int op, long minval, long maxval, char_u *opnd) } place = opnd; // Op node, where operand used to be. - *place++ = op; + *place++ = (char_u)op; *place++ = NUL; *place++ = NUL; assert(minval >= 0 && (uintmax_t)minval <= UINT32_MAX); @@ -2071,7 +2071,7 @@ static char_u *regatom(int *flagp) EMSG2_RET_NULL(_("E678: Invalid character after %s%%[dxouU]"), reg_magic == MAGIC_ALL); } - if (use_multibytecode(i)) { + if (use_multibytecode((int)i)) { ret = regnode(MULTIBYTECODE); } else { ret = regnode(EXACTLY); @@ -2079,7 +2079,7 @@ static char_u *regatom(int *flagp) if (i == 0) { regc(0x0a); } else { - regmbc(i); + regmbc((int)i); } regc(NUL); *flagp |= HASWIDTH; @@ -2111,8 +2111,8 @@ static char_u *regatom(int *flagp) if (ret == JUST_CALC_SIZE) { regsize += 2; } else { - *regcode++ = c; - *regcode++ = cmp; + *regcode++ = (char_u)c; + *regcode++ = (char_u)cmp; } break; } else if (c == 'l' || c == 'c' || c == 'v') { @@ -2123,7 +2123,7 @@ static char_u *regatom(int *flagp) } if (c == 'l') { if (cur) { - n = curwin->w_cursor.lnum; + n = (uint32_t)curwin->w_cursor.lnum; } ret = regnode(RE_LNUM); if (save_prev_at_start) { @@ -2131,7 +2131,7 @@ static char_u *regatom(int *flagp) } } else if (c == 'c') { if (cur) { - n = curwin->w_cursor.col; + n = (uint32_t)curwin->w_cursor.col; n++; } ret = regnode(RE_COL); @@ -2139,7 +2139,7 @@ static char_u *regatom(int *flagp) if (cur) { colnr_T vcol = 0; getvvcol(curwin, &curwin->w_cursor, NULL, NULL, &vcol); - n = ++vcol; + n = (uint32_t)(++vcol); } ret = regnode(RE_VCOL); } @@ -2149,7 +2149,7 @@ static char_u *regatom(int *flagp) // put the number and the optional // comparator after the opcode regcode = re_put_uint32(regcode, n); - *regcode++ = cmp; + *regcode++ = (char_u)cmp; } break; } @@ -2910,7 +2910,7 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags) } // Allocate space. - bt_regprog_T *r = xmalloc(sizeof(bt_regprog_T) + regsize); + bt_regprog_T *r = xmalloc(sizeof(bt_regprog_T) + (size_t)regsize); r->re_in_use = false; // Second pass: emit code. @@ -2938,7 +2938,7 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags) r->regflags |= RF_LOOKBH; } // Remember whether this pattern has any \z specials in it. - r->reghasz = re_has_z; + r->reghasz = (char_u)re_has_z; scan = r->program + 1; // First BRANCH. if (OP(regnext(scan)) == END) { // Only one top-level choice. scan = OPERAND(scan); @@ -3027,7 +3027,7 @@ static int coll_get_char(void) regparse--; nr = '\\'; } - return nr; + return (int)nr; } /* @@ -3505,7 +3505,7 @@ static regitem_T *regstack_push(regstate_T state, char_u *scan) rp->rs_state = state; rp->rs_scan = scan; - regstack.ga_len += sizeof(regitem_T); + regstack.ga_len += (int)sizeof(regitem_T); return rp; } @@ -3519,7 +3519,7 @@ static void regstack_pop(char_u **scan) rp = (regitem_T *)((char *)regstack.ga_data + regstack.ga_len) - 1; *scan = rp->rs_scan; - regstack.ga_len -= sizeof(regitem_T); + regstack.ga_len -= (int)sizeof(regitem_T); } // Save the current subexpr to "bp", so that they can be restored @@ -3704,7 +3704,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) int mark = OPERAND(scan)[0]; int cmp = OPERAND(scan)[1]; pos_T *pos; - size_t col = REG_MULTI ? rex.input - rex.line : 0; + size_t col = REG_MULTI ? (size_t)(rex.input - rex.line) : 0; fmark_T *fm = mark_get(rex.reg_buf, curwin, NULL, kMarkBufLocal, mark); // Line may have been freed, get it again. @@ -4168,7 +4168,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) if (rp == NULL) { status = RA_FAIL; } else { - rp->rs_no = no; + rp->rs_no = (int16_t)no; save_se(&rp->rs_un.sesave, &rex.reg_startpos[no], &rex.reg_startp[no]); // We simply continue and handle the result when done. @@ -4198,7 +4198,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) if (rp == NULL) { status = RA_FAIL; } else { - rp->rs_no = no; + rp->rs_no = (int16_t)no; save_se(&rp->rs_un.sesave, ®_startzpos[no], ®_startzp[no]); // We simply continue and handle the result when done. @@ -4221,7 +4221,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) if (rp == NULL) { status = RA_FAIL; } else { - rp->rs_no = no; + rp->rs_no = (int16_t)no; save_se(&rp->rs_un.sesave, &rex.reg_endpos[no], &rex.reg_endp[no]); // We simply continue and handle the result when done. } @@ -4242,7 +4242,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) if (rp == NULL) { status = RA_FAIL; } else { - rp->rs_no = no; + rp->rs_no = (int16_t)no; save_se(&rp->rs_un.sesave, ®_endzpos[no], ®_endzp[no]); // We simply continue and handle the result when done. @@ -4378,7 +4378,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) if (rp == NULL) { status = RA_FAIL; } else { - rp->rs_no = no; + rp->rs_no = (int16_t)no; reg_save(&rp->rs_un.regsave, &backpos); next = OPERAND(scan); // We continue and handle the result when done. @@ -4394,7 +4394,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) if (rp == NULL) { status = RA_FAIL; } else { - rp->rs_no = no; + rp->rs_no = (int16_t)no; reg_save(&rp->rs_un.regsave, &backpos); next = OPERAND(scan); // We continue and handle the result when done. @@ -4463,7 +4463,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) status = RA_FAIL; } else { ga_grow(®stack, sizeof(regstar_T)); - regstack.ga_len += sizeof(regstar_T); + regstack.ga_len += (int)sizeof(regstar_T); rp = regstack_push(rst.minval <= rst.maxval ? RS_STAR_LONG : RS_STAR_SHORT, scan); if (rp == NULL) { status = RA_FAIL; @@ -4485,7 +4485,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) if (rp == NULL) { status = RA_FAIL; } else { - rp->rs_no = op; + rp->rs_no = (int16_t)op; reg_save(&rp->rs_un.regsave, &backpos); next = OPERAND(scan); // We continue and handle the result when done. @@ -4500,7 +4500,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) status = RA_FAIL; } else { ga_grow(®stack, sizeof(regbehind_T)); - regstack.ga_len += sizeof(regbehind_T); + regstack.ga_len += (int)sizeof(regbehind_T); rp = regstack_push(RS_BEHIND1, scan); if (rp == NULL) { status = RA_FAIL; @@ -4509,7 +4509,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) // when there is a match but we don't use it. save_subexpr(((regbehind_T *)rp) - 1); - rp->rs_no = op; + rp->rs_no = (int16_t)op; reg_save(&rp->rs_un.regsave, &backpos); // First try if what follows matches. If it does then we // check the behind match by looping. @@ -4689,7 +4689,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) case RS_BEHIND1: if (status == RA_NOMATCH) { regstack_pop(&scan); - regstack.ga_len -= sizeof(regbehind_T); + regstack.ga_len -= (int)sizeof(regbehind_T); } else { // The stuff after BEHIND/NOBEHIND matches. Now try if // the behind part does (not) match before the current @@ -4732,7 +4732,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) restore_subexpr(((regbehind_T *)rp) - 1); } regstack_pop(&scan); - regstack.ga_len -= sizeof(regbehind_T); + regstack.ga_len -= (int)sizeof(regbehind_T); } else { long limit; @@ -4806,7 +4806,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) } } regstack_pop(&scan); - regstack.ga_len -= sizeof(regbehind_T); + regstack.ga_len -= (int)sizeof(regbehind_T); } } break; @@ -4817,7 +4817,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) if (status == RA_MATCH) { regstack_pop(&scan); - regstack.ga_len -= sizeof(regstar_T); + regstack.ga_len -= (int)sizeof(regstar_T); break; } @@ -4883,7 +4883,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out) if (status != RA_CONT) { // Failed. regstack_pop(&scan); - regstack.ga_len -= sizeof(regstar_T); + regstack.ga_len -= (int)sizeof(regstar_T); status = RA_NOMATCH; } } @@ -4974,15 +4974,13 @@ static long regtry(bt_regprog_T *prog, colnr_T col, proftime_T *tm, int *timed_o && reg_endzpos[i].lnum == reg_startzpos[i].lnum && reg_endzpos[i].col >= reg_startzpos[i].col) { re_extmatch_out->matches[i] = - vim_strnsave(reg_getline(reg_startzpos[i].lnum) - + reg_startzpos[i].col, - reg_endzpos[i].col - - reg_startzpos[i].col); + vim_strnsave(reg_getline(reg_startzpos[i].lnum) + reg_startzpos[i].col, + (size_t)(reg_endzpos[i].col - reg_startzpos[i].col)); } } else { if (reg_startzp[i] != NULL && reg_endzp[i] != NULL) { re_extmatch_out->matches[i] = - vim_strnsave(reg_startzp[i], reg_endzp[i] - reg_startzp[i]); + vim_strnsave(reg_startzp[i], (size_t)(reg_endzp[i] - reg_startzp[i])); } } } |