aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerry Hung <iperry@gmail.com>2015-03-18 22:41:51 -0400
committerJustin M. Keyes <justinkz@gmail.com>2015-03-20 17:54:28 -0400
commit26e6bca769ca5972063657bb01f157523d51c44f (patch)
treef7dc1cc76feeae4c39740ef256f63998e404ec77 /src
parent2d0f7fa95d9d106d74c24538d6723072c62266d3 (diff)
downloadrneovim-26e6bca769ca5972063657bb01f157523d51c44f.tar.gz
rneovim-26e6bca769ca5972063657bb01f157523d51c44f.tar.bz2
rneovim-26e6bca769ca5972063657bb01f157523d51c44f.zip
vim-patch:7.4.503 #2178
Problem: Cannot append a list of lines to a file. Solution: Add the append option to writefile(). (Yasuhiro Matsumoto) https://code.google.com/p/vim/source/detail?r=v7-4-503 -Ported old legacy test over to test/functional/legacy/writefile_spec.lua -Tests for mapping and signs from the original patch were removed since they have nothing to do this with feature Tested with: make oldtest, make test on OS X. Signed-off-by: Perry Hung <iperry@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c14
-rw-r--r--src/nvim/version.c2
2 files changed, 11 insertions, 5 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index a716bb66ab..ad2a0b2bb2 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -15453,16 +15453,22 @@ static void f_writefile(typval_T *argvars, typval_T *rettv)
}
bool binary = false;
- if (argvars[2].v_type != VAR_UNKNOWN
- && STRCMP(get_tv_string(&argvars[2]), "b") == 0) {
- binary = true;
+ bool append = false;
+ if (argvars[2].v_type != VAR_UNKNOWN) {
+ if (vim_strchr(get_tv_string(&argvars[2]), 'b')) {
+ binary = true;
+ }
+ if (vim_strchr(get_tv_string(&argvars[2]), 'a')) {
+ append = true;
+ }
}
// Always open the file in binary mode, library functions have a mind of
// their own about CR-LF conversion.
char_u *fname = get_tv_string(&argvars[1]);
FILE *fd;
- if (*fname == NUL || (fd = mch_fopen((char *)fname, WRITEBIN)) == NULL) {
+ if (*fname == NUL || (fd = mch_fopen((char *)fname,
+ append ? APPENDBIN : WRITEBIN)) == NULL) {
EMSG2(_(e_notcreate), *fname == NUL ? (char_u *)_("<empty>") : fname);
rettv->vval.v_number = -1;
} else {
diff --git a/src/nvim/version.c b/src/nvim/version.c
index f876e78388..a957d844be 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -337,7 +337,7 @@ static int included_patches[] = {
//506 NA
//505 NA
//504 NA
- //503,
+ 503,
//502,
//501 NA
500,