To: vim_dev@googlegroups.com Subject: Patch 8.1.0552 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0552 Problem: Saved last search pattern may not be restored. Solution: Call restore_last_search_pattern(). Add a check for balancing saving and restoring the last search pattern. Files: src/ex_getln.c, src/search.c *** ../vim-8.1.0551/src/ex_getln.c 2018-11-24 14:27:36.988474753 +0100 --- src/ex_getln.c 2018-11-30 21:43:13.477019050 +0100 *************** *** 462,467 **** --- 462,468 ---- int use_last_pat; // Parsing range may already set the last search pattern. + // NOTE: must call restore_last_search_pattern() before returning! save_last_search_pattern(); if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen)) *************** *** 633,638 **** --- 634,640 ---- int save; // Parsing range may already set the last search pattern. + // NOTE: must call restore_last_search_pattern() before returning! save_last_search_pattern(); if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen)) *************** *** 735,740 **** --- 737,743 ---- int skiplen, patlen; // Parsing range may already set the last search pattern. + // NOTE: must call restore_last_search_pattern() before returning! save_last_search_pattern(); if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen)) *************** *** 742,747 **** --- 745,751 ---- restore_last_search_pattern(); return FAIL; } + restore_last_search_pattern(); // Add a character from under the cursor for 'incsearch'. if (is_state->did_incsearch) *** ../vim-8.1.0551/src/search.c 2018-11-16 16:21:01.633310065 +0100 --- src/search.c 2018-11-30 21:46:33.771924536 +0100 *************** *** 96,101 **** --- 96,102 ---- /* copy of spats[RE_SEARCH], for keeping the search patterns while incremental * searching */ static struct spat saved_last_search_spat; + static int did_save_last_search_spat = 0; static int saved_last_idx = 0; static int saved_no_hlsearch = 0; # endif *************** *** 364,369 **** --- 365,375 ---- void save_last_search_pattern(void) { + if (did_save_last_search_spat != 0) + IEMSG("did_save_last_search_spat is not zero"); + else + ++did_save_last_search_spat; + saved_last_search_spat = spats[RE_SEARCH]; if (spats[RE_SEARCH].pat != NULL) saved_last_search_spat.pat = vim_strsave(spats[RE_SEARCH].pat); *************** *** 374,381 **** --- 380,395 ---- void restore_last_search_pattern(void) { + if (did_save_last_search_spat != 1) + { + IEMSG("did_save_last_search_spat is not one"); + return; + } + --did_save_last_search_spat; + vim_free(spats[RE_SEARCH].pat); spats[RE_SEARCH] = saved_last_search_spat; + saved_last_search_spat.pat = NULL; # if defined(FEAT_EVAL) set_vv_searchforward(); # endif *** ../vim-8.1.0551/src/version.c 2018-11-28 21:20:34.096221686 +0100 --- src/version.c 2018-11-30 21:47:47.412181458 +0100 *************** *** 794,795 **** --- 794,797 ---- { /* Add new patch number below this line */ + /**/ + 552, /**/ -- SIGIRO -- irony detected (iron core dumped) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///