To: vim-dev@vim.org Subject: Patch 5.5.072 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.5.072 (extra) Problem: Dos 32 bit: When setting 'columns' to a too large value, Vim may crash, and the DOS console too. Solution: Check that the value of 'columns' isn't larger than the number of columns that the BIOS reports. Files: src/os_msdos.c, src/proto/os_msdos.pro, src/option.c *** ../vim-5.5.71/src/os_msdos.c Tue Dec 7 12:48:06 1999 --- src/os_msdos.c Thu Dec 16 13:26:13 1999 *************** *** 1640,1655 **** return OK; } /* * Set the active window for delline/insline. */ void set_window(void) { #ifndef DJGPP ! _video.screenheight = Rows; #endif ! mywindow(1, 1, Columns, Rows); screen_start(); } --- 1643,1678 ---- return OK; } + #if defined(DJGPP) || defined(PROTO) + /* + * Check the number of Columns with a BIOS call. This avoids a crash of the + * DOS console when 'columns' is set to a too large value. + */ + void + mch_check_columns() + { + static union REGS regs; + + regs.h.ah = 0x0f; + (void)int86(0x10, ®s, ®s); + if ((unsigned)Columns > (unsigned)regs.h.ah) + Columns = (unsigned)regs.h.ah; + } + #endif + /* * Set the active window for delline/insline. */ void set_window(void) { + if (term_console) + { #ifndef DJGPP ! _video.screenheight = Rows; #endif ! mywindow(1, 1, Columns, Rows); ! } screen_start(); } *** ../vim-5.5.71/src/proto/os_msdos.pro Wed Sep 22 10:06:15 1999 --- src/proto/os_msdos.pro Thu Dec 16 13:17:59 1999 *************** *** 28,33 **** --- 28,34 ---- void mch_setmouse __ARGS((int on)); int mch_screenmode __ARGS((char_u *arg)); int mch_get_winsize __ARGS((void)); + void mch_check_columns __ARGS((void)); void set_window __ARGS((void)); void mch_set_winsize __ARGS((void)); int mch_call_shell __ARGS((char_u *cmd, int options)); *** ../vim-5.5.71/src/option.c Wed Dec 8 16:23:15 1999 --- src/option.c Thu Dec 16 13:25:23 1999 *************** *** 4105,4110 **** --- 4105,4117 ---- } Columns = MIN_COLUMNS; } + + #ifdef DJGPP + /* avoid a crash by checking for a too large value of 'columns' */ + if (old_Columns != Columns && full_screen && term_console) + mch_check_columns(); + #endif + /* * If the screenheight has been changed, assume it is the physical * screenheight. *** ../vim-5.5.71/src/version.c Thu Dec 16 15:58:50 1999 --- src/version.c Thu Dec 16 15:59:06 1999 *************** *** 420,420 **** --- 420,421 ---- { /* Add new patch number below this line */ + 72, -- MESKIMEN'S LAW There's never time to do it right, but always time to do it over. --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /