From 2c1d12d0beda7b359fec94c00746b7206ae8fedd Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 26 Jan 2020 03:18:45 -0800 Subject: [PATCH] mksession: always write LF "\n" line-endings - remove `MKSESSION_NL`, `mksession_nl` - deprecate the "unix" flag of 'sessionoptions' There is no reason to choose CRLF or LF for session files. Instead just always write LF. --- src/nvim/ex_docmd.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 6791bbd34c..2950b2950c 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -8085,11 +8085,6 @@ static void close_redir(void) } } -#ifdef USE_CRNL -# define MKSESSION_NL -static int mksession_nl = FALSE; /* use NL only in put_eol() */ -#endif - /// ":mkexrc", ":mkvimrc", ":mkview", ":mksession". static void ex_mkrc(exarg_T *eap) { @@ -8142,12 +8137,6 @@ static void ex_mkrc(exarg_T *eap) else flagp = &ssop_flags; -#ifdef MKSESSION_NL - /* "unix" in 'sessionoptions': use NL line separator */ - if (view_session && (*flagp & SSOP_UNIX)) - mksession_nl = TRUE; -#endif - /* Write the version command for :mkvimrc */ if (eap->cmdidx == CMD_mkvimrc) (void)put_line(fd, "version 6.0"); @@ -8236,9 +8225,6 @@ static void ex_mkrc(exarg_T *eap) } xfree(tbuf); } -#ifdef MKSESSION_NL - mksession_nl = FALSE; -#endif } xfree(viewFile); @@ -9964,19 +9950,11 @@ static char *get_view_file(int c) } -/* - * Write end-of-line character(s) for ":mkexrc", ":mkvimrc" and ":mksession". - * Return FAIL for a write error. - */ +/// TODO(justinmk): remove this. Formerly used to choose CRLF or LF for session +// files, but that's useless--instead we always write LF. int put_eol(FILE *fd) { -#if defined(USE_CRNL) && defined(MKSESSION_NL) - if ((!mksession_nl && putc('\r', fd) < 0) || putc('\n', fd) < 0) { -#elif defined(USE_CRNL) - if (putc('\r', fd) < 0 || putc('\n', fd) < 0) { -#else if (putc('\n', fd) < 0) { -#endif return FAIL; } return OK;