comparison src/ops.c @ 34552:fd15dc02c223 v9.1.0177

patch 9.1.0177: Coverity reports dead code Commit: https://github.com/vim/vim/commit/8c55d60658b7ee3458dca57fc5eec90ca9bb9bf3 Author: zeertzjq <zeertzjq@outlook.com> Date: Wed Mar 13 20:42:26 2024 +0100 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: #14189 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Wed, 13 Mar 2024 21:00:03 +0100
parents 9e093c96dff6
children bcacdee71db4
comparison
equal deleted inserted replaced
34551:a2aa0fddd4e7 34552:fd15dc02c223
847 did_ai = TRUE; // delete the indent when ESC hit 847 did_ai = TRUE; // delete the indent when ESC hit
848 ai_col = curwin->w_cursor.col; 848 ai_col = curwin->w_cursor.col;
849 } 849 }
850 else 850 else
851 beginline(0); // cursor in column 0 851 beginline(0); // cursor in column 0
852 truncate_line(FALSE); // delete the rest of the line 852 truncate_line(FALSE); // delete the rest of the line,
853 // leave cursor past last char in line 853 // leaving cursor past last char in line
854 if (oap->line_count > 1) 854 if (oap->line_count > 1)
855 u_clearline(); // "U" command not possible after "2cc" 855 u_clearline(); // "U" command not possible after "2cc"
856 } 856 }
857 else 857 else
858 { 858 {
1492 * op_insert - Insert and append operators for Visual mode. 1492 * op_insert - Insert and append operators for Visual mode.
1493 */ 1493 */
1494 void 1494 void
1495 op_insert(oparg_T *oap, long count1) 1495 op_insert(oparg_T *oap, long count1)
1496 { 1496 {
1497 long ins_len, pre_textlen = 0; 1497 long pre_textlen = 0;
1498 char_u *firstline, *ins_text;
1499 colnr_T ind_pre_col = 0, ind_post_col; 1498 colnr_T ind_pre_col = 0, ind_post_col;
1500 int ind_pre_vcol = 0, ind_post_vcol = 0; 1499 int ind_pre_vcol = 0, ind_post_vcol = 0;
1501 struct block_def bd; 1500 struct block_def bd;
1502 int i; 1501 int i;
1503 pos_T t1; 1502 pos_T t1;
1504 pos_T start_insert; 1503 pos_T start_insert;
1505 // offset when cursor was moved in insert mode
1506 int offset = 0;
1507 1504
1508 // edit() changes this - record it for OP_APPEND 1505 // edit() changes this - record it for OP_APPEND
1509 bd.is_MAX = (curwin->w_curswant == MAXCOL); 1506 bd.is_MAX = (curwin->w_curswant == MAXCOL);
1510 1507
1511 // vis block is still marked. Get rid of it now. 1508 // vis block is still marked. Get rid of it now.
1538 // Get the info about the block before entering the text 1535 // Get the info about the block before entering the text
1539 block_prep(oap, &bd, oap->start.lnum, TRUE); 1536 block_prep(oap, &bd, oap->start.lnum, TRUE);
1540 // Get indent information 1537 // Get indent information
1541 ind_pre_col = (colnr_T)getwhitecols_curline(); 1538 ind_pre_col = (colnr_T)getwhitecols_curline();
1542 ind_pre_vcol = get_indent(); 1539 ind_pre_vcol = get_indent();
1543 firstline = ml_get(oap->start.lnum) + bd.textcol;
1544 pre_textlen = ml_get_len(oap->start.lnum) - bd.textcol; 1540 pre_textlen = ml_get_len(oap->start.lnum) - bd.textcol;
1545
1546 if (oap->op_type == OP_APPEND) 1541 if (oap->op_type == OP_APPEND)
1547 {
1548 firstline += bd.textlen;
1549 pre_textlen -= bd.textlen; 1542 pre_textlen -= bd.textlen;
1550 }
1551 } 1543 }
1552 1544
1553 if (oap->op_type == OP_APPEND) 1545 if (oap->op_type == OP_APPEND)
1554 { 1546 {
1555 if (oap->block_mode && curwin->w_cursor.coladd == 0) 1547 if (oap->block_mode && curwin->w_cursor.coladd == 0)
1599 if (curwin->w_cursor.lnum != oap->start.lnum || got_int) 1591 if (curwin->w_cursor.lnum != oap->start.lnum || got_int)
1600 return; 1592 return;
1601 1593
1602 if (oap->block_mode) 1594 if (oap->block_mode)
1603 { 1595 {
1596 long ins_len;
1597 char_u *firstline, *ins_text;
1604 struct block_def bd2; 1598 struct block_def bd2;
1605 int did_indent = FALSE; 1599 int did_indent = FALSE;
1606 size_t len; 1600 size_t len;
1607 int add; 1601 int add;
1602 // offset when cursor was moved in insert mode
1603 int offset = 0;
1608 1604
1609 // If indent kicked in, the firstline might have changed 1605 // If indent kicked in, the firstline might have changed
1610 // but only do that, if the indent actually increased. 1606 // but only do that, if the indent actually increased.
1611 ind_post_col = (colnr_T)getwhitecols_curline(); 1607 ind_post_col = (colnr_T)getwhitecols_curline();
1612 if (curbuf->b_op_start.col > ind_pre_col && ind_post_col > ind_pre_col) 1608 if (curbuf->b_op_start.col > ind_pre_col && ind_post_col > ind_pre_col)
2652 int pre; // 'X'/'x': hex; '0': octal; 'B'/'b': bin 2648 int pre; // 'X'/'x': hex; '0': octal; 'B'/'b': bin
2653 static int hexupper = FALSE; // 0xABC 2649 static int hexupper = FALSE; // 0xABC
2654 uvarnumber_T n; 2650 uvarnumber_T n;
2655 uvarnumber_T oldn; 2651 uvarnumber_T oldn;
2656 char_u *ptr; 2652 char_u *ptr;
2653 int linelen;
2657 int c; 2654 int c;
2658 int todel; 2655 int todel;
2659 int do_hex; 2656 int do_hex;
2660 int do_oct; 2657 int do_oct;
2661 int do_bin; 2658 int do_bin;
2685 pos->coladd = 0; 2682 pos->coladd = 0;
2686 } 2683 }
2687 2684
2688 curwin->w_cursor = *pos; 2685 curwin->w_cursor = *pos;
2689 ptr = ml_get(pos->lnum); 2686 ptr = ml_get(pos->lnum);
2687 linelen = ml_get_len(pos->lnum);
2690 col = pos->col; 2688 col = pos->col;
2691 2689
2692 if (*ptr == NUL || col + !!save_coladd >= (int)STRLEN(ptr)) 2690 if (col + !!save_coladd >= linelen)
2693 goto theend; 2691 goto theend;
2694 2692
2695 /* 2693 /*
2696 * First check if we are on a hexadecimal number, after the "0x". 2694 * First check if we are on a hexadecimal number, after the "0x".
2697 */ 2695 */
2867 negative = TRUE; 2865 negative = TRUE;
2868 } 2866 }
2869 // get the number value (unsigned) 2867 // get the number value (unsigned)
2870 if (visual && VIsual_mode != 'V') 2868 if (visual && VIsual_mode != 'V')
2871 maxlen = (curbuf->b_visual.vi_curswant == MAXCOL 2869 maxlen = (curbuf->b_visual.vi_curswant == MAXCOL
2872 ? (int)STRLEN(ptr) - col 2870 ? linelen - col : length);
2873 : length);
2874 2871
2875 int overflow = FALSE; 2872 int overflow = FALSE;
2876 vim_str2nr(ptr + col, &pre, &length, 2873 vim_str2nr(ptr + col, &pre, &length,
2877 0 + (do_bin ? STR2NR_BIN : 0) 2874 0 + (do_bin ? STR2NR_BIN : 0)
2878 + (do_oct ? STR2NR_OCT : 0) 2875 + (do_oct ? STR2NR_OCT : 0)