diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-03-14 12:41:25 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2024-03-14 13:09:57 +0800 |
commit | 61b48e91b941258e6945e3eafadc777dccef5b75 (patch) | |
tree | 132b06712a25cc34f93883a9ea63c26b4ce4bf45 /src | |
parent | 090d1fd0b86897d2f5a80a600becf1525398ef30 (diff) | |
download | rneovim-61b48e91b941258e6945e3eafadc777dccef5b75.tar.gz rneovim-61b48e91b941258e6945e3eafadc777dccef5b75.tar.bz2 rneovim-61b48e91b941258e6945e3eafadc777dccef5b75.zip |
vim-patch:9.1.0177: Coverity reports dead code
Problem: Coverity reports dead code.
Solution: Remove the dead code. Also fix a mistake in ml_get_pos_len()
and update some comments (zeertzjq).
closes: vim/vim#14189
https://github.com/vim/vim/commit/8c55d60658b7ee3458dca57fc5eec90ca9bb9bf3
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/fold.c | 4 | ||||
-rw-r--r-- | src/nvim/memline.c | 2 | ||||
-rw-r--r-- | src/nvim/ops.c | 10 | ||||
-rw-r--r-- | src/nvim/quickfix.c | 4 |
4 files changed, 9 insertions, 11 deletions
diff --git a/src/nvim/fold.c b/src/nvim/fold.c index e70a05ed9a..be3295c44c 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -518,7 +518,7 @@ static bool checkCloseRec(garray_T *gap, linenr_T lnum, int level) return retval; } -// foldCreateAllowed() {{{2 +// foldManualAllowed() {{{2 /// @return true if it's allowed to manually create or delete a fold or, /// give an error message and return false if not. int foldManualAllowed(bool create) @@ -1025,7 +1025,7 @@ void foldAdjustVisual(void) mb_adjust_cursor(); } -// cursor_foldstart() {{{2 +// foldAdjustCursor() {{{2 /// Move the cursor to the first line of a closed fold. void foldAdjustCursor(win_T *wp) { diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 9fa6261987..70304f6816 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -1843,7 +1843,7 @@ colnr_T ml_get_len(linenr_T lnum) /// @return length (excluding the NUL) of the text after position "pos". colnr_T ml_get_pos_len(pos_T *pos) { - return ml_get_buf_len(curbuf, curwin->w_cursor.lnum) - pos->col; + return ml_get_buf_len(curbuf, pos->lnum) - pos->col; } /// @return length (excluding the NUL) of the given line in the given buffer. diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 81b10f30a9..2decb11d25 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1616,7 +1616,7 @@ int op_delete(oparg_T *oap) beginline(0); // cursor in column 0 } truncate_line(false); // delete the rest of the line, - // leave cursor past last char in line + // leaving cursor past last char in line if (oap->line_count > 1) { u_clearline(curbuf); // "U" command not possible after "2cc" } @@ -2232,7 +2232,6 @@ void op_insert(oparg_T *oap, int count1) ind_pre_col = (colnr_T)getwhitecols_curline(); ind_pre_vcol = get_indent(); pre_textlen = ml_get_len(oap->start.lnum) - bd.textcol; - if (oap->op_type == OP_APPEND) { pre_textlen -= bd.textlen; } @@ -4452,9 +4451,10 @@ bool do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) curwin->w_cursor = *pos; char *ptr = ml_get(pos->lnum); + int linelen = ml_get_len(pos->lnum); int col = pos->col; - if (*ptr == NUL || col + !!save_coladd >= (int)strlen(ptr)) { + if (col + !!save_coladd >= linelen) { goto theend; } @@ -4593,9 +4593,7 @@ bool do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) // get the number value (unsigned) if (visual && VIsual_mode != 'V') { - maxlen = (curbuf->b_visual.vi_curswant == MAXCOL - ? (int)strlen(ptr) - col - : length); + maxlen = curbuf->b_visual.vi_curswant == MAXCOL ? linelen - col : length; } bool overflow = false; diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index a2029a6ae5..0f639bf86a 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -5362,7 +5362,7 @@ static bool vgr_match_buflines(qf_list_T *qfl, char *fname, buf_T *buf, char *sp } } else { char *const str = ml_get_buf(buf, lnum); - const int line_len = ml_get_buf_len(buf, lnum); + const colnr_T linelen = ml_get_buf_len(buf, lnum); int score; uint32_t matches[MAX_FUZZY_MATCHES]; const size_t sz = sizeof(matches) / sizeof(matches[0]); @@ -5401,7 +5401,7 @@ static bool vgr_match_buflines(qf_list_T *qfl, char *fname, buf_T *buf, char *sp break; } col = (colnr_T)matches[pat_len - 1] + col + 1; - if (col > line_len) { + if (col > linelen) { break; } } |