comparison src/ops.c @ 7576:e008ca0e2af2 v7.4.1088

commit https://github.com/vim/vim/commit/7ae4fbca552c972eb3645ece02a2807e517610d7 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 12 21:00:40 2016 +0100 patch 7.4.1088 Problem: Coverity warns for uninitialized variables. Only one is an actual problem. Solution: Move the conditions. Don't use endpos if handling an error.
author Christian Brabandt <cb@256bit.org>
date Tue, 12 Jan 2016 21:15:05 +0100
parents b872724c37db
children 0b6c37dd858d
comparison
equal deleted inserted replaced
7575:44b65a9cc81f 7576:e008ca0e2af2
5369 if (change_cnt) 5369 if (change_cnt)
5370 changed_lines(pos.lnum, 0, pos.lnum + 1, 0L); 5370 changed_lines(pos.lnum, 0, pos.lnum + 1, 0L);
5371 } 5371 }
5372 else 5372 else
5373 { 5373 {
5374 int one_change; 5374 int one_change;
5375 int length; 5375 int length;
5376 pos_T startpos; 5376 pos_T startpos;
5377 5377
5378 if (u_save((linenr_T)(oap->start.lnum - 1), 5378 if (u_save((linenr_T)(oap->start.lnum - 1),
5379 (linenr_T)(oap->end.lnum + 1)) == FAIL) 5379 (linenr_T)(oap->end.lnum + 1)) == FAIL)
5380 return; 5380 return;
5381 5381
5386 { 5386 {
5387 block_prep(oap, &bd, pos.lnum, FALSE); 5387 block_prep(oap, &bd, pos.lnum, FALSE);
5388 pos.col = bd.textcol; 5388 pos.col = bd.textcol;
5389 length = bd.textlen; 5389 length = bd.textlen;
5390 } 5390 }
5391 else 5391 else if (oap->motion_type == MLINE)
5392 { 5392 {
5393 if (oap->motion_type == MLINE) 5393 curwin->w_cursor.col = 0;
5394 pos.col = 0;
5395 length = (colnr_T)STRLEN(ml_get(pos.lnum));
5396 }
5397 else /* oap->motion_type == MCHAR */
5398 {
5399 if (!oap->inclusive)
5400 dec(&(oap->end));
5401 length = (colnr_T)STRLEN(ml_get(pos.lnum));
5402 pos.col = 0;
5403 if (pos.lnum == oap->start.lnum)
5394 { 5404 {
5395 curwin->w_cursor.col = 0; 5405 pos.col += oap->start.col;
5396 pos.col = 0; 5406 length -= oap->start.col;
5397 length = (colnr_T)STRLEN(ml_get(pos.lnum));
5398 } 5407 }
5399 else if (oap->motion_type == MCHAR) 5408 if (pos.lnum == oap->end.lnum)
5400 { 5409 {
5401 if (!oap->inclusive) 5410 length = (int)STRLEN(ml_get(oap->end.lnum));
5402 dec(&(oap->end)); 5411 if (oap->end.col >= length)
5403 length = (colnr_T)STRLEN(ml_get(pos.lnum)); 5412 oap->end.col = length - 1;
5404 pos.col = 0; 5413 length = oap->end.col - pos.col + 1;
5405 if (pos.lnum == oap->start.lnum)
5406 {
5407 pos.col += oap->start.col;
5408 length -= oap->start.col;
5409 }
5410 if (pos.lnum == oap->end.lnum)
5411 {
5412 length = (int)STRLEN(ml_get(oap->end.lnum));
5413 if (oap->end.col >= length)
5414 oap->end.col = length - 1;
5415 length = oap->end.col - pos.col + 1;
5416 }
5417 } 5414 }
5418 } 5415 }
5419 one_change = do_addsub(oap->op_type, &pos, length, amount); 5416 one_change = do_addsub(oap->op_type, &pos, length, amount);
5420 if (one_change) 5417 if (one_change)
5421 { 5418 {
5491 int subtract; 5488 int subtract;
5492 int negative = FALSE; 5489 int negative = FALSE;
5493 int was_positive = TRUE; 5490 int was_positive = TRUE;
5494 int visual = VIsual_active; 5491 int visual = VIsual_active;
5495 int did_change = FALSE; 5492 int did_change = FALSE;
5496 pos_T t = curwin->w_cursor; 5493 pos_T save_cursor = curwin->w_cursor;
5497 int maxlen = 0; 5494 int maxlen = 0;
5498 pos_T startpos; 5495 pos_T startpos;
5499 pos_T endpos; 5496 pos_T endpos;
5500 5497
5501 dohex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); /* "heX" */ 5498 dohex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); /* "heX" */
5817 endpos = curwin->w_cursor; 5814 endpos = curwin->w_cursor;
5818 if (did_change && curwin->w_cursor.col) 5815 if (did_change && curwin->w_cursor.col)
5819 --curwin->w_cursor.col; 5816 --curwin->w_cursor.col;
5820 } 5817 }
5821 5818
5822 theend:
5823 if (visual)
5824 curwin->w_cursor = t;
5825 if (did_change) 5819 if (did_change)
5826 { 5820 {
5827 /* set the '[ and '] marks */ 5821 /* set the '[ and '] marks */
5828 curbuf->b_op_start = startpos; 5822 curbuf->b_op_start = startpos;
5829 curbuf->b_op_end = endpos; 5823 curbuf->b_op_end = endpos;
5830 if (curbuf->b_op_end.col > 0) 5824 if (curbuf->b_op_end.col > 0)
5831 --curbuf->b_op_end.col; 5825 --curbuf->b_op_end.col;
5832 } 5826 }
5827
5828 theend:
5829 if (visual)
5830 curwin->w_cursor = save_cursor;
5833 5831
5834 return did_change; 5832 return did_change;
5835 } 5833 }
5836 5834
5837 #ifdef FEAT_VIMINFO 5835 #ifdef FEAT_VIMINFO