comparison src/main.c @ 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 a1e1527d1cb8
children 448aef880252
comparison
equal deleted inserted replaced
32522:63d12304694f 32523:626c2806d2c1
74 #ifndef PROTO // don't want a prototype for main() 74 #ifndef PROTO // don't want a prototype for main()
75 75
76 // Various parameters passed between main() and other functions. 76 // Various parameters passed between main() and other functions.
77 static mparm_T params; 77 static mparm_T params;
78 78
79 #ifdef _IOLBF
80 static void *s_vbuf = NULL; // buffer for setvbuf()
81 #endif
82
79 #ifndef NO_VIM_MAIN // skip this for unittests 83 #ifndef NO_VIM_MAIN // skip this for unittests
80 84
81 static char_u *start_dir = NULL; // current working dir on startup 85 static char_u *start_dir = NULL; // current working dir on startup
82 86
83 static int has_dash_c_arg = FALSE; 87 static int has_dash_c_arg = FALSE;
351 * Print a warning if stdout is not a terminal. 355 * Print a warning if stdout is not a terminal.
352 */ 356 */
353 check_tty(&params); 357 check_tty(&params);
354 358
355 #ifdef _IOLBF 359 #ifdef _IOLBF
356 // Ensure output works usefully without a tty: buffer lines instead of
357 // fully buffered.
358 if (silent_mode) 360 if (silent_mode)
359 setvbuf(stdout, NULL, _IOLBF, 0); 361 {
362 // Ensure output works usefully without a tty: buffer lines instead of
363 // fully buffered.
364 s_vbuf = malloc(BUFSIZ);
365 if (s_vbuf != NULL)
366 setvbuf(stdout, s_vbuf, _IOLBF, BUFSIZ);
367 }
360 #endif 368 #endif
361 369
362 // This message comes before term inits, but after setting "silent_mode" 370 // This message comes before term inits, but after setting "silent_mode"
363 // when the input is not a tty. Omit the message with --not-a-term. 371 // when the input is not a tty. Omit the message with --not-a-term.
364 if (GARGCOUNT > 1 && !silent_mode && !is_not_a_term()) 372 if (GARGCOUNT > 1 && !silent_mode && !is_not_a_term())
1024 #ifdef FEAT_GUI 1032 #ifdef FEAT_GUI
1025 || gui.in_use 1033 || gui.in_use
1026 #endif 1034 #endif
1027 ; 1035 ;
1028 } 1036 }
1037
1038 #if defined(EXITFREE) || defined(PROTO)
1039 void
1040 free_vbuf(void)
1041 {
1042 # ifdef _IOLBF
1043 if (s_vbuf != NULL)
1044 {
1045 setvbuf(stdout, NULL, _IONBF, 0);
1046 free(s_vbuf);
1047 s_vbuf = NULL;
1048 }
1049 # endif
1050 }
1051 #endif
1029 1052
1030 #if defined(FEAT_GUI) || defined(PROTO) 1053 #if defined(FEAT_GUI) || defined(PROTO)
1031 /* 1054 /*
1032 * If a --gui-dialog-file argument was given return the file name. 1055 * If a --gui-dialog-file argument was given return the file name.
1033 * Otherwise return NULL. 1056 * Otherwise return NULL.