To: vim-dev@vim.org Subject: Patch 6.2.349 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.349 Problem: Finding a match using 'matchpairs' may cause a crash. 'matchpairs' is not used for 'showmatch'. Solution: Don't look past the NUL in 'matchpairs'. Use 'matchpairs' for 'showmatch'. (Dave Olszewkski) Files: src/misc1.c, src/normal.c, src/proto/search.pro, src/search.c *** ../vim-6.2.348/src/misc1.c Mon Mar 8 12:27:39 2004 --- src/misc1.c Fri Mar 12 11:45:19 2004 *************** *** 1943,1958 **** #ifdef FEAT_MBYTE && charlen == 1 #endif ! #ifdef FEAT_RIGHTLEFT ! && ((!(curwin->w_p_rl ^ p_ri) ! && (c == ')' || c == '}' || c == ']')) ! || ((curwin->w_p_rl ^ p_ri) ! && (c == '(' || c == '{' || c == '['))) ! #else ! && (c == ')' || c == '}' || c == ']') ! #endif ! ) ! showmatch(); #ifdef FEAT_RIGHTLEFT if (!p_ri || (State & REPLACE_FLAG)) --- 1943,1950 ---- #ifdef FEAT_MBYTE && charlen == 1 #endif ! ) ! showmatch(c); #ifdef FEAT_RIGHTLEFT if (!p_ri || (State & REPLACE_FLAG)) *** ../vim-6.2.348/src/normal.c Tue Mar 9 19:49:08 2004 --- src/normal.c Fri Mar 12 11:46:51 2004 *************** *** 6188,6199 **** */ ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE); ptr[curwin->w_cursor.col] = cap->nchar; ! if ( p_sm ! && msg_silent == 0 ! && (cap->nchar == ')' ! || cap->nchar == '}' ! || cap->nchar == ']')) ! showmatch(); ++curwin->w_cursor.col; } #ifdef FEAT_NETBEANS_INTG --- 6191,6198 ---- */ ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE); ptr[curwin->w_cursor.col] = cap->nchar; ! if (p_sm && msg_silent == 0) ! showmatch(cap->nchar); ++curwin->w_cursor.col; } #ifdef FEAT_NETBEANS_INTG *** ../vim-6.2.348/src/proto/search.pro Sun Jun 1 12:26:19 2003 --- src/proto/search.pro Fri Mar 12 11:54:07 2004 *************** *** 14,20 **** int searchc __ARGS((cmdarg_T *cap, int t_cmd)); pos_T *findmatch __ARGS((oparg_T *oap, int initc)); pos_T *findmatchlimit __ARGS((oparg_T *oap, int initc, int flags, int maxtravel)); ! void showmatch __ARGS((void)); int findsent __ARGS((int dir, long count)); int findpar __ARGS((oparg_T *oap, int dir, long count, int what, int both)); int startPS __ARGS((linenr_T lnum, int para, int both)); --- 14,20 ---- int searchc __ARGS((cmdarg_T *cap, int t_cmd)); pos_T *findmatch __ARGS((oparg_T *oap, int initc)); pos_T *findmatchlimit __ARGS((oparg_T *oap, int initc, int flags, int maxtravel)); ! void showmatch __ARGS((int c)); int findsent __ARGS((int dir, long count)); int findpar __ARGS((oparg_T *oap, int dir, long count, int what, int both)); int startPS __ARGS((linenr_T lnum, int para, int both)); *** ../vim-6.2.348/src/search.c Sun Feb 15 13:49:38 2004 --- src/search.c Fri Mar 12 20:48:34 2004 *************** *** 1580,1585 **** --- 1580,1587 ---- backwards = FALSE; break; } + if (ptr[1] != ',') + break; } if (!findc) /* invalid initc! */ return NULL; *************** *** 2143,2159 **** * If there isn't a match, then beep. */ void ! showmatch() { ! pos_T *lpos, save_cursor; ! pos_T mpos; ! colnr_T vcol; ! long save_so; ! long save_siso; #ifdef CURSOR_SHAPE ! int save_state; #endif ! colnr_T save_dollar_vcol; if ((lpos = findmatch(NULL, NUL)) == NULL) /* no match, so beep */ vim_beep(); --- 2145,2184 ---- * If there isn't a match, then beep. */ void ! showmatch(c) ! int c; /* char to show match for */ { ! pos_T *lpos, save_cursor; ! pos_T mpos; ! colnr_T vcol; ! long save_so; ! long save_siso; #ifdef CURSOR_SHAPE ! int save_state; ! #endif ! colnr_T save_dollar_vcol; ! char_u *p; ! ! /* ! * Only show match for chars in the 'matchpairs' option. ! */ ! /* 'matchpairs' is "x:y,x:y" */ ! for (p = curbuf->b_p_mps; *p != NUL; p += 2) ! { ! #ifdef FEAT_RIGHTLEFT ! if (*p == c && (curwin->w_p_rl ^ p_ri)) ! break; ! #endif ! p += 2; ! if (*p == c ! #ifdef FEAT_RIGHTLEFT ! && !(curwin->w_p_rl ^ p_ri) #endif ! ) ! break; ! if (p[1] != ',') ! return; ! } if ((lpos = findmatch(NULL, NUL)) == NULL) /* no match, so beep */ vim_beep(); *** ../vim-6.2.348/src/version.c Fri Mar 12 20:42:24 2004 --- src/version.c Fri Mar 12 21:09:02 2004 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 349, /**/ -- hundred-and-one symptoms of being an internet addict: 22. You've already visited all the links at Yahoo and you're halfway through Lycos. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///