diff options
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r-- | src/nvim/ex_cmds.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 0918e73b8a..c2bf9e96e5 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -695,12 +695,10 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) return FAIL; for (extra = 0, l = line1; l <= line2; l++) { str = vim_strsave(ml_get(l + extra)); - if (str != NULL) { - ml_append(dest + l - line1, str, (colnr_T)0, FALSE); - free(str); - if (dest < line1) - extra++; - } + ml_append(dest + l - line1, str, (colnr_T)0, FALSE); + free(str); + if (dest < line1) + extra++; } /* @@ -803,10 +801,9 @@ void ex_copy(linenr_T line1, linenr_T line2, linenr_T n) /* need to use vim_strsave() because the line will be unlocked within * ml_append() */ p = vim_strsave(ml_get(line1)); - if (p != NULL) { - ml_append(curwin->w_cursor.lnum, p, (colnr_T)0, FALSE); - free(p); - } + ml_append(curwin->w_cursor.lnum, p, (colnr_T)0, FALSE); + free(p); + /* situation 2: skip already copied lines */ if (line1 == n) line1 = curwin->w_cursor.lnum; @@ -1886,8 +1883,6 @@ viminfo_readstring ( s = retval + 1; /* Skip the leading '<' */ } else { retval = vim_strsave(virp->vir_line + off); - if (retval == NULL) - return NULL; s = retval; } @@ -3937,17 +3932,14 @@ void do_sub(exarg_T *eap) * what matches. Temporarily replace the line * and change it back afterwards. */ orig_line = vim_strsave(ml_get(lnum)); - if (orig_line != NULL) { - char_u *new_line = concat_str(new_start, - sub_firstline + copycol); - - // Position the cursor relative to the end of the line, the - // previous substitute may have inserted or deleted characters - // before the cursor. - len_change = (int)STRLEN(new_line) - (int)STRLEN(orig_line); - curwin->w_cursor.col += len_change; - ml_replace(lnum, new_line, FALSE); - } + char_u *new_line = concat_str(new_start, sub_firstline + copycol); + + // Position the cursor relative to the end of the line, the + // previous substitute may have inserted or deleted characters + // before the cursor. + len_change = (int)STRLEN(new_line) - (int)STRLEN(orig_line); + curwin->w_cursor.col += len_change; + ml_replace(lnum, new_line, FALSE); } search_match_lines = regmatch.endpos[0].lnum @@ -5769,11 +5761,6 @@ void ex_sign(exarg_T *eap) next_sign_typenr = 1; /* wrap around */ sp->sn_name = vim_strsave(arg); - if (sp->sn_name == NULL) /* out of memory */ - { - free(sp); - return; - } /* add the new sign to the list of signs */ if (sp_prev == NULL) @@ -5837,7 +5824,7 @@ void ex_sign(exarg_T *eap) len = (int)(p - arg + ((cells == 1) ? 1 : 0)); sp->sn_text = vim_strnsave(arg, len); - if (sp->sn_text != NULL && cells == 1) + if (cells == 1) STRCPY(sp->sn_text + len - 1, " "); } else if (STRNCMP(arg, "linehl=", 7) == 0) |