Remove nonnullret deadcode: vim_strsave.

This commit is contained in:
Eliseo Martínez 2015-01-23 14:17:33 +01:00
parent ce5b476dd9
commit d228b8a93e
6 changed files with 14 additions and 31 deletions

View File

@ -1633,11 +1633,6 @@ change_indent (
* put it back again the way we wanted it. * put it back again the way we wanted it.
*/ */
if (State & VREPLACE_FLAG) { if (State & VREPLACE_FLAG) {
/* If orig_line didn't allocate, just return. At least we did the job,
* even if you can't backspace. */
if (orig_line == NULL)
return;
/* Save new line */ /* Save new line */
new_line = vim_strsave(get_cursor_line_ptr()); new_line = vim_strsave(get_cursor_line_ptr());

View File

@ -11628,18 +11628,12 @@ static void f_or(typval_T *argvars, typval_T *rettv)
*/ */
static void f_pathshorten(typval_T *argvars, typval_T *rettv) static void f_pathshorten(typval_T *argvars, typval_T *rettv)
{ {
char_u *p;
rettv->v_type = VAR_STRING; rettv->v_type = VAR_STRING;
p = get_tv_string_chk(&argvars[0]); rettv->vval.v_string = get_tv_string_chk(&argvars[0]);
if (p == NULL) if (!rettv->vval.v_string) {
rettv->vval.v_string = NULL; return;
else {
p = vim_strsave(p);
rettv->vval.v_string = p;
if (p != NULL)
shorten_dir(p);
} }
rettv->vval.v_string = shorten_dir(vim_strsave(rettv->vval.v_string));
} }
/* /*

View File

@ -4742,7 +4742,6 @@ void ex_help(exarg_T *eap)
tag = vim_strsave(matches[i]); tag = vim_strsave(matches[i]);
FreeWild(num_matches, matches); FreeWild(num_matches, matches);
/* /*
* Re-use an existing help window or open a new one. * Re-use an existing help window or open a new one.
* Always open a new one for ":tab help". * Always open a new one for ":tab help".
@ -4805,8 +4804,7 @@ void ex_help(exarg_T *eap)
* It is needed for do_tag top open folds under the cursor. */ * It is needed for do_tag top open folds under the cursor. */
KeyTyped = old_KeyTyped; KeyTyped = old_KeyTyped;
if (tag != NULL) do_tag(tag, DT_HELP, 1, FALSE, TRUE);
do_tag(tag, DT_HELP, 1, FALSE, TRUE);
/* Delete the empty buffer if we're not using it. Careful: autocommands /* Delete the empty buffer if we're not using it. Careful: autocommands
* may have jumped to another window, check that the buffer is not in a * may have jumped to another window, check that the buffer is not in a

View File

@ -1593,8 +1593,6 @@ int get_c_indent(void)
* This is required, because only the most recent line obtained with * This is required, because only the most recent line obtained with
* ml_get is valid! */ * ml_get is valid! */
linecopy = vim_strsave(ml_get(cur_curpos.lnum)); linecopy = vim_strsave(ml_get(cur_curpos.lnum));
if (linecopy == NULL)
return 0;
/* /*
* In insert mode and the cursor is on a ')' truncate the line at the * In insert mode and the cursor is on a ')' truncate the line at the

View File

@ -239,33 +239,31 @@ int vim_ispathlistsep(int c)
* Shorten the path of a file from "~/foo/../.bar/fname" to "~/f/../.b/fname" * Shorten the path of a file from "~/foo/../.bar/fname" to "~/f/../.b/fname"
* It's done in-place. * It's done in-place.
*/ */
void shorten_dir(char_u *str) char_u *shorten_dir(char_u *str)
{ {
char_u *tail, *s, *d; char_u *tail = path_tail(str);
int skip = FALSE; char_u *d = str;
bool skip = false;
tail = path_tail(str); for (char_u *s = str;; ++s) {
d = str;
for (s = str;; ++s) {
if (s >= tail) { /* copy the whole tail */ if (s >= tail) { /* copy the whole tail */
*d++ = *s; *d++ = *s;
if (*s == NUL) if (*s == NUL)
break; break;
} else if (vim_ispathsep(*s)) { /* copy '/' and next char */ } else if (vim_ispathsep(*s)) { /* copy '/' and next char */
*d++ = *s; *d++ = *s;
skip = FALSE; skip = false;
} else if (!skip) { } else if (!skip) {
*d++ = *s; /* copy next char */ *d++ = *s; /* copy next char */
if (*s != '~' && *s != '.') /* and leading "~" and "." */ if (*s != '~' && *s != '.') /* and leading "~" and "." */
skip = TRUE; skip = true;
if (has_mbyte) { if (has_mbyte) {
int l = mb_ptr2len(s); int l = mb_ptr2len(s);
while (--l > 0) while (--l > 0)
*d++ = *++s; *d++ = *++s;
} }
} }
} }
return str;
} }
/* /*

View File

@ -7795,7 +7795,7 @@ static void draw_tabline(void)
if (room > 0) { if (room > 0) {
/* Get buffer name in NameBuff[] */ /* Get buffer name in NameBuff[] */
get_trans_bufname(cwp->w_buffer); get_trans_bufname(cwp->w_buffer);
shorten_dir(NameBuff); (void)shorten_dir(NameBuff);
len = vim_strsize(NameBuff); len = vim_strsize(NameBuff);
p = NameBuff; p = NameBuff;
if (has_mbyte) if (has_mbyte)