mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Remove NULL/non-NULL tests after calls to vim_str(n)save()
This commit is contained in:
parent
b63d2626ed
commit
a80d7e86c1
@ -2237,9 +2237,8 @@ setfname (
|
||||
close_buffer(NULL, obuf, DOBUF_WIPE, FALSE);
|
||||
}
|
||||
sfname = vim_strsave(sfname);
|
||||
if (ffname == NULL || sfname == NULL) {
|
||||
if (ffname == NULL) {
|
||||
free(sfname);
|
||||
free(ffname);
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef USE_FNAME_CASE
|
||||
@ -4116,8 +4115,6 @@ chk_modeline (
|
||||
while (s[-1] != ':');
|
||||
|
||||
s = linecopy = vim_strsave(s); /* copy the line, it will change */
|
||||
if (linecopy == NULL)
|
||||
return FAIL;
|
||||
|
||||
save_sourcing_lnum = sourcing_lnum;
|
||||
save_sourcing_name = sourcing_name;
|
||||
|
@ -1911,9 +1911,6 @@ void backslash_halve(char_u *p)
|
||||
char_u* backslash_halve_save(char_u *p)
|
||||
{
|
||||
char_u *res = vim_strsave(p);
|
||||
if (res == NULL) {
|
||||
return p;
|
||||
}
|
||||
backslash_halve(res);
|
||||
return res;
|
||||
}
|
||||
|
@ -519,10 +519,6 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp)
|
||||
dp->df_lnum[i_org] + off_org,
|
||||
FALSE));
|
||||
|
||||
if (line_org == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
int i_new;
|
||||
for (i_new = i_org + 1; i_new < DB_COUNT; ++i_new) {
|
||||
if (tp->tp_diffbuf[i_new] == NULL) {
|
||||
@ -972,10 +968,7 @@ void ex_diffpatch(exarg_T *eap)
|
||||
if (curbuf->b_fname != NULL) {
|
||||
newname = vim_strnsave(curbuf->b_fname,
|
||||
(int)(STRLEN(curbuf->b_fname) + 4));
|
||||
|
||||
if (newname != NULL) {
|
||||
STRCAT(newname, ".new");
|
||||
}
|
||||
STRCAT(newname, ".new");
|
||||
}
|
||||
|
||||
// don't use a new tab page, each tab page has its own diffs
|
||||
@ -1580,9 +1573,6 @@ static int diff_equal_entry(diff_T *dp, int idx1, int idx2)
|
||||
char_u *line = vim_strsave(ml_get_buf(curtab->tp_diffbuf[idx1],
|
||||
dp->df_lnum[idx1] + i, FALSE));
|
||||
|
||||
if (line == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
int cmp = diff_cmp(line, ml_get_buf(curtab->tp_diffbuf[idx2],
|
||||
dp->df_lnum[idx2] + i, FALSE));
|
||||
free(line);
|
||||
@ -1886,9 +1876,6 @@ int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
|
||||
|
||||
// Make a copy of the line, the next ml_get() will invalidate it.
|
||||
char_u *line_org = vim_strsave(ml_get_buf(wp->w_buffer, lnum, FALSE));
|
||||
if (line_org == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int idx = diff_buf_idx(wp->w_buffer);
|
||||
if (idx == DB_COUNT) {
|
||||
@ -2283,16 +2270,14 @@ void ex_diffgetput(exarg_T *eap)
|
||||
break;
|
||||
}
|
||||
p = vim_strsave(ml_get_buf(curtab->tp_diffbuf[idx_from], nr, FALSE));
|
||||
if (p != NULL) {
|
||||
ml_append(lnum + i - 1, p, 0, FALSE);
|
||||
free(p);
|
||||
added++;
|
||||
if (buf_empty && (curbuf->b_ml.ml_line_count == 2)) {
|
||||
// Added the first line into an empty buffer, need to
|
||||
// delete the dummy empty line.
|
||||
buf_empty = FALSE;
|
||||
ml_delete((linenr_T)2, FALSE);
|
||||
}
|
||||
ml_append(lnum + i - 1, p, 0, FALSE);
|
||||
free(p);
|
||||
added++;
|
||||
if (buf_empty && (curbuf->b_ml.ml_line_count == 2)) {
|
||||
// Added the first line into an empty buffer, need to
|
||||
// delete the dummy empty line.
|
||||
buf_empty = FALSE;
|
||||
ml_delete((linenr_T)2, FALSE);
|
||||
}
|
||||
}
|
||||
new_count = dp->df_count[idx_to] + added;
|
||||
|
@ -1818,12 +1818,10 @@ void ex_loadkeymap(exarg_T *eap)
|
||||
s = skiptowhite(p);
|
||||
kp->to = vim_strnsave(p, (int)(s - p));
|
||||
|
||||
if ((kp->from == NULL)
|
||||
|| (kp->to == NULL)
|
||||
|| (STRLEN(kp->from) + STRLEN(kp->to) >= KMAP_LLEN)
|
||||
if ((STRLEN(kp->from) + STRLEN(kp->to) >= KMAP_LLEN)
|
||||
|| (*kp->from == NUL)
|
||||
|| (*kp->to == NUL)) {
|
||||
if ((kp->to != NULL) && (*kp->to == NUL)) {
|
||||
if (*kp->to == NUL) {
|
||||
EMSG(_("E791: Empty keymap entry"));
|
||||
}
|
||||
free(kp->from);
|
||||
|
@ -1727,8 +1727,6 @@ change_indent (
|
||||
|
||||
/* Save new line */
|
||||
new_line = vim_strsave(ml_get_curline());
|
||||
if (new_line == NULL)
|
||||
return;
|
||||
|
||||
/* We only put back the new line up to the cursor */
|
||||
new_line[curwin->w_cursor.col] = NUL;
|
||||
@ -2128,10 +2126,7 @@ ins_compl_add (
|
||||
match->cp_number = -1;
|
||||
if (flags & ORIGINAL_TEXT)
|
||||
match->cp_number = 0;
|
||||
if ((match->cp_str = vim_strnsave(str, len)) == NULL) {
|
||||
free(match);
|
||||
return FAIL;
|
||||
}
|
||||
match->cp_str = vim_strnsave(str, len);
|
||||
match->cp_icase = icase;
|
||||
|
||||
/* match-fname is:
|
||||
@ -2210,18 +2205,16 @@ static void ins_compl_longest_match(compl_T *match)
|
||||
if (compl_leader == NULL) {
|
||||
/* First match, use it as a whole. */
|
||||
compl_leader = vim_strsave(match->cp_str);
|
||||
if (compl_leader != NULL) {
|
||||
had_match = (curwin->w_cursor.col > compl_col);
|
||||
ins_compl_delete();
|
||||
ins_bytes(compl_leader + ins_compl_len());
|
||||
ins_redraw(FALSE);
|
||||
had_match = (curwin->w_cursor.col > compl_col);
|
||||
ins_compl_delete();
|
||||
ins_bytes(compl_leader + ins_compl_len());
|
||||
ins_redraw(FALSE);
|
||||
|
||||
/* When the match isn't there (to avoid matching itself) remove it
|
||||
* again after redrawing. */
|
||||
if (!had_match)
|
||||
ins_compl_delete();
|
||||
compl_used_match = FALSE;
|
||||
}
|
||||
/* When the match isn't there (to avoid matching itself) remove it
|
||||
* again after redrawing. */
|
||||
if (!had_match)
|
||||
ins_compl_delete();
|
||||
compl_used_match = FALSE;
|
||||
} else {
|
||||
/* Reduce the text if this match differs from compl_leader. */
|
||||
p = compl_leader;
|
||||
@ -2328,9 +2321,10 @@ void set_completion(colnr_T startcol, list_T *list)
|
||||
compl_length = (int)curwin->w_cursor.col - (int)startcol;
|
||||
/* compl_pattern doesn't need to be set */
|
||||
compl_orig_text = vim_strnsave(ml_get_curline() + compl_col, compl_length);
|
||||
if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
|
||||
-1, p_ic, NULL, NULL, 0, ORIGINAL_TEXT, FALSE) != OK)
|
||||
if (ins_compl_add(compl_orig_text, -1, p_ic, NULL, NULL, 0,
|
||||
ORIGINAL_TEXT, FALSE) != OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Handle like dictionary completion. */
|
||||
ctrl_x_mode = CTRL_X_WHOLE_LINE;
|
||||
@ -2873,14 +2867,12 @@ static int ins_compl_bs(void)
|
||||
|
||||
free(compl_leader);
|
||||
compl_leader = vim_strnsave(line + compl_col, (int)(p - line) - compl_col);
|
||||
if (compl_leader != NULL) {
|
||||
ins_compl_new_leader();
|
||||
if (compl_shown_match != NULL)
|
||||
/* Make sure current match is not a hidden item. */
|
||||
compl_curr_match = compl_shown_match;
|
||||
return NUL;
|
||||
}
|
||||
return K_BS;
|
||||
ins_compl_new_leader();
|
||||
if (compl_shown_match != NULL)
|
||||
/* Make sure current match is not a hidden item. */
|
||||
compl_curr_match = compl_shown_match;
|
||||
|
||||
return NUL;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2980,8 +2972,7 @@ static void ins_compl_addleader(int c)
|
||||
free(compl_leader);
|
||||
compl_leader = vim_strnsave(ml_get_curline() + compl_col,
|
||||
(int)(curwin->w_cursor.col - compl_col));
|
||||
if (compl_leader != NULL)
|
||||
ins_compl_new_leader();
|
||||
ins_compl_new_leader();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3003,15 +2994,10 @@ static void ins_compl_restart(void)
|
||||
*/
|
||||
static void ins_compl_set_original_text(char_u *str)
|
||||
{
|
||||
char_u *p;
|
||||
|
||||
/* Replace the original text entry. */
|
||||
if (compl_first_match->cp_flags & ORIGINAL_TEXT) { /* safety check */
|
||||
p = vim_strsave(str);
|
||||
if (p != NULL) {
|
||||
free(compl_first_match->cp_str);
|
||||
compl_first_match->cp_str = p;
|
||||
}
|
||||
free(compl_first_match->cp_str);
|
||||
compl_first_match->cp_str = vim_strsave(str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4356,8 +4342,6 @@ static int ins_complete(int c)
|
||||
) {
|
||||
/* Match any word of at least two chars */
|
||||
compl_pattern = vim_strsave((char_u *)"\\<\\k\\k");
|
||||
if (compl_pattern == NULL)
|
||||
return FAIL;
|
||||
compl_col += curs_col;
|
||||
compl_length = 0;
|
||||
} else {
|
||||
@ -4432,8 +4416,6 @@ static int ins_complete(int c)
|
||||
return FAIL;
|
||||
} else if (ctrl_x_mode == CTRL_X_CMDLINE) {
|
||||
compl_pattern = vim_strnsave(line, curs_col);
|
||||
if (compl_pattern == NULL)
|
||||
return FAIL;
|
||||
set_cmd_context(&compl_xp, compl_pattern,
|
||||
(int)STRLEN(compl_pattern), curs_col);
|
||||
if (compl_xp.xp_context == EXPAND_UNSUCCESSFUL
|
||||
@ -4513,8 +4495,6 @@ static int ins_complete(int c)
|
||||
line = ml_get(curwin->w_cursor.lnum);
|
||||
compl_length = curs_col - compl_col;
|
||||
compl_pattern = vim_strnsave(line + compl_col, compl_length);
|
||||
if (compl_pattern == NULL)
|
||||
return FAIL;
|
||||
} else if (ctrl_x_mode == CTRL_X_SPELL) {
|
||||
if (spell_bad_len > 0)
|
||||
compl_col = curs_col - spell_bad_len;
|
||||
@ -4530,8 +4510,6 @@ static int ins_complete(int c)
|
||||
/* Need to obtain "line" again, it may have become invalid. */
|
||||
line = ml_get(curwin->w_cursor.lnum);
|
||||
compl_pattern = vim_strnsave(line + compl_col, compl_length);
|
||||
if (compl_pattern == NULL)
|
||||
return FAIL;
|
||||
} else {
|
||||
EMSG2(_(e_intern2), "ins_complete()");
|
||||
return FAIL;
|
||||
@ -4568,8 +4546,8 @@ static int ins_complete(int c)
|
||||
/* Always add completion for the original text. */
|
||||
free(compl_orig_text);
|
||||
compl_orig_text = vim_strnsave(line + compl_col, compl_length);
|
||||
if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
|
||||
-1, p_ic, NULL, NULL, 0, ORIGINAL_TEXT, FALSE) != OK) {
|
||||
if (ins_compl_add(compl_orig_text, -1, p_ic, NULL, NULL, 0,
|
||||
ORIGINAL_TEXT, FALSE) != OK) {
|
||||
free(compl_pattern);
|
||||
compl_pattern = NULL;
|
||||
free(compl_orig_text);
|
||||
@ -6227,11 +6205,10 @@ char_u *get_last_insert_save(void)
|
||||
if (last_insert == NULL)
|
||||
return NULL;
|
||||
s = vim_strsave(last_insert + last_insert_skip);
|
||||
if (s != NULL) {
|
||||
len = (int)STRLEN(s);
|
||||
if (len > 0 && s[len - 1] == ESC) /* remove trailing ESC */
|
||||
s[len - 1] = NUL;
|
||||
}
|
||||
len = (int)STRLEN(s);
|
||||
if (len > 0 && s[len - 1] == ESC) /* remove trailing ESC */
|
||||
s[len - 1] = NUL;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -8006,8 +7983,6 @@ static int ins_tab(void)
|
||||
pos = curwin->w_cursor;
|
||||
cursor = &pos;
|
||||
saved_line = vim_strsave(ml_get_curline());
|
||||
if (saved_line == NULL)
|
||||
return FALSE;
|
||||
ptr = saved_line + pos.col;
|
||||
} else {
|
||||
ptr = ml_get_cursor();
|
||||
@ -8411,7 +8386,6 @@ static colnr_T get_nolist_virtcol(void)
|
||||
*/
|
||||
static char_u *do_insert_char_pre(int c)
|
||||
{
|
||||
char_u *res;
|
||||
char_u buf[MB_MAXBYTES + 1];
|
||||
|
||||
/* Return quickly when there is nothing to do. */
|
||||
@ -8429,7 +8403,7 @@ static char_u *do_insert_char_pre(int c)
|
||||
++textlock;
|
||||
set_vim_var_string(VV_CHAR, buf, -1); /* set v:char */
|
||||
|
||||
res = NULL;
|
||||
char_u *res = NULL;
|
||||
if (apply_autocmds(EVENT_INSERTCHARPRE, NULL, NULL, FALSE, curbuf)) {
|
||||
/* Get the value of v:char. It may be empty or more than one
|
||||
* character. Only use it when changed, otherwise continue with the
|
||||
|
135
src/nvim/eval.c
135
src/nvim/eval.c
@ -1041,8 +1041,6 @@ var_redir_start (
|
||||
|
||||
/* Make a copy of the name, it is used in redir_lval until redir ends. */
|
||||
redir_varname = vim_strsave(name);
|
||||
if (redir_varname == NULL)
|
||||
return FAIL;
|
||||
|
||||
redir_lval = xcalloc(1, sizeof(lval_T));
|
||||
|
||||
@ -2542,8 +2540,6 @@ get_lval (
|
||||
lp->ll_newkey = vim_strnsave(key, len);
|
||||
if (len == -1)
|
||||
clear_tv(&var1);
|
||||
if (lp->ll_newkey == NULL)
|
||||
p = NULL;
|
||||
break;
|
||||
}
|
||||
/* existing variable, need to check if it can be changed */
|
||||
@ -6353,8 +6349,6 @@ dictitem_T *dict_find(dict_T *d, char_u *key, int len)
|
||||
akey = key;
|
||||
else if (len >= AKEYLEN) {
|
||||
tofree = akey = vim_strnsave(key, len);
|
||||
if (akey == NULL)
|
||||
return NULL;
|
||||
} else {
|
||||
/* Avoid a malloc/free by using buf[]. */
|
||||
vim_strncpy(buf, key, len);
|
||||
@ -7264,8 +7258,6 @@ call_func (
|
||||
/* Make a copy of the name, if it comes from a funcref variable it could
|
||||
* be changed or deleted in the called function. */
|
||||
name = vim_strnsave(funcname, len);
|
||||
if (name == NULL)
|
||||
return ret;
|
||||
|
||||
/*
|
||||
* In a script change <SID>name() and s:name() to K_SNR 123_name().
|
||||
@ -9677,11 +9669,9 @@ static void f_getfperm(typval_T *argvars, typval_T *rettv)
|
||||
int32_t file_perm = os_getperm(filename);
|
||||
if (file_perm >= 0) {
|
||||
perm = vim_strsave((char_u *)"---------");
|
||||
if (perm != NULL) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (file_perm & (1 << (8 - i)))
|
||||
perm[i] = flags[i % 3];
|
||||
}
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (file_perm & (1 << (8 - i)))
|
||||
perm[i] = flags[i % 3];
|
||||
}
|
||||
}
|
||||
rettv->v_type = VAR_STRING;
|
||||
@ -11761,8 +11751,6 @@ static int mkdir_recurse(char_u *dir, int prot)
|
||||
|
||||
/* If the directory exists we're done. Otherwise: create it.*/
|
||||
updir = vim_strnsave(dir, (int)(p - dir));
|
||||
if (updir == NULL)
|
||||
return FAIL;
|
||||
if (os_isdir(updir))
|
||||
r = OK;
|
||||
else if (mkdir_recurse(updir, prot) == OK)
|
||||
@ -12107,17 +12095,11 @@ static void f_readfile(typval_T *argvars, typval_T *rettv)
|
||||
/* Change "prev" buffer to be the right size. This way
|
||||
* the bytes are only copied once, and very long lines are
|
||||
* allocated only once. */
|
||||
if ((s = xrealloc(prev, prevlen + len + 1)) != NULL) {
|
||||
memmove(s + prevlen, start, len);
|
||||
s[prevlen + len] = NUL;
|
||||
prev = NULL; /* the list will own the string */
|
||||
prevlen = prevsize = 0;
|
||||
}
|
||||
}
|
||||
if (s == NULL) {
|
||||
do_outofmem_msg((long_u) prevlen + len + 1);
|
||||
failed = TRUE;
|
||||
break;
|
||||
s = xrealloc(prev, prevlen + len + 1);
|
||||
memcpy(s + prevlen, start, len);
|
||||
s[prevlen + len] = NUL;
|
||||
prev = NULL; /* the list will own the string */
|
||||
prevlen = prevsize = 0;
|
||||
}
|
||||
|
||||
if ((li = listitem_alloc()) == NULL) {
|
||||
@ -12592,11 +12574,10 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
|
||||
q = path_next_component(remain + 1);
|
||||
len = q - remain - (*q != NUL);
|
||||
cpy = vim_strnsave(p, STRLEN(p) + len);
|
||||
if (cpy != NULL) {
|
||||
STRNCAT(cpy, remain, len);
|
||||
free(p);
|
||||
p = cpy;
|
||||
}
|
||||
STRNCAT(cpy, remain, len);
|
||||
free(p);
|
||||
p = cpy;
|
||||
|
||||
/* Shorten "remain". */
|
||||
if (*q != NUL)
|
||||
STRMOVE(remain, q - 1);
|
||||
@ -14940,33 +14921,30 @@ static void f_tanh(typval_T *argvars, typval_T *rettv)
|
||||
*/
|
||||
static void f_tolower(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
char_u *p;
|
||||
|
||||
p = vim_strsave(get_tv_string(&argvars[0]));
|
||||
char_u *p = vim_strsave(get_tv_string(&argvars[0]));
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = p;
|
||||
|
||||
if (p != NULL)
|
||||
while (*p != NUL) {
|
||||
int l;
|
||||
while (*p != NUL) {
|
||||
int l;
|
||||
|
||||
if (enc_utf8) {
|
||||
int c, lc;
|
||||
if (enc_utf8) {
|
||||
int c, lc;
|
||||
|
||||
c = utf_ptr2char(p);
|
||||
lc = utf_tolower(c);
|
||||
l = utf_ptr2len(p);
|
||||
/* TODO: reallocate string when byte count changes. */
|
||||
if (utf_char2len(lc) == l)
|
||||
utf_char2bytes(lc, p);
|
||||
p += l;
|
||||
} else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
|
||||
p += l; /* skip multi-byte character */
|
||||
else {
|
||||
*p = TOLOWER_LOC(*p); /* note that tolower() can be a macro */
|
||||
++p;
|
||||
}
|
||||
c = utf_ptr2char(p);
|
||||
lc = utf_tolower(c);
|
||||
l = utf_ptr2len(p);
|
||||
/* TODO: reallocate string when byte count changes. */
|
||||
if (utf_char2len(lc) == l)
|
||||
utf_char2bytes(lc, p);
|
||||
p += l;
|
||||
} else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
|
||||
p += l; /* skip multi-byte character */
|
||||
else {
|
||||
*p = TOLOWER_LOC(*p); /* note that tolower() can be a macro */
|
||||
++p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -17428,8 +17406,6 @@ void ex_function(exarg_T *eap)
|
||||
c = *p;
|
||||
*p = NUL;
|
||||
arg = vim_strsave(arg);
|
||||
if (arg == NULL)
|
||||
goto erret;
|
||||
|
||||
/* Check for duplicate argument name. */
|
||||
for (i = 0; i < newargs.ga_len; ++i)
|
||||
@ -17621,11 +17597,9 @@ void ex_function(exarg_T *eap)
|
||||
* allocates 250 bytes per line, this saves 80% on average. The cost
|
||||
* is an extra alloc/free. */
|
||||
p = vim_strsave(theline);
|
||||
if (p != NULL) {
|
||||
if (line_arg == NULL)
|
||||
free(theline);
|
||||
theline = p;
|
||||
}
|
||||
if (line_arg == NULL)
|
||||
free(theline);
|
||||
theline = p;
|
||||
|
||||
((char_u **)(newlines.ga_data))[newlines.ga_len++] = theline;
|
||||
|
||||
@ -17694,8 +17668,6 @@ void ex_function(exarg_T *eap)
|
||||
free(name);
|
||||
sprintf(numbuf, "%d", ++func_nr);
|
||||
name = vim_strsave((char_u *)numbuf);
|
||||
if (name == NULL)
|
||||
goto erret;
|
||||
}
|
||||
|
||||
if (fp == NULL) {
|
||||
@ -19538,11 +19510,9 @@ repeat:
|
||||
/* Only replace it when it starts with '~' */
|
||||
if (*dirname == '~') {
|
||||
s = vim_strsave(dirname);
|
||||
if (s != NULL) {
|
||||
*fnamep = s;
|
||||
free(*bufp);
|
||||
*bufp = s;
|
||||
}
|
||||
*fnamep = s;
|
||||
free(*bufp);
|
||||
*bufp = s;
|
||||
}
|
||||
}
|
||||
free(pbuf);
|
||||
@ -19563,11 +19533,8 @@ repeat:
|
||||
*fnamelen = (int)(tail - *fnamep);
|
||||
if (*fnamelen == 0) {
|
||||
/* Result is empty. Turn it into "." to make ":cd %:h" work. */
|
||||
p = vim_strsave((char_u *)".");
|
||||
if (p == NULL)
|
||||
return -1;
|
||||
free(*bufp);
|
||||
*bufp = *fnamep = tail = p;
|
||||
*bufp = *fnamep = tail = vim_strsave((char_u *)".");
|
||||
*fnamelen = 1;
|
||||
} else {
|
||||
while (tail > s && !after_pathsep(s, tail))
|
||||
@ -19645,23 +19612,19 @@ repeat:
|
||||
s = p + 1;
|
||||
/* find end of substitution */
|
||||
p = vim_strchr(s, sep);
|
||||
if (p != NULL) {
|
||||
sub = vim_strnsave(s, (int)(p - s));
|
||||
str = vim_strnsave(*fnamep, *fnamelen);
|
||||
if (sub != NULL && str != NULL) {
|
||||
*usedlen = (int)(p + 1 - src);
|
||||
s = do_string_sub(str, pat, sub, flags);
|
||||
if (s != NULL) {
|
||||
*fnamep = s;
|
||||
*fnamelen = (int)STRLEN(s);
|
||||
free(*bufp);
|
||||
*bufp = s;
|
||||
didit = TRUE;
|
||||
}
|
||||
}
|
||||
free(sub);
|
||||
free(str);
|
||||
sub = vim_strnsave(s, (int)(p - s));
|
||||
str = vim_strnsave(*fnamep, *fnamelen);
|
||||
*usedlen = (int)(p + 1 - src);
|
||||
s = do_string_sub(str, pat, sub, flags);
|
||||
if (s != NULL) {
|
||||
*fnamep = s;
|
||||
*fnamelen = (int)STRLEN(s);
|
||||
free(*bufp);
|
||||
*bufp = s;
|
||||
didit = TRUE;
|
||||
}
|
||||
free(sub);
|
||||
free(str);
|
||||
free(pat);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
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);
|
||||
}
|
||||
// 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)
|
||||
|
@ -1920,8 +1920,6 @@ void ex_argedit(exarg_T *eap)
|
||||
if (i == ARGCOUNT) {
|
||||
/* Can't find it, add it to the argument list. */
|
||||
s = vim_strsave(eap->arg);
|
||||
if (s == NULL)
|
||||
return;
|
||||
i = alist_add_list(1, &s,
|
||||
eap->addr_count > 0 ? (int)eap->line2 : curwin->w_arg_idx + 1);
|
||||
curwin->w_arg_idx = i;
|
||||
@ -2252,8 +2250,8 @@ void *cookie;
|
||||
/* Make a copy of 'runtimepath'. Invoking the callback may change the
|
||||
* value. */
|
||||
rtp_copy = vim_strsave(p_rtp);
|
||||
buf = xmalloc(MAXPATHL);
|
||||
if (rtp_copy != NULL) {
|
||||
buf = xmallocz(MAXPATHL);
|
||||
{
|
||||
if (p_verbose > 1 && name != NULL) {
|
||||
verbose_enter();
|
||||
smsg((char_u *)_("Searching for \"%s\" in \"%s\""),
|
||||
@ -2594,10 +2592,8 @@ do_source (
|
||||
p = string_convert(&cookie.conv, firstline + 3, NULL);
|
||||
if (p == NULL)
|
||||
p = vim_strsave(firstline + 3);
|
||||
if (p != NULL) {
|
||||
free(firstline);
|
||||
firstline = p;
|
||||
}
|
||||
free(firstline);
|
||||
firstline = p;
|
||||
}
|
||||
|
||||
#ifdef STARTUPTIME
|
||||
@ -3483,8 +3479,6 @@ static char_u **find_locales(void)
|
||||
while (loc != NULL) {
|
||||
ga_grow(&locales_ga, 1);
|
||||
loc = vim_strsave(loc);
|
||||
if (loc == NULL)
|
||||
break;
|
||||
|
||||
((char_u **)locales_ga.ga_data)[locales_ga.ga_len++] = loc;
|
||||
loc = (char_u *)strtok(NULL, "\n");
|
||||
|
@ -721,11 +721,6 @@ int flags;
|
||||
/* 3. Make a copy of the command so we can mess with it. */
|
||||
else if (cmdline_copy == NULL) {
|
||||
next_cmdline = vim_strsave(next_cmdline);
|
||||
if (next_cmdline == NULL) {
|
||||
EMSG(_(e_outofmem));
|
||||
retval = FAIL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
cmdline_copy = next_cmdline;
|
||||
|
||||
@ -4299,10 +4294,6 @@ static int uc_add_command(char_u *name, size_t name_len, char_u *rep, long argt,
|
||||
if (rep_buf == NULL) {
|
||||
/* Can't replace termcodes - try using the string as is */
|
||||
rep_buf = vim_strsave(rep);
|
||||
|
||||
/* Give up if out of memory */
|
||||
if (rep_buf == NULL)
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/* get address of growarray: global or in curbuf */
|
||||
@ -4349,8 +4340,7 @@ static int uc_add_command(char_u *name, size_t name_len, char_u *rep, long argt,
|
||||
if (cmp != 0) {
|
||||
ga_grow(gap, 1);
|
||||
|
||||
if ((p = vim_strnsave(name, (int)name_len)) == NULL)
|
||||
goto fail;
|
||||
p = vim_strnsave(name, (int)name_len);
|
||||
|
||||
cmd = USER_CMD_GA(gap, i);
|
||||
memmove(cmd + 1, cmd, (gap->ga_len - i) * sizeof(ucmd_T));
|
||||
@ -5256,12 +5246,11 @@ static void ex_colorscheme(exarg_T *eap)
|
||||
char_u *expr = vim_strsave((char_u *)"g:colors_name");
|
||||
char_u *p = NULL;
|
||||
|
||||
if (expr != NULL) {
|
||||
++emsg_off;
|
||||
p = eval_to_string(expr, NULL, FALSE);
|
||||
--emsg_off;
|
||||
free(expr);
|
||||
}
|
||||
++emsg_off;
|
||||
p = eval_to_string(expr, NULL, FALSE);
|
||||
--emsg_off;
|
||||
free(expr);
|
||||
|
||||
if (p != NULL) {
|
||||
MSG(p);
|
||||
free(p);
|
||||
@ -7994,8 +7983,6 @@ char_u *expand_sfile(char_u *arg)
|
||||
char_u *p;
|
||||
|
||||
result = vim_strsave(arg);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
||||
for (p = result; *p; ) {
|
||||
if (STRNCMP(p, "<sfile>", 7) != 0)
|
||||
|
@ -250,11 +250,7 @@ int cause_errthrow(char_u *mesg, int severe, int *ignore)
|
||||
EMSG(_(e_outofmem));
|
||||
} else {
|
||||
elem->msg = vim_strsave(mesg);
|
||||
if (elem->msg == NULL) {
|
||||
free(elem);
|
||||
suppress_errthrow = TRUE;
|
||||
EMSG(_(e_outofmem));
|
||||
} else {
|
||||
{
|
||||
elem->next = NULL;
|
||||
elem->throw_msg = NULL;
|
||||
*plist = elem;
|
||||
@ -402,15 +398,11 @@ char_u *get_exception_string(void *value, int type, char_u *cmdname, int *should
|
||||
cmdlen = (int)STRLEN(cmdname);
|
||||
ret = vim_strnsave((char_u *)"Vim(",
|
||||
4 + cmdlen + 2 + (int)STRLEN(mesg));
|
||||
if (ret == NULL)
|
||||
return ret;
|
||||
STRCPY(&ret[4], cmdname);
|
||||
STRCPY(&ret[4 + cmdlen], "):");
|
||||
val = ret + 4 + cmdlen + 2;
|
||||
} else {
|
||||
ret = vim_strnsave((char_u *)"Vim:", 4 + (int)STRLEN(mesg));
|
||||
if (ret == NULL)
|
||||
return ret;
|
||||
val = ret + 4;
|
||||
}
|
||||
|
||||
@ -493,11 +485,6 @@ static int throw_exception(void *value, int type, char_u *cmdname)
|
||||
excp->type = type;
|
||||
excp->throw_name = vim_strsave(sourcing_name == NULL
|
||||
? (char_u *)"" : sourcing_name);
|
||||
if (excp->throw_name == NULL) {
|
||||
if (should_free)
|
||||
free(excp->value);
|
||||
goto nomem;
|
||||
}
|
||||
excp->throw_lnum = sourcing_lnum;
|
||||
|
||||
if (p_verbose >= 13 || debug_break_level > 0) {
|
||||
|
@ -1196,8 +1196,7 @@ getcmdline (
|
||||
|
||||
/* save current command string so it can be restored later */
|
||||
if (lookfor == NULL) {
|
||||
if ((lookfor = vim_strsave(ccline.cmdbuff)) == NULL)
|
||||
goto cmdline_not_changed;
|
||||
lookfor = vim_strsave(ccline.cmdbuff);
|
||||
lookfor[ccline.cmdpos] = NUL;
|
||||
}
|
||||
|
||||
@ -4510,8 +4509,7 @@ add_to_history (
|
||||
/* Store the separator after the NUL of the string. */
|
||||
len = (int)STRLEN(new_entry);
|
||||
hisptr->hisstr = vim_strnsave(new_entry, len + 2);
|
||||
if (hisptr->hisstr != NULL)
|
||||
hisptr->hisstr[len + 1] = sep;
|
||||
hisptr->hisstr[len + 1] = sep;
|
||||
|
||||
hisptr->hisnum = ++hisnum[histype];
|
||||
hisptr->viminfo = FALSE;
|
||||
|
@ -322,8 +322,6 @@ vim_findfile_init (
|
||||
search_ctx->ffsc_start_dir = FullName_save(ff_expand_buffer, FALSE);
|
||||
} else
|
||||
search_ctx->ffsc_start_dir = vim_strnsave(rel_fname, len);
|
||||
if (search_ctx->ffsc_start_dir == NULL)
|
||||
goto error_return;
|
||||
if (*++path != NUL)
|
||||
++path;
|
||||
} else if (*path == NUL || !vim_isAbsName(path)) {
|
||||
@ -344,8 +342,6 @@ vim_findfile_init (
|
||||
goto error_return;
|
||||
|
||||
search_ctx->ffsc_start_dir = vim_strsave(ff_expand_buffer);
|
||||
if (search_ctx->ffsc_start_dir == NULL)
|
||||
goto error_return;
|
||||
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
/* A path that starts with "/dir" is relative to the drive, not to the
|
||||
@ -458,9 +454,6 @@ vim_findfile_init (
|
||||
}
|
||||
ff_expand_buffer[len] = NUL;
|
||||
search_ctx->ffsc_wc_path = vim_strsave(ff_expand_buffer);
|
||||
|
||||
if (search_ctx->ffsc_wc_path == NULL)
|
||||
goto error_return;
|
||||
} else
|
||||
search_ctx->ffsc_fix_path = vim_strsave(path);
|
||||
|
||||
@ -469,8 +462,6 @@ vim_findfile_init (
|
||||
* This is needed if the parameter path is fully qualified.
|
||||
*/
|
||||
search_ctx->ffsc_start_dir = vim_strsave(search_ctx->ffsc_fix_path);
|
||||
if (search_ctx->ffsc_start_dir == NULL)
|
||||
goto error_return;
|
||||
search_ctx->ffsc_fix_path[0] = NUL;
|
||||
}
|
||||
|
||||
@ -536,11 +527,7 @@ vim_findfile_init (
|
||||
goto error_return;
|
||||
|
||||
ff_push(search_ctx, sptr);
|
||||
|
||||
search_ctx->ffsc_file_to_search = vim_strsave(filename);
|
||||
if (search_ctx->ffsc_file_to_search == NULL)
|
||||
goto error_return;
|
||||
|
||||
return search_ctx;
|
||||
|
||||
error_return:
|
||||
@ -1070,10 +1057,6 @@ static ff_visited_list_hdr_T *ff_get_visited_list(char_u *filename, ff_visited_l
|
||||
|
||||
retptr->ffvl_visited_list = NULL;
|
||||
retptr->ffvl_filename = vim_strsave(filename);
|
||||
if (retptr->ffvl_filename == NULL) {
|
||||
free(retptr);
|
||||
return NULL;
|
||||
}
|
||||
retptr->ffvl_next = *list_headp;
|
||||
*list_headp = retptr;
|
||||
|
||||
@ -1185,9 +1168,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u *
|
||||
*/
|
||||
static ff_stack_T *ff_create_stack_element(char_u *fix_part, char_u *wc_part, int level, int star_star_empty)
|
||||
{
|
||||
ff_stack_T *new;
|
||||
|
||||
new = (ff_stack_T *)alloc((unsigned)sizeof(ff_stack_T));
|
||||
ff_stack_T *new = xmalloc(sizeof(ff_stack_T));
|
||||
|
||||
new->ffs_prev = NULL;
|
||||
new->ffs_filearray = NULL;
|
||||
@ -1206,13 +1187,6 @@ static ff_stack_T *ff_create_stack_element(char_u *fix_part, char_u *wc_part, in
|
||||
wc_part = (char_u *)"";
|
||||
new->ffs_wc_path = vim_strsave(wc_part);
|
||||
|
||||
if (new->ffs_fix_path == NULL
|
||||
|| new->ffs_wc_path == NULL
|
||||
) {
|
||||
ff_free_stack_element(new);
|
||||
new = NULL;
|
||||
}
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
@ -1429,10 +1403,6 @@ find_file_in_path_option (
|
||||
|
||||
free(ff_file_to_find);
|
||||
ff_file_to_find = vim_strsave(NameBuff);
|
||||
if (ff_file_to_find == NULL) { /* out of memory */
|
||||
file_name = NULL;
|
||||
goto theend;
|
||||
}
|
||||
}
|
||||
|
||||
rel_to_curdir = (ff_file_to_find[0] == '.'
|
||||
|
@ -2138,11 +2138,9 @@ static char_u *next_fenc(char_u **pp)
|
||||
} else {
|
||||
r = vim_strnsave(*pp, (int)(p - *pp));
|
||||
*pp = p + 1;
|
||||
if (r != NULL) {
|
||||
p = enc_canonize(r);
|
||||
free(r);
|
||||
r = p;
|
||||
}
|
||||
p = enc_canonize(r);
|
||||
free(r);
|
||||
r = p;
|
||||
}
|
||||
if (r == NULL) { /* out of memory */
|
||||
r = (char_u *)"";
|
||||
@ -5037,7 +5035,7 @@ static int move_lines(buf_T *frombuf, buf_T *tobuf)
|
||||
curbuf = tobuf;
|
||||
for (lnum = 1; lnum <= frombuf->b_ml.ml_line_count; ++lnum) {
|
||||
p = vim_strsave(ml_get_buf(frombuf, lnum, FALSE));
|
||||
if (p == NULL || ml_append(lnum - 1, p, 0, FALSE) == FAIL) {
|
||||
if (ml_append(lnum - 1, p, 0, FALSE) == FAIL) {
|
||||
free(p);
|
||||
retval = FAIL;
|
||||
break;
|
||||
@ -6037,8 +6035,6 @@ static int au_new_group(char_u *name)
|
||||
}
|
||||
|
||||
AUGROUP_NAME(i) = vim_strsave(name);
|
||||
if (AUGROUP_NAME(i) == NULL)
|
||||
return AUGROUP_ERROR;
|
||||
if (i == augroups.ga_len)
|
||||
++augroups.ga_len;
|
||||
}
|
||||
@ -6242,18 +6238,14 @@ char_u *au_event_disable(char *what)
|
||||
char_u *save_ei;
|
||||
|
||||
save_ei = vim_strsave(p_ei);
|
||||
if (save_ei != NULL) {
|
||||
new_ei = vim_strnsave(p_ei, (int)(STRLEN(p_ei) + STRLEN(what)));
|
||||
if (new_ei != NULL) {
|
||||
if (*what == ',' && *p_ei == NUL)
|
||||
STRCPY(new_ei, what + 1);
|
||||
else
|
||||
STRCAT(new_ei, what);
|
||||
set_string_option_direct((char_u *)"ei", -1, new_ei,
|
||||
OPT_FREE, SID_NONE);
|
||||
free(new_ei);
|
||||
}
|
||||
}
|
||||
new_ei = vim_strnsave(p_ei, (int)(STRLEN(p_ei) + STRLEN(what)));
|
||||
if (*what == ',' && *p_ei == NUL)
|
||||
STRCPY(new_ei, what + 1);
|
||||
else
|
||||
STRCAT(new_ei, what);
|
||||
set_string_option_direct((char_u *)"ei", -1, new_ei, OPT_FREE, SID_NONE);
|
||||
free(new_ei);
|
||||
|
||||
return save_ei;
|
||||
}
|
||||
|
||||
@ -6404,7 +6396,7 @@ void do_autocmd(char_u *arg, int forceit)
|
||||
* Find the group ID in a ":autocmd" or ":doautocmd" argument.
|
||||
* The "argp" argument is advanced to the following argument.
|
||||
*
|
||||
* Returns the group ID, AUGROUP_ERROR for error (out of memory).
|
||||
* Returns the group ID or AUGROUP_ALL.
|
||||
*/
|
||||
static int au_get_grouparg(char_u **argp)
|
||||
{
|
||||
@ -6416,8 +6408,6 @@ static int au_get_grouparg(char_u **argp)
|
||||
p = skiptowhite(arg);
|
||||
if (p > arg) {
|
||||
group_name = vim_strnsave(arg, (int)(p - arg));
|
||||
if (group_name == NULL) /* out of memory */
|
||||
return AUGROUP_ERROR;
|
||||
group = au_find_group(group_name);
|
||||
if (group == AUGROUP_ERROR)
|
||||
group = AUGROUP_ALL; /* no match, use all groups */
|
||||
@ -6587,10 +6577,6 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd,
|
||||
ap = (AutoPat *)alloc((unsigned)sizeof(AutoPat));
|
||||
ap->pat = vim_strnsave(pat, patlen);
|
||||
ap->patlen = patlen;
|
||||
if (ap->pat == NULL) {
|
||||
free(ap);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (is_buflocal) {
|
||||
ap->buflocal_nr = buflocal_nr;
|
||||
@ -6628,10 +6614,6 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd,
|
||||
ac = (AutoCmd *)alloc((unsigned)sizeof(AutoCmd));
|
||||
ac->cmd = vim_strsave(cmd);
|
||||
ac->scriptID = current_SID;
|
||||
if (ac->cmd == NULL) {
|
||||
free(ac);
|
||||
return FAIL;
|
||||
}
|
||||
ac->next = NULL;
|
||||
*prev_ac = ac;
|
||||
ac->nested = nested;
|
||||
@ -7542,8 +7524,7 @@ int has_autocmd(event_T event, char_u *sfname, buf_T *buf)
|
||||
* autocommand patterns portable between Unix and MS-DOS.
|
||||
*/
|
||||
sfname = vim_strsave(sfname);
|
||||
if (sfname != NULL)
|
||||
forward_slash(sfname);
|
||||
forward_slash(sfname);
|
||||
forward_slash(fname);
|
||||
#endif
|
||||
|
||||
@ -7681,8 +7662,6 @@ int au_exists(char_u *arg)
|
||||
|
||||
/* Make a copy so that we can change the '#' chars to a NUL. */
|
||||
arg_save = vim_strsave(arg);
|
||||
if (arg_save == NULL)
|
||||
return FALSE;
|
||||
p = vim_strchr(arg_save, '#');
|
||||
if (p != NULL)
|
||||
*p++ = NUL;
|
||||
|
@ -2636,7 +2636,6 @@ do_map (
|
||||
char_u *p;
|
||||
int n;
|
||||
int len = 0; /* init for GCC */
|
||||
char_u *newstr;
|
||||
int hasarg;
|
||||
int haskey;
|
||||
int did_it = FALSE;
|
||||
@ -2979,13 +2978,8 @@ do_map (
|
||||
} else { /* new rhs for existing entry */
|
||||
mp->m_mode &= ~mode; /* remove mode bits */
|
||||
if (mp->m_mode == 0 && !did_it) { /* reuse entry */
|
||||
newstr = vim_strsave(rhs);
|
||||
if (newstr == NULL) {
|
||||
retval = 4; /* no mem */
|
||||
goto theend;
|
||||
}
|
||||
free(mp->m_str);
|
||||
mp->m_str = newstr;
|
||||
mp->m_str = vim_strsave(rhs);
|
||||
free(mp->m_orig_str);
|
||||
mp->m_orig_str = vim_strsave(orig_rhs);
|
||||
mp->m_noremap = noremap;
|
||||
@ -3057,14 +3051,6 @@ do_map (
|
||||
mp->m_keys = vim_strsave(keys);
|
||||
mp->m_str = vim_strsave(rhs);
|
||||
mp->m_orig_str = vim_strsave(orig_rhs);
|
||||
if (mp->m_keys == NULL || mp->m_str == NULL) {
|
||||
free(mp->m_keys);
|
||||
free(mp->m_str);
|
||||
free(mp->m_orig_str);
|
||||
free(mp);
|
||||
retval = 4; /* no mem */
|
||||
goto theend;
|
||||
}
|
||||
mp->m_keylen = (int)STRLEN(mp->m_keys);
|
||||
mp->m_noremap = noremap;
|
||||
mp->m_nowait = nowait;
|
||||
@ -3328,11 +3314,9 @@ showmap (
|
||||
/* Remove escaping of CSI, because "m_str" is in a format to be used
|
||||
* as typeahead. */
|
||||
char_u *s = vim_strsave(mp->m_str);
|
||||
if (s != NULL) {
|
||||
vim_unescape_csi(s);
|
||||
msg_outtrans_special(s, FALSE);
|
||||
free(s);
|
||||
}
|
||||
vim_unescape_csi(s);
|
||||
msg_outtrans_special(s, FALSE);
|
||||
free(s);
|
||||
}
|
||||
if (p_verbose > 0)
|
||||
last_set_msg(mp->m_script_ID);
|
||||
@ -3778,8 +3762,6 @@ eval_map_expr (
|
||||
/* Remove escaping of CSI, because "str" is in a format to be used as
|
||||
* typeahead. */
|
||||
expr = vim_strsave(str);
|
||||
if (expr == NULL)
|
||||
return NULL;
|
||||
vim_unescape_csi(expr);
|
||||
|
||||
save_cmd = save_cmdline_alloc();
|
||||
@ -4325,10 +4307,8 @@ void add_map(char_u *map, int mode)
|
||||
|
||||
p_cpo = (char_u *)""; /* Allow <> notation */
|
||||
s = vim_strsave(map);
|
||||
if (s != NULL) {
|
||||
(void)do_map(0, s, mode, FALSE);
|
||||
free(s);
|
||||
}
|
||||
(void)do_map(0, s, mode, FALSE);
|
||||
free(s);
|
||||
p_cpo = cpo_save;
|
||||
}
|
||||
#endif
|
||||
|
@ -1633,10 +1633,7 @@ static void cs_fill_results(char *tagstr, int totmatches, int *nummatches_a, cha
|
||||
if (strcmp(cntx, "<global>") == 0)
|
||||
cntxts[totsofar] = NULL;
|
||||
else {
|
||||
/* note: if vim_strsave returns NULL, then the context
|
||||
* will be "<global>", which is misleading.
|
||||
*/
|
||||
cntxts[totsofar] = (char *)vim_strsave((char_u *)cntx);
|
||||
cntxts[totsofar] = xstrdup(cntx);
|
||||
}
|
||||
|
||||
totsofar++;
|
||||
@ -2110,7 +2107,7 @@ static char *cs_resolve_file(int i, char *name)
|
||||
* cscope output. */
|
||||
fullname = (char *)concat_fnames(csdir, (char_u *)name, TRUE);
|
||||
} else {
|
||||
fullname = (char *)vim_strsave((char_u *)name);
|
||||
fullname = xstrdup(name);
|
||||
}
|
||||
|
||||
free(csdir);
|
||||
|
@ -1428,8 +1428,8 @@ scripterror:
|
||||
|
||||
/* Add the file to the global argument list. */
|
||||
ga_grow(&global_alist.al_ga, 1);
|
||||
if ((p = vim_strsave((char_u *)argv[0])) == NULL)
|
||||
mch_exit(2);
|
||||
p = vim_strsave((char_u *)argv[0]);
|
||||
|
||||
if (parmp->diff_mode && os_isdir(p) && GARGCOUNT > 0
|
||||
&& !os_isdir(alist_name(&GARGLIST[0]))) {
|
||||
char_u *r;
|
||||
|
@ -606,8 +606,7 @@ static char_u *mark_line(pos_T *mp, int lead_len)
|
||||
if (mp->lnum == 0 || mp->lnum > curbuf->b_ml.ml_line_count)
|
||||
return vim_strsave((char_u *)"-invalid-");
|
||||
s = vim_strnsave(skipwhite(ml_get(mp->lnum)), (int)Columns);
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Truncate the line to fit it in the window */
|
||||
len = 0;
|
||||
for (p = s; *p != NUL; mb_ptr_adv(p)) {
|
||||
|
@ -2607,8 +2607,8 @@ int ml_replace(linenr_T lnum, char_u *line, int copy)
|
||||
if (curbuf->b_ml.ml_mfp == NULL && open_buffer(FALSE, NULL, 0) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
if (copy && (line = vim_strsave(line)) == NULL) /* allocate memory */
|
||||
return FAIL;
|
||||
if (copy)
|
||||
line = vim_strsave(line);
|
||||
if (curbuf->b_ml.ml_line_lnum != lnum) /* other line buffered */
|
||||
ml_flush_line(curbuf); /* flush it */
|
||||
else if (curbuf->b_ml.ml_flags & ML_LINE_DIRTY) /* same line allocated */
|
||||
|
@ -192,7 +192,7 @@ char *xstpncpy(char *restrict dst, const char *restrict src, size_t maxlen)
|
||||
}
|
||||
}
|
||||
|
||||
char * xstrdup(const char *str)
|
||||
char *xstrdup(const char *str)
|
||||
{
|
||||
char *ret = strdup(str);
|
||||
|
||||
|
@ -308,8 +308,6 @@ add_menu_path (
|
||||
|
||||
/* Make a copy so we can stuff around with it, since it could be const */
|
||||
path_name = vim_strsave(menu_path);
|
||||
if (path_name == NULL)
|
||||
return FAIL;
|
||||
menup = &root_menu;
|
||||
parent = NULL;
|
||||
name = path_name;
|
||||
@ -728,8 +726,6 @@ static int show_menus(char_u *path_name, int modes)
|
||||
|
||||
menu = root_menu;
|
||||
name = path_name = vim_strsave(path_name);
|
||||
if (path_name == NULL)
|
||||
return FAIL;
|
||||
|
||||
/* First, find the (sub)menu with the given name */
|
||||
while (*name) {
|
||||
@ -1168,7 +1164,7 @@ get_menu_cmd_modes (
|
||||
|
||||
/*
|
||||
* Modify a menu name starting with "PopUp" to include the mode character.
|
||||
* Returns the name in allocated memory (NULL for failure).
|
||||
* Returns the name in allocated memory.
|
||||
*/
|
||||
static char_u *popup_mode_name(char_u *name, int idx)
|
||||
{
|
||||
@ -1176,10 +1172,9 @@ static char_u *popup_mode_name(char_u *name, int idx)
|
||||
int len = (int)STRLEN(name);
|
||||
|
||||
p = vim_strnsave(name, len + 1);
|
||||
if (p != NULL) {
|
||||
memmove(p + 6, p + 5, (size_t)(len - 4));
|
||||
p[5] = menu_mode_chars[idx];
|
||||
}
|
||||
memmove(p + 6, p + 5, (size_t)(len - 4));
|
||||
p[5] = menu_mode_chars[idx];
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -1305,8 +1300,6 @@ void ex_emenu(exarg_T *eap)
|
||||
char_u *mode;
|
||||
|
||||
saved_name = vim_strsave(eap->arg);
|
||||
if (saved_name == NULL)
|
||||
return;
|
||||
|
||||
menu = root_menu;
|
||||
name = saved_name;
|
||||
@ -1419,8 +1412,6 @@ vimmenu_T *gui_find_menu(char_u *path_name)
|
||||
menu = root_menu;
|
||||
|
||||
saved_name = vim_strsave(path_name);
|
||||
if (saved_name == NULL)
|
||||
return NULL;
|
||||
|
||||
name = saved_name;
|
||||
while (*name) {
|
||||
@ -1513,23 +1504,21 @@ void ex_menutranslate(exarg_T *eap)
|
||||
ga_grow(&menutrans_ga, 1);
|
||||
tp = (menutrans_T *)menutrans_ga.ga_data;
|
||||
from = vim_strsave(from);
|
||||
if (from != NULL) {
|
||||
from_noamp = menu_text(from, NULL, NULL);
|
||||
to = vim_strnsave(to, (int)(arg - to));
|
||||
if (from_noamp != NULL && to != NULL) {
|
||||
menu_translate_tab_and_shift(from);
|
||||
menu_translate_tab_and_shift(to);
|
||||
menu_unescape_name(from);
|
||||
menu_unescape_name(to);
|
||||
tp[menutrans_ga.ga_len].from = from;
|
||||
tp[menutrans_ga.ga_len].from_noamp = from_noamp;
|
||||
tp[menutrans_ga.ga_len].to = to;
|
||||
++menutrans_ga.ga_len;
|
||||
} else {
|
||||
free(from);
|
||||
free(from_noamp);
|
||||
free(to);
|
||||
}
|
||||
from_noamp = menu_text(from, NULL, NULL);
|
||||
to = vim_strnsave(to, (int)(arg - to));
|
||||
if (from_noamp != NULL) {
|
||||
menu_translate_tab_and_shift(from);
|
||||
menu_translate_tab_and_shift(to);
|
||||
menu_unescape_name(from);
|
||||
menu_unescape_name(to);
|
||||
tp[menutrans_ga.ga_len].from = from;
|
||||
tp[menutrans_ga.ga_len].from_noamp = from_noamp;
|
||||
tp[menutrans_ga.ga_len].to = to;
|
||||
++menutrans_ga.ga_len;
|
||||
} else {
|
||||
free(from);
|
||||
free(from_noamp);
|
||||
free(to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,8 +120,6 @@ open_line (
|
||||
* make a copy of the current line so we can mess with it
|
||||
*/
|
||||
saved_line = vim_strsave(ml_get_curline());
|
||||
if (saved_line == NULL) /* out of memory! */
|
||||
return FALSE;
|
||||
|
||||
if (State & VREPLACE_FLAG) {
|
||||
/*
|
||||
@ -137,8 +135,6 @@ open_line (
|
||||
next_line = vim_strsave(ml_get(curwin->w_cursor.lnum + 1));
|
||||
else
|
||||
next_line = vim_strsave((char_u *)"");
|
||||
if (next_line == NULL) /* out of memory! */
|
||||
goto theend;
|
||||
|
||||
/*
|
||||
* In VREPLACE mode, a NL replaces the rest of the line, and starts
|
||||
@ -918,8 +914,6 @@ open_line (
|
||||
if (State & VREPLACE_FLAG) {
|
||||
/* Put new line in p_extra */
|
||||
p_extra = vim_strsave(ml_get_curline());
|
||||
if (p_extra == NULL)
|
||||
goto theend;
|
||||
|
||||
/* Put back original line */
|
||||
ml_replace(curwin->w_cursor.lnum, next_line, FALSE);
|
||||
@ -1743,9 +1737,6 @@ truncate_line (
|
||||
else
|
||||
newp = vim_strnsave(ml_get(lnum), col);
|
||||
|
||||
if (newp == NULL)
|
||||
return FAIL;
|
||||
|
||||
ml_replace(lnum, newp, FALSE);
|
||||
|
||||
/* mark the buffer as changed and prepare for displaying */
|
||||
@ -2874,13 +2865,11 @@ expand_env_esc (
|
||||
if (p_ssl && var != NULL && vim_strchr(var, '\\') != NULL) {
|
||||
char_u *p = vim_strsave(var);
|
||||
|
||||
if (p != NULL) {
|
||||
if (mustfree)
|
||||
free(var);
|
||||
var = p;
|
||||
mustfree = TRUE;
|
||||
forward_slash(var);
|
||||
}
|
||||
if (mustfree)
|
||||
free(var);
|
||||
var = p;
|
||||
mustfree = TRUE;
|
||||
forward_slash(var);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3033,7 +3022,7 @@ char_u *vim_getenv(char_u *name, int *mustfree)
|
||||
/* check that the result is a directory name */
|
||||
p = vim_strnsave(p, (int)(pend - p));
|
||||
|
||||
if (p != NULL && !os_isdir(p)) {
|
||||
if (!os_isdir(p)) {
|
||||
free(p);
|
||||
p = NULL;
|
||||
} else {
|
||||
|
@ -689,8 +689,6 @@ char_u *get_expr_line(void)
|
||||
/* Make a copy of the expression, because evaluating it may cause it to be
|
||||
* changed. */
|
||||
expr_copy = vim_strsave(expr_line);
|
||||
if (expr_copy == NULL)
|
||||
return NULL;
|
||||
|
||||
/* When we are invoked recursively limit the evaluation to 10 levels.
|
||||
* Then return the string as-is. */
|
||||
@ -2154,17 +2152,15 @@ void op_insert(oparg_T *oap, long count1)
|
||||
if (pre_textlen >= 0
|
||||
&& (ins_len = (long)STRLEN(firstline) - pre_textlen) > 0) {
|
||||
ins_text = vim_strnsave(firstline, (int)ins_len);
|
||||
if (ins_text != NULL) {
|
||||
/* block handled here */
|
||||
if (u_save(oap->start.lnum,
|
||||
(linenr_T)(oap->end.lnum + 1)) == OK)
|
||||
block_insert(oap, ins_text, (oap->op_type == OP_INSERT),
|
||||
&bd);
|
||||
/* block handled here */
|
||||
if (u_save(oap->start.lnum,
|
||||
(linenr_T)(oap->end.lnum + 1)) == OK)
|
||||
block_insert(oap, ins_text, (oap->op_type == OP_INSERT),
|
||||
&bd);
|
||||
|
||||
curwin->w_cursor.col = oap->start.col;
|
||||
check_cursor();
|
||||
free(ins_text);
|
||||
}
|
||||
curwin->w_cursor.col = oap->start.col;
|
||||
check_cursor();
|
||||
free(ins_text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2414,9 +2410,7 @@ int op_yank(oparg_T *oap, int deleting, int mess)
|
||||
break;
|
||||
|
||||
case MLINE:
|
||||
if ((y_current->y_array[y_idx] =
|
||||
vim_strsave(ml_get(lnum))) == NULL)
|
||||
goto fail;
|
||||
y_current->y_array[y_idx] = vim_strsave(ml_get(lnum));
|
||||
break;
|
||||
|
||||
case MCHAR:
|
||||
@ -2547,13 +2541,7 @@ int op_yank(oparg_T *oap, int deleting, int mess)
|
||||
curbuf->b_op_end.col = MAXCOL;
|
||||
}
|
||||
|
||||
|
||||
return OK;
|
||||
|
||||
fail: /* free the allocated lines */
|
||||
free_yank(y_idx + 1);
|
||||
y_current = curr;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
static void yank_copy_line(struct block_def *bd, long y_idx)
|
||||
@ -2699,14 +2687,10 @@ do_put (
|
||||
if (u_save_cursor() == FAIL)
|
||||
goto end;
|
||||
ptr = vim_strsave(ml_get_cursor());
|
||||
if (ptr == NULL)
|
||||
goto end;
|
||||
ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE);
|
||||
free(ptr);
|
||||
|
||||
ptr = vim_strnsave(ml_get_curline(), curwin->w_cursor.col);
|
||||
if (ptr == NULL)
|
||||
goto end;
|
||||
ml_replace(curwin->w_cursor.lnum, ptr, FALSE);
|
||||
++nr_lines;
|
||||
dir = FORWARD;
|
||||
@ -3628,20 +3612,19 @@ static int same_leader(linenr_T lnum, int leader1_len, char_u *leader1_flags, in
|
||||
* The first line has to be saved, only one line can be locked at a time.
|
||||
*/
|
||||
line1 = vim_strsave(ml_get(lnum));
|
||||
if (line1 != NULL) {
|
||||
for (idx1 = 0; vim_iswhite(line1[idx1]); ++idx1)
|
||||
;
|
||||
line2 = ml_get(lnum + 1);
|
||||
for (idx2 = 0; idx2 < leader2_len; ++idx2) {
|
||||
if (!vim_iswhite(line2[idx2])) {
|
||||
if (line1[idx1++] != line2[idx2])
|
||||
break;
|
||||
} else
|
||||
while (vim_iswhite(line1[idx1]))
|
||||
++idx1;
|
||||
}
|
||||
free(line1);
|
||||
for (idx1 = 0; vim_iswhite(line1[idx1]); ++idx1)
|
||||
;
|
||||
line2 = ml_get(lnum + 1);
|
||||
for (idx2 = 0; idx2 < leader2_len; ++idx2) {
|
||||
if (!vim_iswhite(line2[idx2])) {
|
||||
if (line1[idx1++] != line2[idx2])
|
||||
break;
|
||||
} else
|
||||
while (vim_iswhite(line1[idx1]))
|
||||
++idx1;
|
||||
}
|
||||
free(line1);
|
||||
|
||||
return idx2 == leader2_len && idx1 == leader1_len;
|
||||
}
|
||||
|
||||
@ -4773,8 +4756,7 @@ void write_reg_contents_ex(int name, char_u *str, int maxlen, int must_append, i
|
||||
char_u *p, *s;
|
||||
|
||||
p = vim_strnsave(str, (int)len);
|
||||
if (p == NULL)
|
||||
return;
|
||||
|
||||
if (must_append) {
|
||||
s = concat_str(get_expr_line_src(), p);
|
||||
free(p);
|
||||
|
@ -2102,7 +2102,8 @@ void set_init_1(void)
|
||||
p = (char_u *)_(*(char **)options[opt_idx].var);
|
||||
else
|
||||
p = option_expand(opt_idx, NULL);
|
||||
if (p != NULL && (p = vim_strsave(p)) != NULL) {
|
||||
if (p != NULL) {
|
||||
p = vim_strsave(p);
|
||||
*(char_u **)options[opt_idx].var = p;
|
||||
/* VIMEXP
|
||||
* Defaults for all expanded options are currently the same for Vi
|
||||
@ -2291,14 +2292,12 @@ void set_string_default(char *name, char_u *val)
|
||||
int opt_idx;
|
||||
|
||||
p = vim_strsave(val);
|
||||
if (p != NULL) { /* we don't want a NULL */
|
||||
opt_idx = findoption((char_u *)name);
|
||||
if (opt_idx >= 0) {
|
||||
if (options[opt_idx].flags & P_DEF_ALLOCED)
|
||||
free(options[opt_idx].def_val[VI_DEFAULT]);
|
||||
options[opt_idx].def_val[VI_DEFAULT] = p;
|
||||
options[opt_idx].flags |= P_DEF_ALLOCED;
|
||||
}
|
||||
opt_idx = findoption((char_u *)name);
|
||||
if (opt_idx >= 0) {
|
||||
if (options[opt_idx].flags & P_DEF_ALLOCED)
|
||||
free(options[opt_idx].def_val[VI_DEFAULT]);
|
||||
options[opt_idx].def_val[VI_DEFAULT] = p;
|
||||
options[opt_idx].flags |= P_DEF_ALLOCED;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2463,7 +2462,7 @@ void set_init_3(void)
|
||||
p1 = p2 + 1;
|
||||
p = vim_strnsave(p1, (int)(p - p1));
|
||||
}
|
||||
if (p != NULL) {
|
||||
{
|
||||
/*
|
||||
* Default for p_sp is "| tee", for p_srr is ">".
|
||||
* For known shells it is changed here to include stderr.
|
||||
@ -2519,16 +2518,12 @@ void set_helplang_default(char_u *lang)
|
||||
if (options[idx].flags & P_ALLOCED)
|
||||
free_string_option(p_hlg);
|
||||
p_hlg = vim_strsave(lang);
|
||||
if (p_hlg == NULL)
|
||||
p_hlg = empty_option;
|
||||
else {
|
||||
/* zh_CN becomes "cn", zh_TW becomes "tw". */
|
||||
if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) {
|
||||
p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
|
||||
p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
|
||||
}
|
||||
p_hlg[2] = NUL;
|
||||
/* zh_CN becomes "cn", zh_TW becomes "tw". */
|
||||
if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) {
|
||||
p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
|
||||
p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
|
||||
}
|
||||
p_hlg[2] = NUL;
|
||||
options[idx].flags |= P_ALLOCED;
|
||||
}
|
||||
}
|
||||
@ -3754,7 +3749,7 @@ set_string_option_direct (
|
||||
return;
|
||||
|
||||
s = vim_strsave(val);
|
||||
if (s != NULL) {
|
||||
{
|
||||
varp = (char_u **)get_varp_scope(&(options[idx]),
|
||||
both ? OPT_LOCAL : opt_flags);
|
||||
if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
|
||||
@ -3795,9 +3790,8 @@ set_string_option_global (
|
||||
p = (char_u **)GLOBAL_WO(varp);
|
||||
else
|
||||
p = (char_u **)options[opt_idx].var;
|
||||
if (options[opt_idx].indir != PV_NONE
|
||||
&& p != varp
|
||||
&& (s = vim_strsave(*varp)) != NULL) {
|
||||
if (options[opt_idx].indir != PV_NONE && p != varp) {
|
||||
s = vim_strsave(*varp);
|
||||
free_string_option(*p);
|
||||
*p = s;
|
||||
}
|
||||
@ -3824,18 +3818,17 @@ set_string_option (
|
||||
return NULL;
|
||||
|
||||
s = vim_strsave(value);
|
||||
if (s != NULL) {
|
||||
varp = (char_u **)get_varp_scope(&(options[opt_idx]),
|
||||
(opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
|
||||
? (((int)options[opt_idx].indir & PV_BOTH)
|
||||
? OPT_GLOBAL : OPT_LOCAL)
|
||||
: opt_flags);
|
||||
oldval = *varp;
|
||||
*varp = s;
|
||||
if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
|
||||
opt_flags)) == NULL)
|
||||
did_set_option(opt_idx, opt_flags, TRUE);
|
||||
}
|
||||
varp = (char_u **)get_varp_scope(&(options[opt_idx]),
|
||||
(opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
|
||||
? (((int)options[opt_idx].indir & PV_BOTH)
|
||||
? OPT_GLOBAL : OPT_LOCAL)
|
||||
: opt_flags);
|
||||
oldval = *varp;
|
||||
*varp = s;
|
||||
if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
|
||||
opt_flags)) == NULL)
|
||||
did_set_option(opt_idx, opt_flags, TRUE);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -28,10 +28,7 @@ int os_get_usernames(garray_T *users)
|
||||
// pw->pw_name shouldn't be NULL but just in case...
|
||||
if (pw->pw_name != NULL) {
|
||||
ga_grow(users, 1);
|
||||
user = (char *)vim_strsave((char_u*)pw->pw_name);
|
||||
if (user == NULL) {
|
||||
return FAIL;
|
||||
}
|
||||
user = xstrdup(pw->pw_name);
|
||||
((char **)(users->ga_data))[users->ga_len++] = user;
|
||||
}
|
||||
}
|
||||
@ -79,8 +76,7 @@ char *os_get_user_directory(const char *name)
|
||||
pw = getpwnam(name);
|
||||
if (pw != NULL) {
|
||||
// save the string from the static passwd entry into malloced memory
|
||||
char *user_directory = (char *)vim_strsave((char_u *)pw->pw_dir);
|
||||
return user_directory;
|
||||
return vim_strsave(pw->pw_dir);
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
|
@ -1437,10 +1437,9 @@ char_u ***file;
|
||||
|
||||
for (i = 0; i < num_pat; i++) {
|
||||
s = vim_strsave(pat[i]);
|
||||
if (s != NULL)
|
||||
/* Be compatible with expand_filename(): halve the number of
|
||||
* backslashes. */
|
||||
backslash_halve(s);
|
||||
/* Be compatible with expand_filename(): halve the number of
|
||||
* backslashes. */
|
||||
backslash_halve(s);
|
||||
(*file)[i] = s;
|
||||
}
|
||||
*num_file = num_pat;
|
||||
|
@ -296,7 +296,7 @@ void add_pathsep(char_u *p)
|
||||
|
||||
/*
|
||||
* FullName_save - Make an allocated copy of a full file name.
|
||||
* Returns NULL when out of memory.
|
||||
* Returns NULL when fname is NULL.
|
||||
*/
|
||||
char_u *
|
||||
FullName_save (
|
||||
@ -305,20 +305,19 @@ FullName_save (
|
||||
* like a full path name */
|
||||
)
|
||||
{
|
||||
char_u *buf;
|
||||
char_u *new_fname = NULL;
|
||||
|
||||
if (fname == NULL)
|
||||
return NULL;
|
||||
|
||||
buf = alloc((unsigned)MAXPATHL);
|
||||
if (buf != NULL) {
|
||||
if (vim_FullName(fname, buf, MAXPATHL, force) != FAIL)
|
||||
new_fname = vim_strsave(buf);
|
||||
else
|
||||
new_fname = vim_strsave(fname);
|
||||
free(buf);
|
||||
}
|
||||
char_u *buf = xmalloc(MAXPATHL);
|
||||
|
||||
if (vim_FullName(fname, buf, MAXPATHL, force) != FAIL)
|
||||
new_fname = vim_strsave(buf);
|
||||
else
|
||||
new_fname = vim_strsave(fname);
|
||||
free(buf);
|
||||
|
||||
return new_fname;
|
||||
}
|
||||
|
||||
@ -650,8 +649,6 @@ static void expand_path_option(char_u *curdir, garray_T *gap)
|
||||
ga_grow(gap, 1);
|
||||
|
||||
p = vim_strsave(buf);
|
||||
if (p == NULL)
|
||||
break;
|
||||
((char_u **)gap->ga_data)[gap->ga_len++] = p;
|
||||
}
|
||||
|
||||
@ -1137,8 +1134,6 @@ expand_backtick (
|
||||
|
||||
/* Create the command: lop off the backticks. */
|
||||
cmd = vim_strnsave(pat + 1, (int)STRLEN(pat) - 2);
|
||||
if (cmd == NULL)
|
||||
return 0;
|
||||
|
||||
if (*cmd == '=') /* `={expr}`: Expand expression */
|
||||
buffer = eval_to_string(cmd + 1, &p, TRUE);
|
||||
@ -1563,9 +1558,7 @@ char_u *fix_fname(char_u *fname)
|
||||
fname = vim_strsave(fname);
|
||||
|
||||
# ifdef USE_FNAME_CASE
|
||||
if (fname != NULL) {
|
||||
fname_case(fname, 0); /* set correct case for file name */
|
||||
}
|
||||
fname_case(fname, 0); // set correct case for file name
|
||||
# endif
|
||||
|
||||
return fname;
|
||||
|
@ -929,19 +929,14 @@ qf_add_entry (
|
||||
qfp->qf_fnum = bufnum;
|
||||
else
|
||||
qfp->qf_fnum = qf_get_fnum(dir, fname);
|
||||
if ((qfp->qf_text = vim_strsave(mesg)) == NULL) {
|
||||
free(qfp);
|
||||
return FAIL;
|
||||
}
|
||||
qfp->qf_text = vim_strsave(mesg);
|
||||
qfp->qf_lnum = lnum;
|
||||
qfp->qf_col = col;
|
||||
qfp->qf_viscol = vis_col;
|
||||
if (pattern == NULL || *pattern == NUL)
|
||||
if (pattern == NULL || *pattern == NUL) {
|
||||
qfp->qf_pattern = NULL;
|
||||
else if ((qfp->qf_pattern = vim_strsave(pattern)) == NULL) {
|
||||
free(qfp->qf_text);
|
||||
free(qfp);
|
||||
return FAIL;
|
||||
} else {
|
||||
qfp->qf_pattern = vim_strsave(pattern);
|
||||
}
|
||||
qfp->qf_nr = nr;
|
||||
if (type != 1 && !vim_isprintc(type)) /* only printable chars allowed */
|
||||
|
@ -1141,8 +1141,7 @@ char_u *skip_regexp(char_u *startp, int dirc, int magic, char_u **newp)
|
||||
/* change "\?" to "?", make a copy first. */
|
||||
if (*newp == NULL) {
|
||||
*newp = vim_strsave(startp);
|
||||
if (*newp != NULL)
|
||||
p = *newp + (p - startp);
|
||||
p = *newp + (p - startp);
|
||||
}
|
||||
if (*newp != NULL)
|
||||
STRMOVE(p, p + 1);
|
||||
|
@ -2479,8 +2479,6 @@ spell_load_file (
|
||||
|
||||
// Remember the file name, used to reload the file when it's updated.
|
||||
lp->sl_fname = vim_strsave(fname);
|
||||
if (lp->sl_fname == NULL)
|
||||
goto endFAIL;
|
||||
|
||||
// Check for .add.spl.
|
||||
lp->sl_add = strstr((char *)path_tail(fname), SPL_FNAME_ADD) != NULL;
|
||||
@ -3669,8 +3667,6 @@ char_u *did_set_spelllang(win_T *wp)
|
||||
// Make a copy of 'spelllang', the SpellFileMissing autocommands may change
|
||||
// it under our fingers.
|
||||
spl_copy = vim_strsave(wp->w_s->b_p_spl);
|
||||
if (spl_copy == NULL)
|
||||
goto theend;
|
||||
|
||||
wp->w_s->b_cjk = 0;
|
||||
|
||||
@ -3936,11 +3932,9 @@ static void use_midword(slang_T *lp, win_T *wp)
|
||||
// Append multi-byte chars to "b_spell_ismw_mb".
|
||||
n = (int)STRLEN(wp->w_s->b_spell_ismw_mb);
|
||||
bp = vim_strnsave(wp->w_s->b_spell_ismw_mb, n + l);
|
||||
if (bp != NULL) {
|
||||
free(wp->w_s->b_spell_ismw_mb);
|
||||
wp->w_s->b_spell_ismw_mb = bp;
|
||||
vim_strncpy(bp + n, p, l);
|
||||
}
|
||||
free(wp->w_s->b_spell_ismw_mb);
|
||||
wp->w_s->b_spell_ismw_mb = bp;
|
||||
vim_strncpy(bp + n, p, l);
|
||||
}
|
||||
p += l;
|
||||
} else
|
||||
@ -5175,8 +5169,6 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
||||
if (HASHITEM_EMPTY(hash_find(&spin->si_commonwords,
|
||||
items[i]))) {
|
||||
p = vim_strsave(items[i]);
|
||||
if (p == NULL)
|
||||
break;
|
||||
hash_add(&spin->si_commonwords, p);
|
||||
}
|
||||
}
|
||||
@ -8679,8 +8671,6 @@ void spell_suggest(int count)
|
||||
|
||||
// Make a copy of current line since autocommands may free the line.
|
||||
line = vim_strsave(ml_get_curline());
|
||||
if (line == NULL)
|
||||
goto skip;
|
||||
|
||||
// Get the list of suggestions. Limit to 'lines' - 2 or the number in
|
||||
// 'spellsuggest', whatever is smaller.
|
||||
@ -8819,8 +8809,6 @@ void spell_suggest(int count)
|
||||
curwin->w_cursor = prev_cursor;
|
||||
|
||||
spell_find_cleanup(&sug);
|
||||
skip:
|
||||
free(line);
|
||||
}
|
||||
|
||||
// Check if the word at line "lnum" column "col" is required to start with a
|
||||
@ -9064,8 +9052,6 @@ spell_find_suggest (
|
||||
|
||||
// Make a copy of 'spellsuggest', because the expression may change it.
|
||||
sps_copy = vim_strsave(p_sps);
|
||||
if (sps_copy == NULL)
|
||||
return;
|
||||
|
||||
// Loop over the items in 'spellsuggest'.
|
||||
for (p = sps_copy; *p != NUL; ) {
|
||||
@ -11025,13 +11011,11 @@ static void score_comp_sal(suginfo_T *su)
|
||||
// Add the suggestion.
|
||||
sstp = &SUG(su->su_sga, su->su_sga.ga_len);
|
||||
sstp->st_word = vim_strsave(stp->st_word);
|
||||
if (sstp->st_word != NULL) {
|
||||
sstp->st_wordlen = stp->st_wordlen;
|
||||
sstp->st_score = score;
|
||||
sstp->st_altscore = 0;
|
||||
sstp->st_orglen = stp->st_orglen;
|
||||
++su->su_sga.ga_len;
|
||||
}
|
||||
sstp->st_wordlen = stp->st_wordlen;
|
||||
sstp->st_score = score;
|
||||
sstp->st_altscore = 0;
|
||||
sstp->st_orglen = stp->st_orglen;
|
||||
++su->su_sga.ga_len;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -11731,25 +11715,23 @@ add_suggestion (
|
||||
// Add a suggestion.
|
||||
stp = &SUG(*gap, gap->ga_len);
|
||||
stp->st_word = vim_strnsave(goodword, goodlen);
|
||||
if (stp->st_word != NULL) {
|
||||
stp->st_wordlen = goodlen;
|
||||
stp->st_score = score;
|
||||
stp->st_altscore = altscore;
|
||||
stp->st_had_bonus = had_bonus;
|
||||
stp->st_orglen = badlen;
|
||||
stp->st_slang = slang;
|
||||
++gap->ga_len;
|
||||
stp->st_wordlen = goodlen;
|
||||
stp->st_score = score;
|
||||
stp->st_altscore = altscore;
|
||||
stp->st_had_bonus = had_bonus;
|
||||
stp->st_orglen = badlen;
|
||||
stp->st_slang = slang;
|
||||
++gap->ga_len;
|
||||
|
||||
// If we have too many suggestions now, sort the list and keep
|
||||
// the best suggestions.
|
||||
if (gap->ga_len > SUG_MAX_COUNT(su)) {
|
||||
if (maxsf)
|
||||
su->su_sfmaxscore = cleanup_suggestions(gap,
|
||||
su->su_sfmaxscore, SUG_CLEAN_COUNT(su));
|
||||
else
|
||||
su->su_maxscore = cleanup_suggestions(gap,
|
||||
su->su_maxscore, SUG_CLEAN_COUNT(su));
|
||||
}
|
||||
// If we have too many suggestions now, sort the list and keep
|
||||
// the best suggestions.
|
||||
if (gap->ga_len > SUG_MAX_COUNT(su)) {
|
||||
if (maxsf)
|
||||
su->su_sfmaxscore = cleanup_suggestions(gap,
|
||||
su->su_sfmaxscore, SUG_CLEAN_COUNT(su));
|
||||
else
|
||||
su->su_maxscore = cleanup_suggestions(gap,
|
||||
su->su_maxscore, SUG_CLEAN_COUNT(su));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11800,8 +11782,7 @@ static void add_banned(suginfo_T *su, char_u *word)
|
||||
hi = hash_lookup(&su->su_banned, word, hash);
|
||||
if (HASHITEM_EMPTY(hi)) {
|
||||
s = vim_strsave(word);
|
||||
if (s != NULL)
|
||||
hash_add_item(&su->su_banned, hi, s, hash);
|
||||
hash_add_item(&su->su_banned, hi, s, hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,49 +242,45 @@ void vim_strup(char_u *p)
|
||||
/*
|
||||
* Make string "s" all upper-case and return it in allocated memory.
|
||||
* Handles multi-byte characters as well as possible.
|
||||
* Returns NULL when out of memory.
|
||||
*/
|
||||
char_u *strup_save(char_u *orig)
|
||||
{
|
||||
char_u *p;
|
||||
char_u *res;
|
||||
char_u *res = vim_strsave(orig);
|
||||
|
||||
res = p = vim_strsave(orig);
|
||||
char_u *p = res;
|
||||
while (*p != NUL) {
|
||||
int l;
|
||||
|
||||
if (res != NULL)
|
||||
while (*p != NUL) {
|
||||
int l;
|
||||
if (enc_utf8) {
|
||||
int c, uc;
|
||||
int newl;
|
||||
char_u *s;
|
||||
|
||||
if (enc_utf8) {
|
||||
int c, uc;
|
||||
int newl;
|
||||
char_u *s;
|
||||
c = utf_ptr2char(p);
|
||||
uc = utf_toupper(c);
|
||||
|
||||
c = utf_ptr2char(p);
|
||||
uc = utf_toupper(c);
|
||||
|
||||
/* Reallocate string when byte count changes. This is rare,
|
||||
* thus it's OK to do another malloc()/free(). */
|
||||
l = utf_ptr2len(p);
|
||||
newl = utf_char2len(uc);
|
||||
if (newl != l) {
|
||||
s = alloc((unsigned)STRLEN(res) + 1 + newl - l);
|
||||
memmove(s, res, p - res);
|
||||
STRCPY(s + (p - res) + newl, p + l);
|
||||
p = s + (p - res);
|
||||
free(res);
|
||||
res = s;
|
||||
}
|
||||
|
||||
utf_char2bytes(uc, p);
|
||||
p += newl;
|
||||
} else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
|
||||
p += l; /* skip multi-byte character */
|
||||
else {
|
||||
*p = TOUPPER_LOC(*p); /* note that toupper() can be a macro */
|
||||
p++;
|
||||
/* Reallocate string when byte count changes. This is rare,
|
||||
* thus it's OK to do another malloc()/free(). */
|
||||
l = utf_ptr2len(p);
|
||||
newl = utf_char2len(uc);
|
||||
if (newl != l) {
|
||||
s = alloc((unsigned)STRLEN(res) + 1 + newl - l);
|
||||
memmove(s, res, p - res);
|
||||
STRCPY(s + (p - res) + newl, p + l);
|
||||
p = s + (p - res);
|
||||
free(res);
|
||||
res = s;
|
||||
}
|
||||
|
||||
utf_char2bytes(uc, p);
|
||||
p += newl;
|
||||
} else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
|
||||
p += l; /* skip multi-byte character */
|
||||
else {
|
||||
*p = TOUPPER_LOC(*p); /* note that toupper() can be a macro */
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -4113,8 +4113,6 @@ get_syn_options (
|
||||
if (gname_start == arg)
|
||||
return NULL;
|
||||
gname = vim_strnsave(gname_start, (int)(arg - gname_start));
|
||||
if (gname == NULL)
|
||||
return NULL;
|
||||
if (STRCMP(gname, "NONE") == 0)
|
||||
*opt->sync_idx = NONE_IDX;
|
||||
else {
|
||||
@ -4823,14 +4821,10 @@ static int syn_scl_name2id(char_u *name)
|
||||
*/
|
||||
static int syn_scl_namen2id(char_u *linep, int len)
|
||||
{
|
||||
char_u *name;
|
||||
int id = 0;
|
||||
char_u *name = vim_strnsave(linep, len);
|
||||
int id = syn_scl_name2id(name);
|
||||
free(name);
|
||||
|
||||
name = vim_strnsave(linep, len);
|
||||
if (name != NULL) {
|
||||
id = syn_scl_name2id(name);
|
||||
free(name);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -4846,8 +4840,6 @@ static int syn_check_cluster(char_u *pp, int len)
|
||||
char_u *name;
|
||||
|
||||
name = vim_strnsave(pp, len);
|
||||
if (name == NULL)
|
||||
return 0;
|
||||
|
||||
id = syn_scl_name2id(name);
|
||||
if (id == 0) /* doesn't exist yet */
|
||||
@ -4996,8 +4988,7 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci)
|
||||
return NULL;
|
||||
}
|
||||
/* store the pattern and compiled regexp program */
|
||||
if ((ci->sp_pattern = vim_strnsave(arg + 1, (int)(end - arg - 1))) == NULL)
|
||||
return NULL;
|
||||
ci->sp_pattern = vim_strnsave(arg + 1, (int)(end - arg - 1));
|
||||
|
||||
/* Make 'cpoptions' empty, to avoid the 'l' flag */
|
||||
cpo_save = p_cpo;
|
||||
@ -5139,11 +5130,8 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
|
||||
|
||||
if (!eap->skip) {
|
||||
/* store the pattern and compiled regexp program */
|
||||
if ((curwin->w_s->b_syn_linecont_pat = vim_strnsave(next_arg + 1,
|
||||
(int)(arg_end - next_arg - 1))) == NULL) {
|
||||
finished = TRUE;
|
||||
break;
|
||||
}
|
||||
curwin->w_s->b_syn_linecont_pat =
|
||||
vim_strnsave(next_arg + 1, (int)(arg_end - next_arg - 1));
|
||||
curwin->w_s->b_syn_linecont_ic = curwin->w_s->b_syn_ic;
|
||||
|
||||
/* Make 'cpoptions' empty, to avoid the 'l' flag */
|
||||
@ -5518,24 +5506,22 @@ void ex_syntax(exarg_T *eap)
|
||||
for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); ++subcmd_end)
|
||||
;
|
||||
subcmd_name = vim_strnsave(arg, (int)(subcmd_end - arg));
|
||||
if (subcmd_name != NULL) {
|
||||
if (eap->skip) /* skip error messages for all subcommands */
|
||||
++emsg_skip;
|
||||
for (i = 0;; ++i) {
|
||||
if (subcommands[i].name == NULL) {
|
||||
EMSG2(_("E410: Invalid :syntax subcommand: %s"), subcmd_name);
|
||||
break;
|
||||
}
|
||||
if (STRCMP(subcmd_name, (char_u *)subcommands[i].name) == 0) {
|
||||
eap->arg = skipwhite(subcmd_end);
|
||||
(subcommands[i].func)(eap, FALSE);
|
||||
break;
|
||||
}
|
||||
if (eap->skip) /* skip error messages for all subcommands */
|
||||
++emsg_skip;
|
||||
for (i = 0;; ++i) {
|
||||
if (subcommands[i].name == NULL) {
|
||||
EMSG2(_("E410: Invalid :syntax subcommand: %s"), subcmd_name);
|
||||
break;
|
||||
}
|
||||
if (STRCMP(subcmd_name, (char_u *)subcommands[i].name) == 0) {
|
||||
eap->arg = skipwhite(subcmd_end);
|
||||
(subcommands[i].func)(eap, FALSE);
|
||||
break;
|
||||
}
|
||||
free(subcmd_name);
|
||||
if (eap->skip)
|
||||
--emsg_skip;
|
||||
}
|
||||
free(subcmd_name);
|
||||
if (eap->skip)
|
||||
--emsg_skip;
|
||||
}
|
||||
|
||||
void ex_ownsyntax(exarg_T *eap)
|
||||
@ -6392,10 +6378,6 @@ do_highlight (
|
||||
++linep;
|
||||
free(key);
|
||||
key = vim_strnsave_up(key_start, (int)(linep - key_start));
|
||||
if (key == NULL) {
|
||||
error = TRUE;
|
||||
break;
|
||||
}
|
||||
linep = skipwhite(linep);
|
||||
|
||||
if (STRCMP(key, "NONE") == 0) {
|
||||
@ -6440,10 +6422,7 @@ do_highlight (
|
||||
}
|
||||
free(arg);
|
||||
arg = vim_strnsave(arg_start, (int)(linep - arg_start));
|
||||
if (arg == NULL) {
|
||||
error = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (*linep == '\'')
|
||||
++linep;
|
||||
|
||||
@ -6725,10 +6704,6 @@ do_highlight (
|
||||
arg[off + len] != ','; ++len)
|
||||
;
|
||||
tname = vim_strnsave(arg + off, len);
|
||||
if (tname == NULL) { /* out of memory */
|
||||
error = TRUE;
|
||||
break;
|
||||
}
|
||||
/* lookup the escape sequence for the item */
|
||||
p = get_term_code(tname);
|
||||
free(tname);
|
||||
@ -7410,14 +7385,10 @@ char_u *syn_id2name(int id)
|
||||
*/
|
||||
int syn_namen2id(char_u *linep, int len)
|
||||
{
|
||||
char_u *name;
|
||||
int id = 0;
|
||||
char_u *name = vim_strnsave(linep, len);
|
||||
int id = syn_name2id(name);
|
||||
free(name);
|
||||
|
||||
name = vim_strnsave(linep, len);
|
||||
if (name != NULL) {
|
||||
id = syn_name2id(name);
|
||||
free(name);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -7433,8 +7404,6 @@ int syn_check_group(char_u *pp, int len)
|
||||
char_u *name;
|
||||
|
||||
name = vim_strnsave(pp, len);
|
||||
if (name == NULL)
|
||||
return 0;
|
||||
|
||||
id = syn_name2id(name);
|
||||
if (id == 0) /* doesn't exist yet */
|
||||
|
@ -236,8 +236,7 @@ do_tag (
|
||||
cur_fnum = ptag_entry.cur_fnum;
|
||||
} else {
|
||||
free(ptag_entry.tagname);
|
||||
if ((ptag_entry.tagname = vim_strsave(tag)) == NULL)
|
||||
goto end_do_tag;
|
||||
ptag_entry.tagname = vim_strsave(tag);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
@ -256,13 +255,9 @@ do_tag (
|
||||
--tagstackidx;
|
||||
}
|
||||
|
||||
/*
|
||||
* put the tag name in the tag stack
|
||||
*/
|
||||
if ((tagstack[tagstackidx].tagname = vim_strsave(tag)) == NULL) {
|
||||
curwin->w_tagstacklen = tagstacklen - 1;
|
||||
goto end_do_tag;
|
||||
}
|
||||
// put the tag name in the tag stack
|
||||
tagstack[tagstackidx].tagname = vim_strsave(tag);
|
||||
|
||||
curwin->w_tagstacklen = tagstacklen;
|
||||
|
||||
save_pos = TRUE; /* save the cursor position below */
|
||||
@ -1211,11 +1206,9 @@ find_tags (
|
||||
&& ASCII_ISALPHA(pat[orgpat.len - 2])
|
||||
&& ASCII_ISALPHA(pat[orgpat.len - 1])) {
|
||||
saved_pat = vim_strnsave(pat, orgpat.len - 3);
|
||||
if (saved_pat != NULL) {
|
||||
help_lang_find = &pat[orgpat.len - 2];
|
||||
orgpat.pat = saved_pat;
|
||||
orgpat.len -= 3;
|
||||
}
|
||||
help_lang_find = &pat[orgpat.len - 2];
|
||||
orgpat.pat = saved_pat;
|
||||
orgpat.len -= 3;
|
||||
}
|
||||
}
|
||||
if (p_tl != 0 && orgpat.len > p_tl) /* adjust for 'taglength' */
|
||||
@ -2099,8 +2092,6 @@ get_tagfname (
|
||||
* the value without notifying us. */
|
||||
tnp->tn_tags = vim_strsave((*curbuf->b_p_tags != NUL)
|
||||
? curbuf->b_p_tags : p_tags);
|
||||
if (tnp->tn_tags == NULL)
|
||||
return FAIL;
|
||||
tnp->tn_np = tnp->tn_tags;
|
||||
}
|
||||
|
||||
@ -2435,8 +2426,6 @@ jumpto_tag (
|
||||
retval = NOTAGFILE;
|
||||
free(nofile_fname);
|
||||
nofile_fname = vim_strsave(fname);
|
||||
if (nofile_fname == NULL)
|
||||
nofile_fname = empty_option;
|
||||
goto erret;
|
||||
}
|
||||
|
||||
|
@ -1198,15 +1198,13 @@ static void parse_builtin_tcap(char_u *term)
|
||||
char_u *s, *t;
|
||||
|
||||
s = vim_strsave((char_u *)p->bt_string);
|
||||
if (s != NULL) {
|
||||
for (t = s; *t; ++t)
|
||||
if (term_7to8bit(t)) {
|
||||
*t = term_7to8bit(t);
|
||||
STRCPY(t + 1, t + 2);
|
||||
}
|
||||
term_strings[p->bt_entry] = s;
|
||||
set_term_option_alloced(&term_strings[p->bt_entry]);
|
||||
}
|
||||
for (t = s; *t; ++t)
|
||||
if (term_7to8bit(t)) {
|
||||
*t = term_7to8bit(t);
|
||||
STRCPY(t + 1, t + 2);
|
||||
}
|
||||
term_strings[p->bt_entry] = s;
|
||||
set_term_option_alloced(&term_strings[p->bt_entry]);
|
||||
} else
|
||||
term_strings[p->bt_entry] = (char_u *)p->bt_string;
|
||||
}
|
||||
@ -2970,8 +2968,6 @@ void add_termcode(char_u *name, char_u *string, int flags)
|
||||
}
|
||||
|
||||
s = vim_strsave(string);
|
||||
if (s == NULL)
|
||||
return;
|
||||
|
||||
/* Change leading <Esc>[ to CSI, change <Esc>O to <M-O>. */
|
||||
if (flags != 0 && flags != ATC_FROM_TERM && term_7to8bit(string) != 0) {
|
||||
@ -4313,8 +4309,8 @@ replace_termcodes (
|
||||
* Copy the new string to allocated memory.
|
||||
* If this fails, just return from.
|
||||
*/
|
||||
if ((*bufp = vim_strsave(result)) != NULL)
|
||||
from = *bufp;
|
||||
*bufp = vim_strsave(result);
|
||||
from = *bufp;
|
||||
free(result);
|
||||
return from;
|
||||
}
|
||||
|
@ -700,8 +700,6 @@ char_u *u_get_undo_file_name(char_u *buf_ffname, int reading)
|
||||
/* Use same directory as the ffname,
|
||||
* "dir/name" -> "dir/.name.un~" */
|
||||
undo_file_name = vim_strnsave(ffname, (int)(STRLEN(ffname) + 5));
|
||||
if (undo_file_name == NULL)
|
||||
break;
|
||||
p = path_tail(undo_file_name);
|
||||
memmove(p + 1, p, STRLEN(p) + 1);
|
||||
*p = '.';
|
||||
@ -711,8 +709,6 @@ char_u *u_get_undo_file_name(char_u *buf_ffname, int reading)
|
||||
if (os_isdir(dir_name)) {
|
||||
if (munged_name == NULL) {
|
||||
munged_name = vim_strsave(ffname);
|
||||
if (munged_name == NULL)
|
||||
return NULL;
|
||||
for (p = munged_name; *p != NUL; mb_ptr_adv(p))
|
||||
if (vim_ispathsep(*p))
|
||||
*p = '%';
|
||||
|
Loading…
Reference in New Issue
Block a user