To: vim_dev@googlegroups.com Subject: Patch 9.0.0950 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0950 Problem: The pattern "\_s\zs" matches at EOL. Solution: Make the pattern "\_s\zs" match at the start of the next line. (closes #11617) Files: src/regexp.c, src/regexp_nfa.c, src/search.c, src/testdir/test_search.vim *** ../vim-9.0.0949/src/regexp.c 2022-11-02 13:30:37.538314551 +0000 --- src/regexp.c 2022-11-25 21:12:07.747744484 +0000 *************** *** 1093,1099 **** #ifdef FEAT_SYN_HL static void cleanup_zsubexpr(void); #endif - static void reg_nextline(void); static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T end_lnum, colnr_T end_col, int *bytelen); /* --- 1093,1098 ---- *** ../vim-9.0.0949/src/regexp_nfa.c 2022-11-18 22:14:04.802988148 +0000 --- src/regexp_nfa.c 2022-11-25 21:11:38.483741462 +0000 *************** *** 1742,1748 **** break; } } ! semsg(_(e_nfa_regexp_unknown_operator_percent_chr), no_Magic(c)); return FAIL; } break; --- 1742,1749 ---- break; } } ! semsg(_(e_nfa_regexp_unknown_operator_percent_chr), ! no_Magic(c)); return FAIL; } break; *************** *** 4013,4019 **** for (j = 0; j < sub->in_use; j++) if (REG_MULTI) ! fprintf(log_fd, "*** group %d, start: c=%d, l=%d, end: c=%d, l=%d\n", j, sub->list.multi[j].start_col, (int)sub->list.multi[j].start_lnum, --- 4014,4021 ---- for (j = 0; j < sub->in_use; j++) if (REG_MULTI) ! fprintf(log_fd, ! "*** group %d, start: c=%d, l=%d, end: c=%d, l=%d\n", j, sub->list.multi[j].start_col, (int)sub->list.multi[j].start_lnum, *************** *** 4790,4796 **** { sub->list.multi[subidx].start_lnum = rex.lnum; sub->list.multi[subidx].start_col = ! (colnr_T)(rex.input - rex.line + off); } sub->list.multi[subidx].end_lnum = -1; } --- 4792,4798 ---- { sub->list.multi[subidx].start_lnum = rex.lnum; sub->list.multi[subidx].start_col = ! (colnr_T)(rex.input - rex.line + off); } sub->list.multi[subidx].end_lnum = -1; } *************** *** 6243,6249 **** } else if (!vim_iswordc_buf(curc, rex.reg_buf) || (rex.input > rex.line ! && vim_iswordc_buf(rex.input[-1], rex.reg_buf))) result = FALSE; if (result) { --- 6245,6251 ---- } else if (!vim_iswordc_buf(curc, rex.reg_buf) || (rex.input > rex.line ! && vim_iswordc_buf(rex.input[-1], rex.reg_buf))) result = FALSE; if (result) { *************** *** 6373,6379 **** case NFA_NEWL: if (curc == NUL && !rex.reg_line_lbr && REG_MULTI ! && rex.lnum <= rex.reg_maxline) { go_to_nextline = TRUE; // Pass -1 for the offset, which means taking the position --- 6375,6381 ---- case NFA_NEWL: if (curc == NUL && !rex.reg_line_lbr && REG_MULTI ! && rex.lnum <= rex.reg_maxline) { go_to_nextline = TRUE; // Pass -1 for the offset, which means taking the position *************** *** 7025,7031 **** && rex.lnum == 0 && clen != 0 && (rex.reg_maxcol == 0 ! || (colnr_T)(rex.input - rex.line) < rex.reg_maxcol)) || (nfa_endp != NULL && (REG_MULTI ? (rex.lnum < nfa_endp->se_u.pos.lnum --- 7027,7033 ---- && rex.lnum == 0 && clen != 0 && (rex.reg_maxcol == 0 ! || (colnr_T)(rex.input - rex.line) < rex.reg_maxcol)) || (nfa_endp != NULL && (REG_MULTI ? (rex.lnum < nfa_endp->se_u.pos.lnum *** ../vim-9.0.0949/src/search.c 2022-08-31 11:25:02.815996919 +0100 --- src/search.c 2022-11-25 20:51:39.419183005 +0000 *************** *** 793,798 **** --- 793,800 ---- if (dir == FORWARD && at_first_line) { match_ok = TRUE; + matchcol = col; + /* * When the match starts in a next line it's certainly * past the start position. *************** *** 837,843 **** } else { ! matchcol = matchpos.col; if (ptr[matchcol] != NUL) { if (has_mbyte) --- 839,847 ---- } else { ! // Advance "matchcol" to the next character. ! // This does not use matchpos.col, because ! // "\zs" may have have set it. if (ptr[matchcol] != NUL) { if (has_mbyte) *** ../vim-9.0.0949/src/testdir/test_search.vim 2022-10-10 22:39:38.203545897 +0100 --- src/testdir/test_search.vim 2022-11-25 21:01:16.715605265 +0000 *************** *** 1884,1890 **** set ignorecase& smartcase& let &encoding = save_enc ! close! endfunc " Test searching past the end of a file --- 1884,1890 ---- set ignorecase& smartcase& let &encoding = save_enc ! bwipe! endfunc " Test searching past the end of a file *************** *** 1893,1899 **** call setline(1, ['Line']) exe "normal /\\n\\zs\" call assert_equal([1, 4], [line('.'), col('.')]) ! close! endfunc " Test for various search offsets --- 1893,1921 ---- call setline(1, ['Line']) exe "normal /\\n\\zs\" call assert_equal([1, 4], [line('.'), col('.')]) ! bwipe! ! endfunc ! ! " Test setting the start of the match and still finding a next match in the ! " same line. ! func Test_search_set_start_same_line() ! new ! set cpo-=c ! ! call setline(1, ['1', '2', '3 .', '4', '5']) ! exe "normal /\\_s\\zs\\S\" ! call assert_equal([2, 1], [line('.'), col('.')]) ! exe 'normal n' ! call assert_equal([3, 1], [line('.'), col('.')]) ! exe 'normal n' ! call assert_equal([3, 3], [line('.'), col('.')]) ! exe 'normal n' ! call assert_equal([4, 1], [line('.'), col('.')]) ! exe 'normal n' ! call assert_equal([5, 1], [line('.'), col('.')]) ! ! set cpo+=c ! bwipe! endfunc " Test for various search offsets *** ../vim-9.0.0949/src/version.c 2022-11-25 16:31:46.972606656 +0000 --- src/version.c 2022-11-25 21:00:57.615597724 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 950, /**/ -- Fingers not found - Pound head on keyboard to continue. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///