To: vim_dev@googlegroups.com Subject: Patch 8.1.0288 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0288 Problem: Quickfix code uses cmdidx too often. Solution: Add is_loclist_cmd(). (Yegappan Lakshmanan) Files: src/ex_docmd.c, src/proto/ex_docmd.pro, src/quickfix.c *** ../vim-8.1.0287/src/ex_docmd.c 2018-08-14 16:06:09.451696062 +0200 --- src/ex_docmd.c 2018-08-15 20:53:22.429089025 +0200 *************** *** 12529,12534 **** --- 12529,12548 ---- } #endif + #ifdef FEAT_QUICKFIX + /* + * Returns TRUE if the supplied Ex cmdidx is for a location list command + * instead of a quickfix command. + */ + int + is_loclist_cmd(int cmdidx) + { + if (cmdidx < 0 || cmdidx > CMD_SIZE) + return FALSE; + return cmdnames[cmdidx].cmd_name[0] == 'l'; + } + #endif + # if defined(FEAT_TIMERS) || defined(PROTO) int get_pressedreturn(void) *** ../vim-8.1.0287/src/proto/ex_docmd.pro 2018-08-14 16:06:09.451696062 +0200 --- src/proto/ex_docmd.pro 2018-08-15 20:50:10.242164053 +0200 *************** *** 70,75 **** --- 70,76 ---- char_u *get_messages_arg(expand_T *xp, int idx); char_u *get_mapclear_arg(expand_T *xp, int idx); void set_no_hlsearch(int flag); + int is_loclist_cmd(int cmdidx); int get_pressedreturn(void); void set_pressedreturn(int val); /* vim: set ft=c : */ *** ../vim-8.1.0287/src/quickfix.c 2018-08-11 13:36:51.806140673 +0200 --- src/quickfix.c 2018-08-15 20:50:10.242164053 +0200 *************** *** 3330,3336 **** recognised errors */ qf_info_T *qi = &ql_info; ! if (eap->cmdidx == CMD_llist) { qi = GET_LOC_LIST(curwin); if (qi == NULL) --- 3330,3336 ---- recognised errors */ qf_info_T *qi = &ql_info; ! if (is_loclist_cmd(eap->cmdidx)) { qi = GET_LOC_LIST(curwin); if (qi == NULL) *************** *** 3478,3484 **** qf_info_T *qi = &ql_info; int count; ! if (eap->cmdidx == CMD_lolder || eap->cmdidx == CMD_lnewer) { qi = GET_LOC_LIST(curwin); if (qi == NULL) --- 3478,3484 ---- qf_info_T *qi = &ql_info; int count; ! if (is_loclist_cmd(eap->cmdidx)) { qi = GET_LOC_LIST(curwin); if (qi == NULL) *************** *** 3526,3532 **** qf_info_T *qi = &ql_info; int i; ! if (eap->cmdidx == CMD_lhistory) qi = GET_LOC_LIST(curwin); if (qi == NULL || (qi->qf_listcount == 0 && qf_list_empty(qi, qi->qf_curlist))) --- 3526,3532 ---- qf_info_T *qi = &ql_info; int i; ! if (is_loclist_cmd(eap->cmdidx)) qi = GET_LOC_LIST(curwin); if (qi == NULL || (qi->qf_listcount == 0 && qf_list_empty(qi, qi->qf_curlist))) *************** *** 3745,3751 **** qf_info_T *qi = &ql_info; win_T *win; ! if (eap->cmdidx == CMD_lwindow) { qi = GET_LOC_LIST(curwin); if (qi == NULL) --- 3745,3751 ---- qf_info_T *qi = &ql_info; win_T *win; ! if (is_loclist_cmd(eap->cmdidx)) { qi = GET_LOC_LIST(curwin); if (qi == NULL) *************** *** 3781,3787 **** win_T *win = NULL; qf_info_T *qi = &ql_info; ! if (eap->cmdidx == CMD_lclose || eap->cmdidx == CMD_lwindow) { qi = GET_LOC_LIST(curwin); if (qi == NULL) --- 3781,3787 ---- win_T *win = NULL; qf_info_T *qi = &ql_info; ! if (is_loclist_cmd(eap->cmdidx)) { qi = GET_LOC_LIST(curwin); if (qi == NULL) *************** *** 3808,3814 **** buf_T *qf_buf; win_T *oldwin = curwin; ! if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow) { qi = GET_LOC_LIST(curwin); if (qi == NULL) --- 3808,3814 ---- buf_T *qf_buf; win_T *oldwin = curwin; ! if (is_loclist_cmd(eap->cmdidx)) { qi = GET_LOC_LIST(curwin); if (qi == NULL) *************** *** 3953,3964 **** * :cbottom/:lbottom commands. */ void ! ex_cbottom(exarg_T *eap UNUSED) { qf_info_T *qi = &ql_info; win_T *win; ! if (eap->cmdidx == CMD_lbottom) { qi = GET_LOC_LIST(curwin); if (qi == NULL) --- 3953,3964 ---- * :cbottom/:lbottom commands. */ void ! ex_cbottom(exarg_T *eap) { qf_info_T *qi = &ql_info; win_T *win; ! if (is_loclist_cmd(eap->cmdidx)) { qi = GET_LOC_LIST(curwin); if (qi == NULL) *************** *** 4430,4437 **** enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; #endif ! if (eap->cmdidx == CMD_lmake || eap->cmdidx == CMD_lgrep ! || eap->cmdidx == CMD_lgrepadd) wp = curwin; autowrite_all(); --- 4430,4436 ---- enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; #endif ! if (is_loclist_cmd(eap->cmdidx)) wp = curwin; autowrite_all(); *************** *** 4570,4576 **** int i, sz = 0; int prev_fnum = 0; ! if (eap->cmdidx == CMD_ldo || eap->cmdidx == CMD_lfdo) { /* Location list */ qi = GET_LOC_LIST(curwin); --- 4569,4575 ---- int i, sz = 0; int prev_fnum = 0; ! if (is_loclist_cmd(eap->cmdidx)) { /* Location list */ qi = GET_LOC_LIST(curwin); *************** *** 4607,4613 **** { qf_info_T *qi = &ql_info; ! if (eap->cmdidx == CMD_ldo || eap->cmdidx == CMD_lfdo) { /* Location list */ qi = GET_LOC_LIST(curwin); --- 4606,4612 ---- { qf_info_T *qi = &ql_info; ! if (is_loclist_cmd(eap->cmdidx)) { /* Location list */ qi = GET_LOC_LIST(curwin); *************** *** 4631,4637 **** int i, eidx = 0; int prev_fnum = 0; ! if (eap->cmdidx == CMD_ldo || eap->cmdidx == CMD_lfdo) { /* Location list */ qi = GET_LOC_LIST(curwin); --- 4630,4636 ---- int i, eidx = 0; int prev_fnum = 0; ! if (is_loclist_cmd(eap->cmdidx)) { /* Location list */ qi = GET_LOC_LIST(curwin); *************** *** 4724,4735 **** qf_info_T *qi = &ql_info; int errornr; ! if (eap->cmdidx == CMD_ll ! || eap->cmdidx == CMD_lrewind ! || eap->cmdidx == CMD_lfirst ! || eap->cmdidx == CMD_llast ! || eap->cmdidx == CMD_ldo ! || eap->cmdidx == CMD_lfdo) { qi = GET_LOC_LIST(curwin); if (qi == NULL) --- 4723,4729 ---- qf_info_T *qi = &ql_info; int errornr; ! if (is_loclist_cmd(eap->cmdidx)) { qi = GET_LOC_LIST(curwin); if (qi == NULL) *************** *** 4743,4755 **** errornr = (int)eap->line2; else { ! if (eap->cmdidx == CMD_cc || eap->cmdidx == CMD_ll) ! errornr = 0; ! else if (eap->cmdidx == CMD_crewind || eap->cmdidx == CMD_lrewind ! || eap->cmdidx == CMD_cfirst || eap->cmdidx == CMD_lfirst) ! errornr = 1; ! else ! errornr = 32767; } /* For cdo and ldo commands, jump to the nth valid error. --- 4737,4754 ---- errornr = (int)eap->line2; else { ! switch (eap->cmdidx) ! { ! case CMD_cc: case CMD_ll: ! errornr = 0; ! break; ! case CMD_crewind: case CMD_lrewind: case CMD_cfirst: ! case CMD_lfirst: ! errornr = 1; ! break; ! default: ! errornr = 32767; ! } } /* For cdo and ldo commands, jump to the nth valid error. *************** *** 4774,4788 **** { qf_info_T *qi = &ql_info; int errornr; ! if (eap->cmdidx == CMD_lnext ! || eap->cmdidx == CMD_lNext ! || eap->cmdidx == CMD_lprevious ! || eap->cmdidx == CMD_lnfile ! || eap->cmdidx == CMD_lNfile ! || eap->cmdidx == CMD_lpfile ! || eap->cmdidx == CMD_ldo ! || eap->cmdidx == CMD_lfdo) { qi = GET_LOC_LIST(curwin); if (qi == NULL) --- 4773,4781 ---- { qf_info_T *qi = &ql_info; int errornr; + int dir; ! if (is_loclist_cmd(eap->cmdidx)) { qi = GET_LOC_LIST(curwin); if (qi == NULL) *************** *** 4799,4815 **** else errornr = 1; ! qf_jump(qi, (eap->cmdidx == CMD_cnext || eap->cmdidx == CMD_lnext ! || eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo) ! ? FORWARD ! : (eap->cmdidx == CMD_cnfile || eap->cmdidx == CMD_lnfile ! || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) ! ? FORWARD_FILE ! : (eap->cmdidx == CMD_cpfile || eap->cmdidx == CMD_lpfile ! || eap->cmdidx == CMD_cNfile || eap->cmdidx == CMD_lNfile) ! ? BACKWARD_FILE ! : BACKWARD, ! errornr, eap->forceit); } /* --- 4792,4819 ---- else errornr = 1; ! // Depending on the command jump to either next or previous entry/file. ! switch (eap->cmdidx) ! { ! case CMD_cnext: case CMD_lnext: case CMD_cdo: case CMD_ldo: ! dir = FORWARD; ! break; ! case CMD_cprevious: case CMD_lprevious: case CMD_cNext: ! case CMD_lNext: ! dir = BACKWARD; ! break; ! case CMD_cnfile: case CMD_lnfile: case CMD_cfdo: case CMD_lfdo: ! dir = FORWARD_FILE; ! break; ! case CMD_cpfile: case CMD_lpfile: case CMD_cNfile: case CMD_lNfile: ! dir = BACKWARD_FILE; ! break; ! default: ! dir = FORWARD; ! break; ! } ! ! qf_jump(qi, dir, errornr, eap->forceit); } /* *************** *** 4857,4865 **** if (*eap->arg != NUL) set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0); ! if (eap->cmdidx == CMD_lfile ! || eap->cmdidx == CMD_lgetfile ! || eap->cmdidx == CMD_laddfile) wp = curwin; /* --- 4861,4867 ---- if (*eap->arg != NUL) set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0); ! if (is_loclist_cmd(eap->cmdidx)) wp = curwin; /* *************** *** 5178,5187 **** #endif } ! if (eap->cmdidx == CMD_lgrep ! || eap->cmdidx == CMD_lvimgrep ! || eap->cmdidx == CMD_lgrepadd ! || eap->cmdidx == CMD_lvimgrepadd) { qi = ll_get_or_alloc_list(curwin); if (qi == NULL) --- 5180,5186 ---- #endif } ! if (is_loclist_cmd(eap->cmdidx)) { qi = ll_get_or_alloc_list(curwin); if (qi == NULL) *************** *** 6525,6533 **** } /* Must come after autocommands. */ ! if (eap->cmdidx == CMD_lbuffer ! || eap->cmdidx == CMD_lgetbuffer ! || eap->cmdidx == CMD_laddbuffer) { qi = ll_get_or_alloc_list(curwin); if (qi == NULL) --- 6524,6530 ---- } /* Must come after autocommands. */ ! if (is_loclist_cmd(eap->cmdidx)) { qi = ll_get_or_alloc_list(curwin); if (qi == NULL) *************** *** 6631,6639 **** #endif } ! if (eap->cmdidx == CMD_lexpr ! || eap->cmdidx == CMD_lgetexpr ! || eap->cmdidx == CMD_laddexpr) { qi = ll_get_or_alloc_list(curwin); if (qi == NULL) --- 6628,6634 ---- #endif } ! if (is_loclist_cmd(eap->cmdidx)) { qi = ll_get_or_alloc_list(curwin); if (qi == NULL) *************** *** 6922,6928 **** save_cpo = p_cpo; p_cpo = empty_option; ! if (eap->cmdidx == CMD_lhelpgrep) { qi = hgr_get_ll(&new_qi); if (qi == NULL) --- 6917,6923 ---- save_cpo = p_cpo; p_cpo = empty_option; ! if (is_loclist_cmd(eap->cmdidx)) { qi = hgr_get_ll(&new_qi); if (qi == NULL) *** ../vim-8.1.0287/src/version.c 2018-08-14 22:08:20.211616525 +0200 --- src/version.c 2018-08-15 20:51:09.609828450 +0200 *************** *** 796,797 **** --- 796,799 ---- { /* Add new patch number below this line */ + /**/ + 288, /**/ -- INSPECTOR END OF FILM: Move along. There's nothing to see! Keep moving! [Suddenly he notices the cameras.] INSPECTOR END OF FILM: (to Camera) All right, put that away sonny. [He walks over to it and puts his hand over the lens.] "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///