To: vim-dev@vim.org Subject: Patch 6.1.226 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.226 Problem: Using ":debug" with a ":normal" command may cause a hang. (Colin Keith) Solution: Save the typeahead buffer when obtaining a debug command. Files: src/ex_cmds2.c, src/getchar.c, src/proto/getchar.pro *** ../vim61.225/src/ex_cmds2.c Sun Oct 13 20:08:13 2002 --- src/ex_cmds2.c Mon Oct 14 21:11:01 2002 *************** *** 30,35 **** --- 30,39 ---- int save_State = State; int save_did_emsg = did_emsg; int save_cmd_silent = cmd_silent; + typebuf_T saved_typebuf; + int new_typebuf; + struct buffheader save_stuffbuff; + int save_ex_normal_busy; int n; char_u *cmdline = NULL; char_u *p; *************** *** 85,91 **** --- 89,117 ---- #ifdef FEAT_SNIFF ProcessSniffRequests(); #endif + /* Save the current typeahead buffer and replace it with an empty one. + * This makes sure we get input from the user here and don't interfere + * with the commands being executed. Reset "ex_normal_busy" to avoid + * the side effects of using ":normal". Save the stuff buffer and make + * it empty. */ + saved_typebuf = typebuf; + new_typebuf = (alloc_typebuf() == OK); + save_ex_normal_busy = ex_normal_busy; + ex_normal_busy = 0; + save_stuffbuff = stuffbuff; + stuffbuff.bh_first.b_next = NULL; + cmdline = getcmdline_prompt('>', NULL, 0); + + if (new_typebuf) + { + free_typebuf(); + typebuf = saved_typebuf; + } + ex_normal_busy = save_ex_normal_busy; + free_buff(&stuffbuff); + stuffbuff = save_stuffbuff; + cmdline_row = msg_row; if (cmdline != NULL) { *** ../vim61.225/src/getchar.c Sat Sep 14 16:56:33 2002 --- src/getchar.c Mon Oct 14 21:11:30 2002 *************** *** 109,115 **** static int last_recorded_len = 0; /* number of last recorded chars */ - static void free_buff __ARGS((struct buffheader *)); static char_u *get_buffcont __ARGS((struct buffheader *, int)); static void add_buff __ARGS((struct buffheader *, char_u *, long n)); static void add_num_buff __ARGS((struct buffheader *, long)); --- 109,114 ---- *************** *** 130,136 **** /* * Free and clear a buffer. */ ! static void free_buff(buf) struct buffheader *buf; { --- 129,135 ---- /* * Free and clear a buffer. */ ! void free_buff(buf) struct buffheader *buf; { *** ../vim61.225/src/proto/getchar.pro Fri Mar 22 21:41:10 2002 --- src/proto/getchar.pro Mon Oct 14 21:11:49 2002 *************** *** 1,4 **** --- 1,5 ---- /* getchar.c */ + void free_buff __ARGS((struct buffheader *buf)); char_u *get_recorded __ARGS((void)); char_u *get_inserted __ARGS((void)); int stuff_empty __ARGS((void)); *** ../vim61.225/src/version.c Mon Oct 14 20:41:51 2002 --- src/version.c Mon Oct 14 21:15:29 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 226, /**/ -- hundred-and-one symptoms of being an internet addict: 220. Your wife asks for sex and you tell her where to find you on IRC. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.vim.org \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///