mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Replace 'alloc' with 'xmalloc' in some files.
Files changed: charset.c, buffer.c, diff.c, edit.c, ex_cmds.c, ex_cmds2.c and ex_docmd.c. The remaining alloc's in these files require more careful attention to remove.
This commit is contained in:
parent
1b5217687a
commit
67a157c08d
@ -1843,7 +1843,7 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
|
|||||||
|
|
||||||
/* Make a copy of "pat" and change "^" to "\(^\|[\/]\)". */
|
/* Make a copy of "pat" and change "^" to "\(^\|[\/]\)". */
|
||||||
if (*pat == '^') {
|
if (*pat == '^') {
|
||||||
patc = alloc((unsigned)STRLEN(pat) + 11);
|
patc = xmalloc(STRLEN(pat) + 11);
|
||||||
STRCPY(patc, "\\(^\\|[\\/]\\)");
|
STRCPY(patc, "\\(^\\|[\\/]\\)");
|
||||||
STRCPY(patc + 11, pat + 1);
|
STRCPY(patc + 11, pat + 1);
|
||||||
} else
|
} else
|
||||||
@ -1888,7 +1888,7 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
|
|||||||
if (count == 0) /* no match found, break here */
|
if (count == 0) /* no match found, break here */
|
||||||
break;
|
break;
|
||||||
if (round == 1) {
|
if (round == 1) {
|
||||||
*file = (char_u **)alloc((unsigned)(count * sizeof(char_u *)));
|
*file = xmalloc(count * sizeof(**file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vim_regfree(prog);
|
vim_regfree(prog);
|
||||||
@ -2520,7 +2520,7 @@ fileinfo (
|
|||||||
char_u *buffer;
|
char_u *buffer;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
buffer = alloc(IOSIZE);
|
buffer = xmalloc(IOSIZE);
|
||||||
|
|
||||||
if (fullname > 1) { /* 2 CTRL-G: include buffer number */
|
if (fullname > 1) { /* 2 CTRL-G: include buffer number */
|
||||||
vim_snprintf((char *)buffer, IOSIZE, "buf %d: ", curbuf->b_fnum);
|
vim_snprintf((char *)buffer, IOSIZE, "buf %d: ", curbuf->b_fnum);
|
||||||
@ -4285,7 +4285,7 @@ void write_viminfo_bufferlist(FILE *fp)
|
|||||||
|
|
||||||
/* Allocate room for the file name, lnum and col. */
|
/* Allocate room for the file name, lnum and col. */
|
||||||
#define LINE_BUF_LEN (MAXPATHL + 40)
|
#define LINE_BUF_LEN (MAXPATHL + 40)
|
||||||
line = alloc(LINE_BUF_LEN);
|
line = xmalloc(LINE_BUF_LEN);
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, win)
|
FOR_ALL_TAB_WINDOWS(tp, win)
|
||||||
set_last_cursor(win);
|
set_last_cursor(win);
|
||||||
|
@ -335,13 +335,13 @@ char_u *transstr(char_u *s)
|
|||||||
{
|
{
|
||||||
char_u *res;
|
char_u *res;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
int l, len, c;
|
int l, c;
|
||||||
char_u hexbuf[11];
|
char_u hexbuf[11];
|
||||||
|
|
||||||
if (has_mbyte) {
|
if (has_mbyte) {
|
||||||
// Compute the length of the result, taking account of unprintable
|
// Compute the length of the result, taking account of unprintable
|
||||||
// multi-byte characters.
|
// multi-byte characters.
|
||||||
len = 0;
|
size_t len = 0;
|
||||||
p = s;
|
p = s;
|
||||||
|
|
||||||
while (*p != NUL) {
|
while (*p != NUL) {
|
||||||
@ -353,7 +353,7 @@ char_u *transstr(char_u *s)
|
|||||||
len += l;
|
len += l;
|
||||||
} else {
|
} else {
|
||||||
transchar_hex(hexbuf, c);
|
transchar_hex(hexbuf, c);
|
||||||
len += (int)STRLEN(hexbuf);
|
len += STRLEN(hexbuf);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
l = byte2cells(*p++);
|
l = byte2cells(*p++);
|
||||||
@ -366,9 +366,9 @@ char_u *transstr(char_u *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res = alloc((unsigned)(len + 1));
|
res = xmallocz(len);
|
||||||
} else {
|
} else {
|
||||||
res = alloc((unsigned)(vim_strsize(s) + 1));
|
res = xmallocz(vim_strsize(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
*res = NUL;
|
*res = NUL;
|
||||||
|
@ -462,7 +462,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1,
|
|||||||
/// @return The new diff block.
|
/// @return The new diff block.
|
||||||
static diff_T* diff_alloc_new(tabpage_T *tp, diff_T *dprev, diff_T *dp)
|
static diff_T* diff_alloc_new(tabpage_T *tp, diff_T *dprev, diff_T *dp)
|
||||||
{
|
{
|
||||||
diff_T *dnew = (diff_T *)alloc((unsigned)sizeof(diff_T));
|
diff_T *dnew = xmalloc(sizeof(*dnew));
|
||||||
|
|
||||||
dnew->df_next = dp;
|
dnew->df_next = dp;
|
||||||
if (dprev == NULL) {
|
if (dprev == NULL) {
|
||||||
@ -819,7 +819,7 @@ static void diff_file(char_u *tmp_orig, char_u *tmp_new, char_u *tmp_diff)
|
|||||||
} else {
|
} else {
|
||||||
size_t len = STRLEN(tmp_orig) + STRLEN(tmp_new) + STRLEN(tmp_diff)
|
size_t len = STRLEN(tmp_orig) + STRLEN(tmp_new) + STRLEN(tmp_diff)
|
||||||
+ STRLEN(p_srr) + 27;
|
+ STRLEN(p_srr) + 27;
|
||||||
char_u *cmd = alloc((unsigned)len);
|
char_u *cmd = xmalloc(len);
|
||||||
|
|
||||||
/* We don't want $DIFF_OPTIONS to get in the way. */
|
/* We don't want $DIFF_OPTIONS to get in the way. */
|
||||||
if (os_getenv("DIFF_OPTIONS")) {
|
if (os_getenv("DIFF_OPTIONS")) {
|
||||||
@ -895,7 +895,7 @@ void ex_diffpatch(exarg_T *eap)
|
|||||||
size_t buflen = STRLEN(tmp_orig) + (STRLEN(eap->arg)) + STRLEN(tmp_new) + 16;
|
size_t buflen = STRLEN(tmp_orig) + (STRLEN(eap->arg)) + STRLEN(tmp_new) + 16;
|
||||||
#endif // ifdef UNIX
|
#endif // ifdef UNIX
|
||||||
|
|
||||||
buf = alloc((unsigned)buflen);
|
buf = xmalloc(buflen);
|
||||||
|
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
|
|
||||||
|
33
src/edit.c
33
src/edit.c
@ -1652,11 +1652,9 @@ change_indent (
|
|||||||
if (vcol != (int)curwin->w_virtcol) {
|
if (vcol != (int)curwin->w_virtcol) {
|
||||||
curwin->w_cursor.col = (colnr_T)new_cursor_col;
|
curwin->w_cursor.col = (colnr_T)new_cursor_col;
|
||||||
i = (int)curwin->w_virtcol - vcol;
|
i = (int)curwin->w_virtcol - vcol;
|
||||||
ptr = alloc((unsigned)(i + 1));
|
ptr = xmallocz(i);
|
||||||
|
memset(ptr, ' ', i);
|
||||||
new_cursor_col += i;
|
new_cursor_col += i;
|
||||||
ptr[i] = NUL;
|
|
||||||
while (--i >= 0)
|
|
||||||
ptr[i] = ' ';
|
|
||||||
ins_str(ptr);
|
ins_str(ptr);
|
||||||
vim_free(ptr);
|
vim_free(ptr);
|
||||||
}
|
}
|
||||||
@ -1994,7 +1992,7 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int
|
|||||||
? actual_len : actual_compl_length;
|
? actual_len : actual_compl_length;
|
||||||
|
|
||||||
/* Allocate wide character array for the completion and fill it. */
|
/* Allocate wide character array for the completion and fill it. */
|
||||||
wca = (int *)alloc((unsigned)(actual_len * sizeof(int)));
|
wca = xmalloc(actual_len * sizeof(*wca));
|
||||||
p = str;
|
p = str;
|
||||||
for (i = 0; i < actual_len; ++i)
|
for (i = 0; i < actual_len; ++i)
|
||||||
if (has_mbyte)
|
if (has_mbyte)
|
||||||
@ -2080,8 +2078,8 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int
|
|||||||
/*
|
/*
|
||||||
* Add a match to the list of matches.
|
* Add a match to the list of matches.
|
||||||
* If the given string is already in the list of completions, then return
|
* If the given string is already in the list of completions, then return
|
||||||
* NOTDONE, otherwise add it to the list and return OK. If there is an error,
|
* NOTDONE, otherwise add it to the list and return OK. If there is an error
|
||||||
* maybe because alloc() returns NULL, then FAIL is returned.
|
* then FAIL is returned.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ins_compl_add (
|
ins_compl_add (
|
||||||
@ -2576,7 +2574,7 @@ ins_compl_dictionaries (
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = alloc(LSIZE);
|
buf = xmalloc(LSIZE);
|
||||||
regmatch.regprog = NULL; /* so that we can goto theend */
|
regmatch.regprog = NULL; /* so that we can goto theend */
|
||||||
|
|
||||||
/* If 'infercase' is set, don't use 'smartcase' here */
|
/* If 'infercase' is set, don't use 'smartcase' here */
|
||||||
@ -2589,12 +2587,11 @@ ins_compl_dictionaries (
|
|||||||
* pattern. Also need to double backslashes. */
|
* pattern. Also need to double backslashes. */
|
||||||
if (ctrl_x_mode == CTRL_X_WHOLE_LINE) {
|
if (ctrl_x_mode == CTRL_X_WHOLE_LINE) {
|
||||||
char_u *pat_esc = vim_strsave_escaped(pat, (char_u *)"\\");
|
char_u *pat_esc = vim_strsave_escaped(pat, (char_u *)"\\");
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (pat_esc == NULL)
|
if (pat_esc == NULL)
|
||||||
goto theend;
|
goto theend;
|
||||||
len = STRLEN(pat_esc) + 10;
|
size_t len = STRLEN(pat_esc) + 10;
|
||||||
ptr = alloc((unsigned)len);
|
ptr = xmalloc(len);
|
||||||
vim_snprintf((char *)ptr, len, "^\\s*\\zs\\V%s", pat_esc);
|
vim_snprintf((char *)ptr, len, "^\\s*\\zs\\V%s", pat_esc);
|
||||||
regmatch.regprog = vim_regcomp(ptr, RE_MAGIC);
|
regmatch.regprog = vim_regcomp(ptr, RE_MAGIC);
|
||||||
vim_free(pat_esc);
|
vim_free(pat_esc);
|
||||||
@ -3475,8 +3472,8 @@ static void ins_compl_add_dict(dict_T *dict)
|
|||||||
/*
|
/*
|
||||||
* Add a match to the list of matches from a typeval_T.
|
* Add a match to the list of matches from a typeval_T.
|
||||||
* If the given string is already in the list of completions, then return
|
* If the given string is already in the list of completions, then return
|
||||||
* NOTDONE, otherwise add it to the list and return OK. If there is an error,
|
* NOTDONE, otherwise add it to the list and return OK. If there is an error
|
||||||
* maybe because alloc() returns NULL, then FAIL is returned.
|
* then FAIL is returned.
|
||||||
*/
|
*/
|
||||||
int ins_compl_add_tv(typval_T *tv, int dir)
|
int ins_compl_add_tv(typval_T *tv, int dir)
|
||||||
{
|
{
|
||||||
@ -4342,7 +4339,7 @@ static int ins_complete(int c)
|
|||||||
char_u *prefix = (char_u *)"\\<";
|
char_u *prefix = (char_u *)"\\<";
|
||||||
|
|
||||||
/* we need up to 2 extra chars for the prefix */
|
/* we need up to 2 extra chars for the prefix */
|
||||||
compl_pattern = alloc(quote_meta(NULL, line + compl_col,
|
compl_pattern = xmalloc(quote_meta(NULL, line + compl_col,
|
||||||
compl_length) + 2);
|
compl_length) + 2);
|
||||||
if (!vim_iswordp(line + compl_col)
|
if (!vim_iswordp(line + compl_col)
|
||||||
|| (compl_col > 0
|
|| (compl_col > 0
|
||||||
@ -4386,14 +4383,14 @@ static int ins_complete(int c)
|
|||||||
if (compl_length == 1) {
|
if (compl_length == 1) {
|
||||||
/* Only match word with at least two chars -- webb
|
/* Only match word with at least two chars -- webb
|
||||||
* there's no need to call quote_meta,
|
* there's no need to call quote_meta,
|
||||||
* alloc(7) is enough -- Acevedo
|
* xmalloc(7) is enough -- Acevedo
|
||||||
*/
|
*/
|
||||||
compl_pattern = alloc(7);
|
compl_pattern = xmalloc(7);
|
||||||
STRCPY((char *)compl_pattern, "\\<");
|
STRCPY((char *)compl_pattern, "\\<");
|
||||||
(void)quote_meta(compl_pattern + 2, line + compl_col, 1);
|
(void)quote_meta(compl_pattern + 2, line + compl_col, 1);
|
||||||
STRCAT((char *)compl_pattern, "\\k");
|
STRCAT((char *)compl_pattern, "\\k");
|
||||||
} else {
|
} else {
|
||||||
compl_pattern = alloc(quote_meta(NULL, line + compl_col,
|
compl_pattern = xmalloc(quote_meta(NULL, line + compl_col,
|
||||||
compl_length) + 2);
|
compl_length) + 2);
|
||||||
STRCPY((char *)compl_pattern, "\\<");
|
STRCPY((char *)compl_pattern, "\\<");
|
||||||
(void)quote_meta(compl_pattern + 2, line + compl_col,
|
(void)quote_meta(compl_pattern + 2, line + compl_col,
|
||||||
@ -5875,7 +5872,7 @@ void set_last_insert(int c)
|
|||||||
char_u *s;
|
char_u *s;
|
||||||
|
|
||||||
vim_free(last_insert);
|
vim_free(last_insert);
|
||||||
last_insert = alloc(MB_MAXBYTES * 3 + 5);
|
last_insert = xmalloc(MB_MAXBYTES * 3 + 5);
|
||||||
s = last_insert;
|
s = last_insert;
|
||||||
/* Use the CTRL-V only when entering a special char */
|
/* Use the CTRL-V only when entering a special char */
|
||||||
if (c < ' ' || c == DEL)
|
if (c < ' ' || c == DEL)
|
||||||
|
@ -489,12 +489,8 @@ void ex_sort(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate a buffer that can hold the longest line. */
|
/* Allocate a buffer that can hold the longest line. */
|
||||||
sortbuf1 = alloc((unsigned)maxlen + 1);
|
sortbuf1 = xmalloc(maxlen + 1);
|
||||||
if (sortbuf1 == NULL)
|
sortbuf2 = xmalloc(maxlen + 1);
|
||||||
goto sortend;
|
|
||||||
sortbuf2 = alloc((unsigned)maxlen + 1);
|
|
||||||
if (sortbuf2 == NULL)
|
|
||||||
goto sortend;
|
|
||||||
|
|
||||||
/* Sort the array of line numbers. Note: can't be interrupted! */
|
/* Sort the array of line numbers. Note: can't be interrupted! */
|
||||||
qsort((void *)nrs, count, sizeof(sorti_T), sort_compare);
|
qsort((void *)nrs, count, sizeof(sorti_T), sort_compare);
|
||||||
@ -892,10 +888,7 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out)
|
|||||||
}
|
}
|
||||||
len += (int)STRLEN(prevcmd);
|
len += (int)STRLEN(prevcmd);
|
||||||
}
|
}
|
||||||
if ((t = alloc((unsigned)len)) == NULL) {
|
t = xmalloc(len);
|
||||||
vim_free(newcmd);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*t = NUL;
|
*t = NUL;
|
||||||
if (newcmd != NULL)
|
if (newcmd != NULL)
|
||||||
STRCAT(t, newcmd);
|
STRCAT(t, newcmd);
|
||||||
@ -944,9 +937,7 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out)
|
|||||||
* Add quotes around the command, for shells that need them.
|
* Add quotes around the command, for shells that need them.
|
||||||
*/
|
*/
|
||||||
if (*p_shq != NUL) {
|
if (*p_shq != NUL) {
|
||||||
newcmd = alloc((unsigned)(STRLEN(prevcmd) + 2 * STRLEN(p_shq) + 1));
|
newcmd = xmalloc(STRLEN(prevcmd) + 2 * STRLEN(p_shq) + 1);
|
||||||
if (newcmd == NULL)
|
|
||||||
return;
|
|
||||||
STRCPY(newcmd, p_shq);
|
STRCPY(newcmd, p_shq);
|
||||||
STRCAT(newcmd, prevcmd);
|
STRCAT(newcmd, prevcmd);
|
||||||
STRCAT(newcmd, p_shq);
|
STRCAT(newcmd, p_shq);
|
||||||
@ -1770,8 +1761,7 @@ static void do_viminfo(FILE *fp_in, FILE *fp_out, int flags)
|
|||||||
vir_T vir;
|
vir_T vir;
|
||||||
int merge = FALSE;
|
int merge = FALSE;
|
||||||
|
|
||||||
if ((vir.vir_line = alloc(LSIZE)) == NULL)
|
vir.vir_line = xmalloc(LSIZE);
|
||||||
return;
|
|
||||||
vir.vir_fd = fp_in;
|
vir.vir_fd = fp_in;
|
||||||
vir.vir_conv.vc_type = CONV_NONE;
|
vir.vir_conv.vc_type = CONV_NONE;
|
||||||
|
|
||||||
@ -2378,14 +2368,10 @@ check_overwrite (
|
|||||||
* Use 'shortname' of the current buffer, since there is no buffer
|
* Use 'shortname' of the current buffer, since there is no buffer
|
||||||
* for the written file. */
|
* for the written file. */
|
||||||
if (*p_dir == NUL) {
|
if (*p_dir == NUL) {
|
||||||
dir = alloc(5);
|
dir = xmalloc(5);
|
||||||
if (dir == NULL)
|
|
||||||
return FAIL;
|
|
||||||
STRCPY(dir, ".");
|
STRCPY(dir, ".");
|
||||||
} else {
|
} else {
|
||||||
dir = alloc(MAXPATHL);
|
dir = xmalloc(MAXPATHL);
|
||||||
if (dir == NULL)
|
|
||||||
return FAIL;
|
|
||||||
p = p_dir;
|
p = p_dir;
|
||||||
copy_option_part(&p, dir, MAXPATHL, ",");
|
copy_option_part(&p, dir, MAXPATHL, ",");
|
||||||
}
|
}
|
||||||
@ -2725,24 +2711,19 @@ do_ecmd (
|
|||||||
|
|
||||||
if ((command != NULL || newlnum > (linenr_T)0)
|
if ((command != NULL || newlnum > (linenr_T)0)
|
||||||
&& *get_vim_var_str(VV_SWAPCOMMAND) == NUL) {
|
&& *get_vim_var_str(VV_SWAPCOMMAND) == NUL) {
|
||||||
int len;
|
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
/* Set v:swapcommand for the SwapExists autocommands. */
|
/* Set v:swapcommand for the SwapExists autocommands. */
|
||||||
if (command != NULL)
|
size_t len = (command != NULL) ? STRLEN(command) + 3 : 30;
|
||||||
len = (int)STRLEN(command) + 3;
|
p = xmalloc(len);
|
||||||
else
|
if (command != NULL) {
|
||||||
len = 30;
|
vim_snprintf((char *)p, len, ":%s\r", command);
|
||||||
p = alloc((unsigned)len);
|
} else {
|
||||||
if (p != NULL) {
|
vim_snprintf((char *)p, len, "%" PRId64 "G", (int64_t)newlnum);
|
||||||
if (command != NULL)
|
|
||||||
vim_snprintf((char *)p, len, ":%s\r", command);
|
|
||||||
else
|
|
||||||
vim_snprintf((char *)p, len, "%" PRId64 "G", (int64_t)newlnum);
|
|
||||||
set_vim_var_string(VV_SWAPCOMMAND, p, -1);
|
|
||||||
did_set_swapcommand = TRUE;
|
|
||||||
vim_free(p);
|
|
||||||
}
|
}
|
||||||
|
set_vim_var_string(VV_SWAPCOMMAND, p, -1);
|
||||||
|
did_set_swapcommand = TRUE;
|
||||||
|
vim_free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3861,7 +3842,7 @@ void do_sub(exarg_T *eap)
|
|||||||
* accordingly.
|
* accordingly.
|
||||||
*
|
*
|
||||||
* The new text is built up in new_start[]. It has some extra
|
* The new text is built up in new_start[]. It has some extra
|
||||||
* room to avoid using alloc()/free() too often. new_start_len is
|
* room to avoid using xmalloc()/free() too often. new_start_len is
|
||||||
* the length of the allocated memory at new_start.
|
* the length of the allocated memory at new_start.
|
||||||
*
|
*
|
||||||
* Make a copy of the old line, so it won't be taken away when
|
* Make a copy of the old line, so it won't be taken away when
|
||||||
@ -4178,26 +4159,23 @@ void do_sub(exarg_T *eap)
|
|||||||
/*
|
/*
|
||||||
* Get some space for a temporary buffer to do the
|
* Get some space for a temporary buffer to do the
|
||||||
* substitution into (and some extra space to avoid
|
* substitution into (and some extra space to avoid
|
||||||
* too many calls to alloc()/free()).
|
* too many calls to xmalloc()/free()).
|
||||||
*/
|
*/
|
||||||
new_start_len = needed_len + 50;
|
new_start_len = needed_len + 50;
|
||||||
new_start = (char_u *)xmalloc((size_t)new_start_len);
|
new_start = xmalloc(new_start_len);
|
||||||
*new_start = NUL;
|
*new_start = NUL;
|
||||||
new_end = new_start;
|
new_end = new_start;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Check if the temporary buffer is long enough to do the
|
* Check if the temporary buffer is long enough to do the
|
||||||
* substitution into. If not, make it larger (with a bit
|
* substitution into. If not, make it larger (with a bit
|
||||||
* extra to avoid too many calls to alloc()/free()).
|
* extra to avoid too many calls to xmalloc()/free()).
|
||||||
*/
|
*/
|
||||||
len = (unsigned)STRLEN(new_start);
|
len = (unsigned)STRLEN(new_start);
|
||||||
needed_len += len;
|
needed_len += len;
|
||||||
if (needed_len > (int)new_start_len) {
|
if (needed_len > (int)new_start_len) {
|
||||||
new_start_len = needed_len + 50;
|
new_start_len = needed_len + 50;
|
||||||
p1 = (char_u *) xmalloc((size_t)new_start_len);
|
new_start = xrealloc(new_start, new_start_len);
|
||||||
memmove(p1, new_start, (size_t)(len + 1));
|
|
||||||
vim_free(new_start);
|
|
||||||
new_start = p1;
|
|
||||||
}
|
}
|
||||||
new_end = new_start + len;
|
new_end = new_start + len;
|
||||||
}
|
}
|
||||||
@ -5552,7 +5530,7 @@ helptags_one (
|
|||||||
if (add_help_tags || path_full_compare((char_u *)"$VIMRUNTIME/doc",
|
if (add_help_tags || path_full_compare((char_u *)"$VIMRUNTIME/doc",
|
||||||
dir, FALSE) == kEqualFiles) {
|
dir, FALSE) == kEqualFiles) {
|
||||||
ga_grow(&ga, 1);
|
ga_grow(&ga, 1);
|
||||||
s = alloc(18 + (unsigned)STRLEN(tagfname));
|
s = xmalloc(18 + STRLEN(tagfname));
|
||||||
sprintf((char *)s, "help-tags\t%s\t1\n", tagfname);
|
sprintf((char *)s, "help-tags\t%s\t1\n", tagfname);
|
||||||
((char_u **)ga.ga_data)[ga.ga_len] = s;
|
((char_u **)ga.ga_data)[ga.ga_len] = s;
|
||||||
++ga.ga_len;
|
++ga.ga_len;
|
||||||
@ -5623,11 +5601,7 @@ helptags_one (
|
|||||||
*p2 = '\0';
|
*p2 = '\0';
|
||||||
++p1;
|
++p1;
|
||||||
ga_grow(&ga, 1);
|
ga_grow(&ga, 1);
|
||||||
s = alloc((unsigned)(p2 - p1 + STRLEN(fname) + 2));
|
s = xmalloc((p2 - p1) + STRLEN(fname) + 2);
|
||||||
if (s == NULL) {
|
|
||||||
got_int = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
((char_u **)ga.ga_data)[ga.ga_len] = s;
|
((char_u **)ga.ga_data)[ga.ga_len] = s;
|
||||||
++ga.ga_len;
|
++ga.ga_len;
|
||||||
sprintf((char *)s, "%s\t%s", p1, fname);
|
sprintf((char *)s, "%s\t%s", p1, fname);
|
||||||
@ -6100,9 +6074,7 @@ void ex_sign(exarg_T *eap)
|
|||||||
{ /* ... not currently in a window */
|
{ /* ... not currently in a window */
|
||||||
char_u *cmd;
|
char_u *cmd;
|
||||||
|
|
||||||
cmd = alloc((unsigned)STRLEN(buf->b_fname) + 25);
|
cmd = xmalloc(STRLEN(buf->b_fname) + 25);
|
||||||
if (cmd == NULL)
|
|
||||||
return;
|
|
||||||
sprintf((char *)cmd, "e +%" PRId64 " %s",
|
sprintf((char *)cmd, "e +%" PRId64 " %s",
|
||||||
(int64_t)lnum, buf->b_fname);
|
(int64_t)lnum, buf->b_fname);
|
||||||
do_cmdline_cmd(cmd);
|
do_cmdline_cmd(cmd);
|
||||||
|
@ -676,13 +676,9 @@ debuggy_find (
|
|||||||
|
|
||||||
/* Replace K_SNR in function name with "<SNR>". */
|
/* Replace K_SNR in function name with "<SNR>". */
|
||||||
if (!file && fname[0] == K_SPECIAL) {
|
if (!file && fname[0] == K_SPECIAL) {
|
||||||
name = alloc((unsigned)STRLEN(fname) + 3);
|
name = xmalloc(STRLEN(fname) + 3);
|
||||||
if (name == NULL)
|
STRCPY(name, "<SNR>");
|
||||||
name = fname;
|
STRCPY(name + 5, fname + 3);
|
||||||
else {
|
|
||||||
STRCPY(name, "<SNR>");
|
|
||||||
STRCPY(name + 5, fname + 3);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < gap->ga_len; ++i) {
|
for (i = 0; i < gap->ga_len; ++i) {
|
||||||
@ -1373,9 +1369,7 @@ check_changed_any (
|
|||||||
if (bufcount == 0)
|
if (bufcount == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
bufnrs = (int *)alloc(sizeof(int) * bufcount);
|
bufnrs = xmalloc(sizeof(*bufnrs) * bufcount);
|
||||||
if (bufnrs == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* curbuf */
|
/* curbuf */
|
||||||
bufnrs[bufnum++] = curbuf->b_fnum;
|
bufnrs[bufnum++] = curbuf->b_fnum;
|
||||||
@ -2158,49 +2152,47 @@ void ex_compiler(exarg_T *eap)
|
|||||||
do_cmdline_cmd((char_u *)"echo globpath(&rtp, 'compiler/*.vim')");
|
do_cmdline_cmd((char_u *)"echo globpath(&rtp, 'compiler/*.vim')");
|
||||||
/* ) keep the indenter happy... */
|
/* ) keep the indenter happy... */
|
||||||
} else {
|
} else {
|
||||||
buf = alloc((unsigned)(STRLEN(eap->arg) + 14));
|
buf = xmalloc(STRLEN(eap->arg) + 14);
|
||||||
if (buf != NULL) {
|
if (eap->forceit) {
|
||||||
if (eap->forceit) {
|
/* ":compiler! {name}" sets global options */
|
||||||
/* ":compiler! {name}" sets global options */
|
do_cmdline_cmd((char_u *)
|
||||||
do_cmdline_cmd((char_u *)
|
"command -nargs=* CompilerSet set <args>");
|
||||||
"command -nargs=* CompilerSet set <args>");
|
} else {
|
||||||
} else {
|
/* ":compiler! {name}" sets local options.
|
||||||
/* ":compiler! {name}" sets local options.
|
* To remain backwards compatible "current_compiler" is always
|
||||||
* To remain backwards compatible "current_compiler" is always
|
* used. A user's compiler plugin may set it, the distributed
|
||||||
* used. A user's compiler plugin may set it, the distributed
|
* plugin will then skip the settings. Afterwards set
|
||||||
* plugin will then skip the settings. Afterwards set
|
* "b:current_compiler" and restore "current_compiler".
|
||||||
* "b:current_compiler" and restore "current_compiler".
|
* Explicitly prepend "g:" to make it work in a function. */
|
||||||
* Explicitly prepend "g:" to make it work in a function. */
|
old_cur_comp = get_var_value((char_u *)"g:current_compiler");
|
||||||
old_cur_comp = get_var_value((char_u *)"g:current_compiler");
|
if (old_cur_comp != NULL)
|
||||||
if (old_cur_comp != NULL)
|
old_cur_comp = vim_strsave(old_cur_comp);
|
||||||
old_cur_comp = vim_strsave(old_cur_comp);
|
do_cmdline_cmd((char_u *)
|
||||||
do_cmdline_cmd((char_u *)
|
"command -nargs=* CompilerSet setlocal <args>");
|
||||||
"command -nargs=* CompilerSet setlocal <args>");
|
}
|
||||||
}
|
do_unlet((char_u *)"g:current_compiler", TRUE);
|
||||||
do_unlet((char_u *)"g:current_compiler", TRUE);
|
do_unlet((char_u *)"b:current_compiler", TRUE);
|
||||||
do_unlet((char_u *)"b:current_compiler", TRUE);
|
|
||||||
|
|
||||||
sprintf((char *)buf, "compiler/%s.vim", eap->arg);
|
sprintf((char *)buf, "compiler/%s.vim", eap->arg);
|
||||||
if (source_runtime(buf, TRUE) == FAIL)
|
if (source_runtime(buf, TRUE) == FAIL)
|
||||||
EMSG2(_("E666: compiler not supported: %s"), eap->arg);
|
EMSG2(_("E666: compiler not supported: %s"), eap->arg);
|
||||||
vim_free(buf);
|
vim_free(buf);
|
||||||
|
|
||||||
do_cmdline_cmd((char_u *)":delcommand CompilerSet");
|
do_cmdline_cmd((char_u *)":delcommand CompilerSet");
|
||||||
|
|
||||||
/* Set "b:current_compiler" from "current_compiler". */
|
/* Set "b:current_compiler" from "current_compiler". */
|
||||||
p = get_var_value((char_u *)"g:current_compiler");
|
p = get_var_value((char_u *)"g:current_compiler");
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
set_internal_string_var((char_u *)"b:current_compiler", p);
|
set_internal_string_var((char_u *)"b:current_compiler", p);
|
||||||
|
|
||||||
/* Restore "current_compiler" for ":compiler {name}". */
|
/* Restore "current_compiler" for ":compiler {name}". */
|
||||||
if (!eap->forceit) {
|
if (!eap->forceit) {
|
||||||
if (old_cur_comp != NULL) {
|
if (old_cur_comp != NULL) {
|
||||||
set_internal_string_var((char_u *)"g:current_compiler",
|
set_internal_string_var((char_u *)"g:current_compiler",
|
||||||
old_cur_comp);
|
old_cur_comp);
|
||||||
vim_free(old_cur_comp);
|
vim_free(old_cur_comp);
|
||||||
} else
|
} else
|
||||||
do_unlet((char_u *)"g:current_compiler", TRUE);
|
do_unlet((char_u *)"g:current_compiler", TRUE);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2261,8 +2253,8 @@ void *cookie;
|
|||||||
/* Make a copy of 'runtimepath'. Invoking the callback may change the
|
/* Make a copy of 'runtimepath'. Invoking the callback may change the
|
||||||
* value. */
|
* value. */
|
||||||
rtp_copy = vim_strsave(p_rtp);
|
rtp_copy = vim_strsave(p_rtp);
|
||||||
buf = alloc(MAXPATHL);
|
buf = xmalloc(MAXPATHL);
|
||||||
if (buf != NULL && rtp_copy != NULL) {
|
if (rtp_copy != NULL) {
|
||||||
if (p_verbose > 1 && name != NULL) {
|
if (p_verbose > 1 && name != NULL) {
|
||||||
verbose_enter();
|
verbose_enter();
|
||||||
smsg((char_u *)_("Searching for \"%s\" in \"%s\""),
|
smsg((char_u *)_("Searching for \"%s\" in \"%s\""),
|
||||||
|
209
src/ex_docmd.c
209
src/ex_docmd.c
@ -3569,9 +3569,7 @@ static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep)
|
|||||||
while ((pos = (char_u *)strstr((char *)pos + 2, "$*")) != NULL)
|
while ((pos = (char_u *)strstr((char *)pos + 2, "$*")) != NULL)
|
||||||
++i;
|
++i;
|
||||||
len = (int)STRLEN(p);
|
len = (int)STRLEN(p);
|
||||||
new_cmdline = alloc((int)(STRLEN(program) + i * (len - 2) + 1));
|
new_cmdline = xmalloc(STRLEN(program) + i * (len - 2) + 1);
|
||||||
if (new_cmdline == NULL)
|
|
||||||
return NULL; /* out of memory */
|
|
||||||
ptr = new_cmdline;
|
ptr = new_cmdline;
|
||||||
while ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) {
|
while ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) {
|
||||||
i = (int)(pos - program);
|
i = (int)(pos - program);
|
||||||
@ -3582,9 +3580,7 @@ static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep)
|
|||||||
}
|
}
|
||||||
STRCPY(ptr, program);
|
STRCPY(ptr, program);
|
||||||
} else {
|
} else {
|
||||||
new_cmdline = alloc((int)(STRLEN(program) + STRLEN(p) + 2));
|
new_cmdline = xmalloc(STRLEN(program) + STRLEN(p) + 2);
|
||||||
if (new_cmdline == NULL)
|
|
||||||
return NULL; /* out of memory */
|
|
||||||
STRCPY(new_cmdline, program);
|
STRCPY(new_cmdline, program);
|
||||||
STRCAT(new_cmdline, " ");
|
STRCAT(new_cmdline, " ");
|
||||||
STRCAT(new_cmdline, p);
|
STRCAT(new_cmdline, p);
|
||||||
@ -3715,8 +3711,6 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
|
|||||||
|
|
||||||
p = repl_cmdline(eap, p, srclen, repl, cmdlinep);
|
p = repl_cmdline(eap, p, srclen, repl, cmdlinep);
|
||||||
vim_free(repl);
|
vim_free(repl);
|
||||||
if (p == NULL)
|
|
||||||
return FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3811,7 +3805,6 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
|
|||||||
* "src" points to the part that is to be replaced, of length "srclen".
|
* "src" points to the part that is to be replaced, of length "srclen".
|
||||||
* "repl" is the replacement string.
|
* "repl" is the replacement string.
|
||||||
* Returns a pointer to the character after the replaced string.
|
* Returns a pointer to the character after the replaced string.
|
||||||
* Returns NULL for failure.
|
|
||||||
*/
|
*/
|
||||||
static char_u *repl_cmdline(exarg_T *eap, char_u *src, int srclen, char_u *repl, char_u **cmdlinep)
|
static char_u *repl_cmdline(exarg_T *eap, char_u *src, int srclen, char_u *repl, char_u **cmdlinep)
|
||||||
{
|
{
|
||||||
@ -3828,8 +3821,7 @@ static char_u *repl_cmdline(exarg_T *eap, char_u *src, int srclen, char_u *repl,
|
|||||||
i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3;
|
i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3;
|
||||||
if (eap->nextcmd != NULL)
|
if (eap->nextcmd != NULL)
|
||||||
i += (int)STRLEN(eap->nextcmd); /* add space for next command */
|
i += (int)STRLEN(eap->nextcmd); /* add space for next command */
|
||||||
if ((new_cmdline = alloc((unsigned)i)) == NULL)
|
new_cmdline = xmalloc(i);
|
||||||
return NULL; /* out of memory! */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy the stuff before the expanded part.
|
* Copy the stuff before the expanded part.
|
||||||
@ -4823,11 +4815,7 @@ static char_u *uc_split_args(char_u *arg, size_t *lenp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = alloc(len + 1);
|
buf = xmalloc(len + 1);
|
||||||
if (buf == NULL) {
|
|
||||||
*lenp = 0;
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = arg;
|
p = arg;
|
||||||
q = buf;
|
q = buf;
|
||||||
@ -5142,11 +5130,7 @@ static void do_ucmd(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
totlen += STRLEN(p); /* Add on the trailing characters */
|
totlen += STRLEN(p); /* Add on the trailing characters */
|
||||||
buf = alloc((unsigned)(totlen + 1));
|
buf = xmalloc(totlen + 1);
|
||||||
if (buf == NULL) {
|
|
||||||
vim_free(split_buf);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
current_SID = cmd->uc_scriptID;
|
current_SID = cmd->uc_scriptID;
|
||||||
@ -5698,7 +5682,7 @@ static void ex_goto(exarg_T *eap)
|
|||||||
* code is very similar to :args and hence needs access to a lot of the static
|
* code is very similar to :args and hence needs access to a lot of the static
|
||||||
* functions in this file.
|
* functions in this file.
|
||||||
*
|
*
|
||||||
* The list should be allocated using alloc(), as should each item in the
|
* The list should be allocated using xmalloc(), as should each item in the
|
||||||
* list. This function takes over responsibility for freeing the list.
|
* list. This function takes over responsibility for freeing the list.
|
||||||
*
|
*
|
||||||
* XXX The list is made into the argument list. This is freed using
|
* XXX The list is made into the argument list. This is freed using
|
||||||
@ -5806,14 +5790,9 @@ void alist_unlink(alist_T *al)
|
|||||||
*/
|
*/
|
||||||
void alist_new(void)
|
void alist_new(void)
|
||||||
{
|
{
|
||||||
curwin->w_alist = (alist_T *)alloc((unsigned)sizeof(alist_T));
|
curwin->w_alist = xmalloc(sizeof(*curwin->w_alist));
|
||||||
if (curwin->w_alist == NULL) {
|
curwin->w_alist->al_refcount = 1;
|
||||||
curwin->w_alist = &global_alist;
|
alist_init(curwin->w_alist);
|
||||||
++global_alist.al_refcount;
|
|
||||||
} else {
|
|
||||||
curwin->w_alist->al_refcount = 1;
|
|
||||||
alist_init(curwin->w_alist);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(UNIX) || defined(PROTO)
|
#if !defined(UNIX) || defined(PROTO)
|
||||||
@ -5835,19 +5814,17 @@ void alist_expand(int *fnum_list, int fnum_len)
|
|||||||
* expansion. Also, the vimrc file isn't read yet, thus the user
|
* expansion. Also, the vimrc file isn't read yet, thus the user
|
||||||
* can't set the options. */
|
* can't set the options. */
|
||||||
p_su = empty_option;
|
p_su = empty_option;
|
||||||
old_arg_files = (char_u **)alloc((unsigned)(sizeof(char_u *) * GARGCOUNT));
|
old_arg_files = xmalloc(sizeof(*old_arg_files) * GARGCOUNT);
|
||||||
if (old_arg_files != NULL) {
|
for (i = 0; i < GARGCOUNT; ++i)
|
||||||
for (i = 0; i < GARGCOUNT; ++i)
|
old_arg_files[i] = vim_strsave(GARGLIST[i].ae_fname);
|
||||||
old_arg_files[i] = vim_strsave(GARGLIST[i].ae_fname);
|
old_arg_count = GARGCOUNT;
|
||||||
old_arg_count = GARGCOUNT;
|
if (expand_wildcards(old_arg_count, old_arg_files,
|
||||||
if (expand_wildcards(old_arg_count, old_arg_files,
|
&new_arg_file_count, &new_arg_files,
|
||||||
&new_arg_file_count, &new_arg_files,
|
EW_FILE|EW_NOTFOUND|EW_ADDSLASH|EW_NOERROR) == OK
|
||||||
EW_FILE|EW_NOTFOUND|EW_ADDSLASH|EW_NOERROR) == OK
|
&& new_arg_file_count > 0) {
|
||||||
&& new_arg_file_count > 0) {
|
alist_set(&global_alist, new_arg_file_count, new_arg_files,
|
||||||
alist_set(&global_alist, new_arg_file_count, new_arg_files,
|
TRUE, fnum_list, fnum_len);
|
||||||
TRUE, fnum_list, fnum_len);
|
FreeWild(old_arg_count, old_arg_files);
|
||||||
FreeWild(old_arg_count, old_arg_files);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
p_su = save_p_su;
|
p_su = save_p_su;
|
||||||
}
|
}
|
||||||
@ -7287,37 +7264,33 @@ static void ex_mkrc(exarg_T *eap)
|
|||||||
if (eap->cmdidx == CMD_mksession) {
|
if (eap->cmdidx == CMD_mksession) {
|
||||||
char_u *dirnow; /* current directory */
|
char_u *dirnow; /* current directory */
|
||||||
|
|
||||||
dirnow = alloc(MAXPATHL);
|
dirnow = xmalloc(MAXPATHL);
|
||||||
if (dirnow == NULL)
|
/*
|
||||||
failed = TRUE;
|
* Change to session file's dir.
|
||||||
else {
|
*/
|
||||||
/*
|
if (os_dirname(dirnow, MAXPATHL) == FAIL
|
||||||
* Change to session file's dir.
|
|| os_chdir((char *)dirnow) != 0)
|
||||||
*/
|
*dirnow = NUL;
|
||||||
if (os_dirname(dirnow, MAXPATHL) == FAIL
|
if (*dirnow != NUL && (ssop_flags & SSOP_SESDIR)) {
|
||||||
|| os_chdir((char *)dirnow) != 0)
|
if (vim_chdirfile(fname) == OK)
|
||||||
*dirnow = NUL;
|
shorten_fnames(TRUE);
|
||||||
if (*dirnow != NUL && (ssop_flags & SSOP_SESDIR)) {
|
} else if (*dirnow != NUL
|
||||||
if (vim_chdirfile(fname) == OK)
|
&& (ssop_flags & SSOP_CURDIR) && globaldir != NULL) {
|
||||||
shorten_fnames(TRUE);
|
if (os_chdir((char *)globaldir) == 0)
|
||||||
} else if (*dirnow != NUL
|
|
||||||
&& (ssop_flags & SSOP_CURDIR) && globaldir != NULL) {
|
|
||||||
if (os_chdir((char *)globaldir) == 0)
|
|
||||||
shorten_fnames(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
failed |= (makeopens(fd, dirnow) == FAIL);
|
|
||||||
|
|
||||||
/* restore original dir */
|
|
||||||
if (*dirnow != NUL && ((ssop_flags & SSOP_SESDIR)
|
|
||||||
|| ((ssop_flags & SSOP_CURDIR) && globaldir !=
|
|
||||||
NULL))) {
|
|
||||||
if (os_chdir((char *)dirnow) != 0)
|
|
||||||
EMSG(_(e_prev_dir));
|
|
||||||
shorten_fnames(TRUE);
|
shorten_fnames(TRUE);
|
||||||
}
|
|
||||||
vim_free(dirnow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
failed |= (makeopens(fd, dirnow) == FAIL);
|
||||||
|
|
||||||
|
/* restore original dir */
|
||||||
|
if (*dirnow != NUL && ((ssop_flags & SSOP_SESDIR)
|
||||||
|
|| ((ssop_flags & SSOP_CURDIR) && globaldir !=
|
||||||
|
NULL))) {
|
||||||
|
if (os_chdir((char *)dirnow) != 0)
|
||||||
|
EMSG(_(e_prev_dir));
|
||||||
|
shorten_fnames(TRUE);
|
||||||
|
}
|
||||||
|
vim_free(dirnow);
|
||||||
} else {
|
} else {
|
||||||
failed |= (put_view(fd, curwin, !using_vdir, flagp,
|
failed |= (put_view(fd, curwin, !using_vdir, flagp,
|
||||||
-1) == FAIL);
|
-1) == FAIL);
|
||||||
@ -7343,12 +7316,10 @@ static void ex_mkrc(exarg_T *eap)
|
|||||||
/* successful session write - set this_session var */
|
/* successful session write - set this_session var */
|
||||||
char_u *tbuf;
|
char_u *tbuf;
|
||||||
|
|
||||||
tbuf = alloc(MAXPATHL);
|
tbuf = xmalloc(MAXPATHL);
|
||||||
if (tbuf != NULL) {
|
if (vim_FullName(fname, tbuf, MAXPATHL, FALSE) == OK)
|
||||||
if (vim_FullName(fname, tbuf, MAXPATHL, FALSE) == OK)
|
set_vim_var_string(VV_THIS_SESSION, tbuf, -1);
|
||||||
set_vim_var_string(VV_THIS_SESSION, tbuf, -1);
|
vim_free(tbuf);
|
||||||
vim_free(tbuf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#ifdef MKSESSION_NL
|
#ifdef MKSESSION_NL
|
||||||
mksession_nl = FALSE;
|
mksession_nl = FALSE;
|
||||||
@ -7478,20 +7449,18 @@ static void ex_normal(exarg_T *eap)
|
|||||||
len += 2;
|
len += 2;
|
||||||
}
|
}
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
arg = alloc((unsigned)(STRLEN(eap->arg) + len + 1));
|
arg = xmalloc(STRLEN(eap->arg) + len + 1);
|
||||||
if (arg != NULL) {
|
len = 0;
|
||||||
len = 0;
|
for (p = eap->arg; *p != NUL; ++p) {
|
||||||
for (p = eap->arg; *p != NUL; ++p) {
|
arg[len++] = *p;
|
||||||
arg[len++] = *p;
|
for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) {
|
||||||
for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) {
|
arg[len++] = *++p;
|
||||||
arg[len++] = *++p;
|
if (*p == K_SPECIAL) {
|
||||||
if (*p == K_SPECIAL) {
|
arg[len++] = KS_SPECIAL;
|
||||||
arg[len++] = KS_SPECIAL;
|
arg[len++] = KE_FILLER;
|
||||||
arg[len++] = KE_FILLER;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
arg[len] = NUL;
|
|
||||||
}
|
}
|
||||||
|
arg[len] = NUL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8038,7 +8007,6 @@ eval_vars (
|
|||||||
* Concatenate all files in the argument list, separated by spaces, and return
|
* Concatenate all files in the argument list, separated by spaces, and return
|
||||||
* it in one allocated string.
|
* it in one allocated string.
|
||||||
* Spaces and backslashes in the file names are escaped with a backslash.
|
* Spaces and backslashes in the file names are escaped with a backslash.
|
||||||
* Returns NULL when out of memory.
|
|
||||||
*/
|
*/
|
||||||
static char_u *arg_all(void)
|
static char_u *arg_all(void)
|
||||||
{
|
{
|
||||||
@ -8084,9 +8052,7 @@ static char_u *arg_all(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* allocate memory */
|
/* allocate memory */
|
||||||
retval = alloc((unsigned)len + 1);
|
retval = xmalloc(len + 1);
|
||||||
if (retval == NULL)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
@ -8128,12 +8094,7 @@ char_u *expand_sfile(char_u *arg)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
len = (int)STRLEN(result) - srclen + (int)STRLEN(repl) + 1;
|
len = (int)STRLEN(result) - srclen + (int)STRLEN(repl) + 1;
|
||||||
newres = alloc(len);
|
newres = xmalloc(len);
|
||||||
if (newres == NULL) {
|
|
||||||
vim_free(repl);
|
|
||||||
vim_free(result);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
memmove(newres, result, (size_t)(p - result));
|
memmove(newres, result, (size_t)(p - result));
|
||||||
STRCPY(newres + (p - result), repl);
|
STRCPY(newres + (p - result), repl);
|
||||||
len = (int)STRLEN(newres);
|
len = (int)STRLEN(newres);
|
||||||
@ -8777,11 +8738,9 @@ ses_arglist (
|
|||||||
s = alist_name(&((aentry_T *)gap->ga_data)[i]);
|
s = alist_name(&((aentry_T *)gap->ga_data)[i]);
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
if (fullname) {
|
if (fullname) {
|
||||||
buf = alloc(MAXPATHL);
|
buf = xmalloc(MAXPATHL);
|
||||||
if (buf != NULL) {
|
(void)vim_FullName(s, buf, MAXPATHL, FALSE);
|
||||||
(void)vim_FullName(s, buf, MAXPATHL, FALSE);
|
s = buf;
|
||||||
s = buf;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (fputs("argadd ", fd) < 0 || ses_put_fname(fd, s, flagp) == FAIL
|
if (fputs("argadd ", fd) < 0 || ses_put_fname(fd, s, flagp) == FAIL
|
||||||
|| put_eol(fd) == FAIL) {
|
|| put_eol(fd) == FAIL) {
|
||||||
@ -8900,30 +8859,28 @@ static char_u *get_view_file(int c)
|
|||||||
for (p = sname; *p; ++p)
|
for (p = sname; *p; ++p)
|
||||||
if (*p == '=' || vim_ispathsep(*p))
|
if (*p == '=' || vim_ispathsep(*p))
|
||||||
++len;
|
++len;
|
||||||
retval = alloc((unsigned)(STRLEN(sname) + len + STRLEN(p_vdir) + 9));
|
retval = xmalloc(STRLEN(sname) + len + STRLEN(p_vdir) + 9);
|
||||||
if (retval != NULL) {
|
STRCPY(retval, p_vdir);
|
||||||
STRCPY(retval, p_vdir);
|
add_pathsep(retval);
|
||||||
add_pathsep(retval);
|
s = retval + STRLEN(retval);
|
||||||
s = retval + STRLEN(retval);
|
for (p = sname; *p; ++p) {
|
||||||
for (p = sname; *p; ++p) {
|
if (*p == '=') {
|
||||||
if (*p == '=') {
|
*s++ = '=';
|
||||||
*s++ = '=';
|
*s++ = '=';
|
||||||
*s++ = '=';
|
} else if (vim_ispathsep(*p)) {
|
||||||
} else if (vim_ispathsep(*p)) {
|
*s++ = '=';
|
||||||
*s++ = '=';
|
|
||||||
#if defined(BACKSLASH_IN_FILENAME)
|
#if defined(BACKSLASH_IN_FILENAME)
|
||||||
if (*p == ':')
|
if (*p == ':')
|
||||||
*s++ = '-';
|
*s++ = '-';
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
*s++ = '+';
|
*s++ = '+';
|
||||||
} else
|
} else
|
||||||
*s++ = *p;
|
*s++ = *p;
|
||||||
}
|
|
||||||
*s++ = '=';
|
|
||||||
*s++ = c;
|
|
||||||
STRCPY(s, ".vim");
|
|
||||||
}
|
}
|
||||||
|
*s++ = '=';
|
||||||
|
*s++ = c;
|
||||||
|
STRCPY(s, ".vim");
|
||||||
|
|
||||||
vim_free(sname);
|
vim_free(sname);
|
||||||
return retval;
|
return retval;
|
||||||
|
Loading…
Reference in New Issue
Block a user