aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/fileio.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2020-02-16 23:18:24 -0800
committerGitHub <noreply@github.com>2020-02-16 23:18:24 -0800
commit03f245c0b810fa2ff980bd3bf2530d94fd0f05d3 (patch)
treedbbd77ecb94314d118f0a9a9a001d33ba1b74053 /src/nvim/fileio.c
parent0c5d2ffebe92e710ca57d4e3f0b0789ccc369660 (diff)
parent1ce4b3c9a7420227c3ecffab782cb8da732998f5 (diff)
downloadrneovim-03f245c0b810fa2ff980bd3bf2530d94fd0f05d3.tar.gz
rneovim-03f245c0b810fa2ff980bd3bf2530d94fd0f05d3.tar.bz2
rneovim-03f245c0b810fa2ff980bd3bf2530d94fd0f05d3.zip
Merge #11873 from janlazo/vim-8.1.0786
vim-patch:8.0.1660,8.1.{43,786,1201,2129,2131,2187,2223,2259},8.2.{241,267}
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r--src/nvim/fileio.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 84c328f0c4..e5845e0749 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -2032,14 +2032,16 @@ readfile_linenr(
* Fill "*eap" to force the 'fileencoding', 'fileformat' and 'binary to be
* equal to the buffer "buf". Used for calling readfile().
*/
-void prep_exarg(exarg_T *eap, buf_T *buf)
+void prep_exarg(exarg_T *eap, const buf_T *buf)
+ FUNC_ATTR_NONNULL_ALL
{
- eap->cmd = xmalloc(STRLEN(buf->b_p_ff) + STRLEN(buf->b_p_fenc) + 15);
+ const size_t cmd_len = 15 + STRLEN(buf->b_p_fenc);
+ eap->cmd = xmalloc(cmd_len);
- 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);
+ snprintf((char *)eap->cmd, cmd_len, "e ++enc=%s", buf->b_p_fenc);
+ eap->force_enc = 8;
eap->bad_char = buf->b_bad_char;
- eap->force_ff = 7;
+ eap->force_ff = *buf->b_p_ff;
eap->force_bin = buf->b_p_bin ? FORCE_BIN : FORCE_NOBIN;
eap->read_edit = FALSE;