mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
No OOM error condition in prep_exarg()
This commit is contained in:
parent
15d8f702a8
commit
4b6b9117b3
@ -4659,10 +4659,7 @@ int buf_contents_changed(buf_T *buf)
|
||||
return TRUE;
|
||||
|
||||
/* Force the 'fileencoding' and 'fileformat' to be equal. */
|
||||
if (prep_exarg(&ea, buf) == FAIL) {
|
||||
wipe_buffer(newbuf, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
prep_exarg(&ea, buf);
|
||||
|
||||
/* set curwin/curbuf to buf and save a few things */
|
||||
aucmd_prepbuf(&aco, newbuf);
|
||||
|
20
src/fileio.c
20
src/fileio.c
@ -2062,15 +2062,10 @@ readfile_linenr (
|
||||
/*
|
||||
* Fill "*eap" to force the 'fileencoding', 'fileformat' and 'binary to be
|
||||
* equal to the buffer "buf". Used for calling readfile().
|
||||
* Returns OK or FAIL.
|
||||
*/
|
||||
int prep_exarg(exarg_T *eap, buf_T *buf)
|
||||
void prep_exarg(exarg_T *eap, buf_T *buf)
|
||||
{
|
||||
eap->cmd = alloc((unsigned)(STRLEN(buf->b_p_ff)
|
||||
+ STRLEN(buf->b_p_fenc)
|
||||
+ 15));
|
||||
if (eap->cmd == NULL)
|
||||
return FAIL;
|
||||
eap->cmd = xmalloc(STRLEN(buf->b_p_ff) + STRLEN(buf->b_p_fenc) + 15);
|
||||
|
||||
sprintf((char *)eap->cmd, "e ++ff=%s ++enc=%s", buf->b_p_ff, buf->b_p_fenc);
|
||||
eap->force_enc = 14 + (int)STRLEN(buf->b_p_ff);
|
||||
@ -2080,7 +2075,6 @@ int prep_exarg(exarg_T *eap, buf_T *buf)
|
||||
eap->force_bin = buf->b_p_bin ? FORCE_BIN : FORCE_NOBIN;
|
||||
eap->read_edit = FALSE;
|
||||
eap->forceit = FALSE;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -5456,10 +5450,11 @@ void buf_reload(buf_T *buf, int orig_mode)
|
||||
/* set curwin/curbuf for "buf" and save some things */
|
||||
aucmd_prepbuf(&aco, buf);
|
||||
|
||||
/* We only want to read the text from the file, not reset the syntax
|
||||
* highlighting, clear marks, diff status, etc. Force the fileformat
|
||||
* and encoding to be the same. */
|
||||
if (prep_exarg(&ea, buf) == OK) {
|
||||
// We only want to read the text from the file, not reset the syntax
|
||||
// highlighting, clear marks, diff status, etc. Force the fileformat and
|
||||
// encoding to be the same.
|
||||
|
||||
prep_exarg(&ea, buf);
|
||||
old_cursor = curwin->w_cursor;
|
||||
old_topline = curwin->w_topline;
|
||||
|
||||
@ -5563,7 +5558,6 @@ void buf_reload(buf_T *buf, int orig_mode)
|
||||
|
||||
/* Modelines must override settings done by autocommands. */
|
||||
do_modelines(0);
|
||||
}
|
||||
|
||||
/* restore curwin/curbuf and a few other things */
|
||||
aucmd_restbuf(&aco);
|
||||
|
@ -21,7 +21,7 @@ void filemess(buf_T *buf, char_u *name, char_u *s, int attr);
|
||||
int readfile(char_u *fname, char_u *sfname, linenr_T from,
|
||||
linenr_T lines_to_skip, linenr_T lines_to_read, exarg_T *eap,
|
||||
int flags);
|
||||
int prep_exarg(exarg_T *eap, buf_T *buf);
|
||||
void prep_exarg(exarg_T *eap, buf_T *buf);
|
||||
void set_file_options(int set_options, exarg_T *eap);
|
||||
void set_forced_fenc(exarg_T *eap);
|
||||
int prepare_crypt_read(FILE *fp);
|
||||
|
Loading…
Reference in New Issue
Block a user