Mercurial > vim
changeset 32523:626c2806d2c1 v9.0.1593
patch 9.0.1593: MS-Windows: assert error when compiled with debug mode
Commit: https://github.com/vim/vim/commit/3c240f608c38ef1af67e112e0e689751c003f946
Author: K.Takata <kentkt@csc.jp>
Date: Wed May 31 12:47:45 2023 +0100
patch 9.0.1593: MS-Windows: assert error when compiled with debug mode
Problem: MS-Windows: assert error when compiled with debug mode.
Solution: Adjust arguments to setvbuf(). (Ken Takata, closes https://github.com/vim/vim/issues/12467)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 31 May 2023 14:00:06 +0200 |
parents | 63d12304694f |
children | f32e24ce6970 |
files | src/alloc.c src/main.c src/proto/main.pro src/version.c |
diffstat | 4 files changed, 30 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alloc.c +++ b/src/alloc.c @@ -580,6 +580,7 @@ free_all_mem(void) # ifdef FEAT_EVAL free_resub_eval_result(); # endif + free_vbuf(); } #endif
--- a/src/main.c +++ b/src/main.c @@ -76,6 +76,10 @@ static char *(main_errors[]) = // Various parameters passed between main() and other functions. static mparm_T params; +#ifdef _IOLBF +static void *s_vbuf = NULL; // buffer for setvbuf() +#endif + #ifndef NO_VIM_MAIN // skip this for unittests static char_u *start_dir = NULL; // current working dir on startup @@ -353,10 +357,14 @@ main check_tty(¶ms); #ifdef _IOLBF - // Ensure output works usefully without a tty: buffer lines instead of - // fully buffered. if (silent_mode) - setvbuf(stdout, NULL, _IOLBF, 0); + { + // Ensure output works usefully without a tty: buffer lines instead of + // fully buffered. + s_vbuf = malloc(BUFSIZ); + if (s_vbuf != NULL) + setvbuf(stdout, s_vbuf, _IOLBF, BUFSIZ); + } #endif // This message comes before term inits, but after setting "silent_mode" @@ -1027,6 +1035,21 @@ is_not_a_term_or_gui(void) ; } +#if defined(EXITFREE) || defined(PROTO) + void +free_vbuf(void) +{ +# ifdef _IOLBF + if (s_vbuf != NULL) + { + setvbuf(stdout, NULL, _IONBF, 0); + free(s_vbuf); + s_vbuf = NULL; + } +# endif +} +#endif + #if defined(FEAT_GUI) || defined(PROTO) /* * If a --gui-dialog-file argument was given return the file name.