mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 13:38:34 +00:00
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
8c55d60658
This commit is contained in:
@@ -518,7 +518,7 @@ static bool checkCloseRec(garray_T *gap, linenr_T lnum, int level)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
// foldCreateAllowed() {{{2
|
// foldManualAllowed() {{{2
|
||||||
/// @return true if it's allowed to manually create or delete a fold or,
|
/// @return true if it's allowed to manually create or delete a fold or,
|
||||||
/// give an error message and return false if not.
|
/// give an error message and return false if not.
|
||||||
int foldManualAllowed(bool create)
|
int foldManualAllowed(bool create)
|
||||||
@@ -1025,7 +1025,7 @@ void foldAdjustVisual(void)
|
|||||||
mb_adjust_cursor();
|
mb_adjust_cursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
// cursor_foldstart() {{{2
|
// foldAdjustCursor() {{{2
|
||||||
/// Move the cursor to the first line of a closed fold.
|
/// Move the cursor to the first line of a closed fold.
|
||||||
void foldAdjustCursor(win_T *wp)
|
void foldAdjustCursor(win_T *wp)
|
||||||
{
|
{
|
||||||
|
@@ -1843,7 +1843,7 @@ colnr_T ml_get_len(linenr_T lnum)
|
|||||||
/// @return length (excluding the NUL) of the text after position "pos".
|
/// @return length (excluding the NUL) of the text after position "pos".
|
||||||
colnr_T ml_get_pos_len(pos_T *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.
|
/// @return length (excluding the NUL) of the given line in the given buffer.
|
||||||
|
@@ -1616,7 +1616,7 @@ int op_delete(oparg_T *oap)
|
|||||||
beginline(0); // cursor in column 0
|
beginline(0); // cursor in column 0
|
||||||
}
|
}
|
||||||
truncate_line(false); // delete the rest of the line,
|
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) {
|
if (oap->line_count > 1) {
|
||||||
u_clearline(curbuf); // "U" command not possible after "2cc"
|
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_col = (colnr_T)getwhitecols_curline();
|
||||||
ind_pre_vcol = get_indent();
|
ind_pre_vcol = get_indent();
|
||||||
pre_textlen = ml_get_len(oap->start.lnum) - bd.textcol;
|
pre_textlen = ml_get_len(oap->start.lnum) - bd.textcol;
|
||||||
|
|
||||||
if (oap->op_type == OP_APPEND) {
|
if (oap->op_type == OP_APPEND) {
|
||||||
pre_textlen -= bd.textlen;
|
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;
|
curwin->w_cursor = *pos;
|
||||||
char *ptr = ml_get(pos->lnum);
|
char *ptr = ml_get(pos->lnum);
|
||||||
|
int linelen = ml_get_len(pos->lnum);
|
||||||
int col = pos->col;
|
int col = pos->col;
|
||||||
|
|
||||||
if (*ptr == NUL || col + !!save_coladd >= (int)strlen(ptr)) {
|
if (col + !!save_coladd >= linelen) {
|
||||||
goto theend;
|
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)
|
// get the number value (unsigned)
|
||||||
if (visual && VIsual_mode != 'V') {
|
if (visual && VIsual_mode != 'V') {
|
||||||
maxlen = (curbuf->b_visual.vi_curswant == MAXCOL
|
maxlen = curbuf->b_visual.vi_curswant == MAXCOL ? linelen - col : length;
|
||||||
? (int)strlen(ptr) - col
|
|
||||||
: length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool overflow = false;
|
bool overflow = false;
|
||||||
|
@@ -5362,7 +5362,7 @@ static bool vgr_match_buflines(qf_list_T *qfl, char *fname, buf_T *buf, char *sp
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char *const str = ml_get_buf(buf, lnum);
|
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;
|
int score;
|
||||||
uint32_t matches[MAX_FUZZY_MATCHES];
|
uint32_t matches[MAX_FUZZY_MATCHES];
|
||||||
const size_t sz = sizeof(matches) / sizeof(matches[0]);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
col = (colnr_T)matches[pat_len - 1] + col + 1;
|
col = (colnr_T)matches[pat_len - 1] + col + 1;
|
||||||
if (col > line_len) {
|
if (col > linelen) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2370,6 +2370,14 @@ func Test_normal30_changecase()
|
|||||||
%d
|
%d
|
||||||
call assert_beeps('norm! ~')
|
call assert_beeps('norm! ~')
|
||||||
|
|
||||||
|
" Test with multiple lines
|
||||||
|
call setline(1, ['AA', 'BBBB', 'CCCCCC', 'DDDDDDDD'])
|
||||||
|
norm! ggguG
|
||||||
|
call assert_equal(['aa', 'bbbb', 'cccccc', 'dddddddd'], getline(1, '$'))
|
||||||
|
norm! GgUgg
|
||||||
|
call assert_equal(['AA', 'BBBB', 'CCCCCC', 'DDDDDDDD'], getline(1, '$'))
|
||||||
|
%d
|
||||||
|
|
||||||
" Test for changing case across lines using 'whichwrap'
|
" Test for changing case across lines using 'whichwrap'
|
||||||
call setline(1, ['aaaaaa', 'aaaaaa'])
|
call setline(1, ['aaaaaa', 'aaaaaa'])
|
||||||
normal! gg10~
|
normal! gg10~
|
||||||
|
Reference in New Issue
Block a user