diff options
Diffstat (limited to 'src/nvim/memline.c')
-rw-r--r-- | src/nvim/memline.c | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/src/nvim/memline.c b/src/nvim/memline.c index aa3e0e0b1c..4e35dd481f 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -1,11 +1,3 @@ -/* - * VIM - Vi IMproved by Bram Moolenaar - * - * Do ":help uganda" in Vim to read copying and usage conditions. - * Do ":help credits" in Vim to see a list of people who contributed. - * See README.txt for an overview of the Vim source code. - */ - /* for debugging */ /* #define CHECK(c, s) if (c) EMSG(s) */ #define CHECK(c, s) @@ -46,6 +38,7 @@ #include <inttypes.h> #include <string.h> #include <stdbool.h> +#include <fcntl.h> #include "nvim/ascii.h" #include "nvim/vim.h" @@ -72,7 +65,6 @@ #include "nvim/strings.h" #include "nvim/ui.h" #include "nvim/version.h" -#include "nvim/tempfile.h" #include "nvim/undo.h" #include "nvim/window.h" #include "nvim/os/os.h" @@ -433,10 +425,8 @@ void ml_setname(buf_T *buf) /* try to rename the swap file */ if (vim_rename(mfp->mf_fname, fname) == 0) { success = TRUE; - xfree(mfp->mf_fname); - mfp->mf_fname = fname; - xfree(mfp->mf_ffname); - mf_set_ffname(mfp); + mf_free_fnames(mfp); + mf_set_fnames(mfp, fname); ml_upd_block0(buf, UB_SAME_DIR); break; } @@ -796,9 +786,8 @@ void ml_recover(void) if (fname == NULL) /* When there is no file name */ fname = (char_u *)""; len = (int)STRLEN(fname); - if (len >= 4 && - STRNICMP(fname + len - 4, ".s", 2) - == 0 + if (len >= 4 + && STRNICMP(fname + len - 4, ".s", 2) == 0 && vim_strchr((char_u *)"UVWuvw", fname[len - 2]) != NULL && ASCII_ISALPHA(fname[len - 1])) { directly = TRUE; @@ -2990,7 +2979,7 @@ static void ml_lineadd(buf_T *buf, int count) * If it worked returns OK and the resolved link in "buf[MAXPATHL]". * Otherwise returns FAIL. */ -int resolve_symlink(char_u *fname, char_u *buf) +int resolve_symlink(const char_u *fname, char_u *buf) { char_u tmp[MAXPATHL]; int ret; @@ -3203,7 +3192,7 @@ attention_message ( */ static int do_swapexists(buf_T *buf, char_u *fname) { - set_vim_var_string(VV_SWAPNAME, fname, -1); + set_vim_var_string(VV_SWAPNAME, (char *) fname, -1); set_vim_var_string(VV_SWAPCHOICE, NULL, -1); /* Trigger SwapExists autocommands with <afile> set to the file being @@ -3262,8 +3251,8 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, * Isolate a directory name from *dirp and put it in dir_name. * First allocate some memory to put the directory name in. */ - const size_t dir_len = strlen(*dirp); - dir_name = xmalloc(dir_len + 1); + const size_t dir_len = strlen(*dirp) + 1; + dir_name = xmalloc(dir_len); (void)copy_option_part((char_u **) dirp, (char_u *) dir_name, dir_len, ","); /* @@ -3962,8 +3951,10 @@ long ml_find_line_or_offset(buf_T *buf, linenr_T lnum, long *offp) if (ffdos) size += lnum - 1; - /* Don't count the last line break if 'bin' and 'noeol'. */ - if (buf->b_p_bin && !buf->b_p_eol && buf->b_ml.ml_line_count == lnum) { + /* Don't count the last line break if 'noeol' and ('bin' or + * 'nofixeol'). */ + if ((!buf->b_p_fixeol || buf->b_p_bin) && !buf->b_p_eol + && buf->b_ml.ml_line_count == lnum) { size -= ffdos + 1; } } |