Patch 8.2.2885
Problem:    searching for \%'> does not match linewise end of line. (Tim Chase)
Solution:   Match end of line if column is MAXCOL. (closes #8238)
Files:      src/regexp_nfa.c, src/regexp_bt.c, src/testdir/test_search.vim


*** ../vim-8.2.2884/src/regexp_nfa.c    2021-05-03 20:01:40.805808533 +0200
--- src/regexp_nfa.c    2021-05-24 22:47:54.100335969 +0200
***************
*** 6806,6827 ****
              {
                pos_T   *pos = getmark_buf(rex.reg_buf, t->state->val, FALSE);
  
!               // Compare the mark position to the match position.
!               result = (pos != NULL                // mark doesn't exist
!                       && pos->lnum > 0    // mark isn't set in reg_buf
!                       && (pos->lnum == rex.lnum + rex.reg_firstlnum
!                               ? (pos->col == (colnr_T)(rex.input - rex.line)
                                    ? t->state->c == NFA_MARK
!                                   : (pos->col < (colnr_T)(rex.input - 
rex.line)
                                        ? t->state->c == NFA_MARK_GT
                                        : t->state->c == NFA_MARK_LT))
                                : (pos->lnum < rex.lnum + rex.reg_firstlnum
                                    ? t->state->c == NFA_MARK_GT
!                                   : t->state->c == NFA_MARK_LT)));
!               if (result)
!               {
!                   add_here = TRUE;
!                   add_state = t->state->out;
                }
                break;
              }
--- 6806,6835 ----
              {
                pos_T   *pos = getmark_buf(rex.reg_buf, t->state->val, FALSE);
  
!               // Compare the mark position to the match position, if the mark
!               // exists and mark is set in reg_buf.
!               if (pos != NULL && pos->lnum > 0)
!               {
!                   colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum
!                                                         && pos->col == MAXCOL
!                                     ? (colnr_T)STRLEN(reg_getline(
!                                               pos->lnum - rex.reg_firstlnum))
!                                     : pos->col;
! 
!                   result = (pos->lnum == rex.lnum + rex.reg_firstlnum
!                               ? (pos_col == (colnr_T)(rex.input - rex.line)
                                    ? t->state->c == NFA_MARK
!                                   : (pos_col < (colnr_T)(rex.input - rex.line)
                                        ? t->state->c == NFA_MARK_GT
                                        : t->state->c == NFA_MARK_LT))
                                : (pos->lnum < rex.lnum + rex.reg_firstlnum
                                    ? t->state->c == NFA_MARK_GT
!                                   : t->state->c == NFA_MARK_LT));
!                   if (result)
!                   {
!                       add_here = TRUE;
!                       add_state = t->state->out;
!                   }
                }
                break;
              }
*** ../vim-8.2.2884/src/regexp_bt.c     2021-05-03 20:01:40.801808547 +0200
--- src/regexp_bt.c     2021-05-24 22:48:29.044239238 +0200
***************
*** 3357,3373 ****
  
                pos = getmark_buf(rex.reg_buf, mark, FALSE);
                if (pos == NULL              // mark doesn't exist
!                       || pos->lnum <= 0    // mark isn't set in reg_buf
!                       || (pos->lnum == rex.lnum + rex.reg_firstlnum
!                               ? (pos->col == (colnr_T)(rex.input - rex.line)
                                    ? (cmp == '<' || cmp == '>')
!                                   : (pos->col < (colnr_T)(rex.input - 
rex.line)
                                        ? cmp != '>'
                                        : cmp != '<'))
                                : (pos->lnum < rex.lnum + rex.reg_firstlnum
                                    ? cmp != '>'
                                    : cmp != '<')))
                    status = RA_NOMATCH;
            }
            break;
  
--- 3357,3385 ----
  
                pos = getmark_buf(rex.reg_buf, mark, FALSE);
                if (pos == NULL              // mark doesn't exist
!                       || pos->lnum <= 0)   // mark isn't set in reg_buf
!               {
!                   status = RA_NOMATCH;
!               }
!               else
!               {
!                   colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum
!                                                         && pos->col == MAXCOL
!                                     ? (colnr_T)STRLEN(reg_getline(
!                                               pos->lnum - rex.reg_firstlnum))
!                                     : pos->col;
! 
!                   if ((pos->lnum == rex.lnum + rex.reg_firstlnum
!                               ? (pos_col == (colnr_T)(rex.input - rex.line)
                                    ? (cmp == '<' || cmp == '>')
!                                   : (pos_col < (colnr_T)(rex.input - rex.line)
                                        ? cmp != '>'
                                        : cmp != '<'))
                                : (pos->lnum < rex.lnum + rex.reg_firstlnum
                                    ? cmp != '>'
                                    : cmp != '<')))
                    status = RA_NOMATCH;
+               }
            }
            break;
  
*** ../vim-8.2.2884/src/testdir/test_search.vim 2021-04-21 15:11:18.153623383 
+0200
--- src/testdir/test_search.vim 2021-05-24 22:45:14.332783482 +0200
***************
*** 1332,1344 ****
    bwipe!
  endfunc
  
  func Test_search_sentence()
    new
    " this used to cause a crash
-   call assert_fails("/\\%')", 'E486:')
-   call assert_fails("/", 'E486:')
    /\%'(
    /
  endfunc
  
  " Test that there is no crash when there is a last search pattern but no last
--- 1332,1359 ----
    bwipe!
  endfunc
  
+ func Test_search_visual_area_linewise()
+   new
+   call setline(1, ['aa', 'bb', 'cc'])
+   exe "normal 2GV\<Esc>"
+   for engine in [1, 2]
+     exe 'set regexpengine=' .. engine
+     exe "normal gg/\\%'<\<CR>>"
+     call assert_equal([0, 2, 1, 0, 1], getcurpos(), 'engine ' .. engine)
+     exe "normal gg/\\%'>\<CR>"
+     call assert_equal([0, 2, 2, 0, 2], getcurpos(), 'engine ' .. engine)
+   endfor
+ 
+   bwipe!
+   set regexpengine&
+ endfunc
+ 
  func Test_search_sentence()
    new
    " this used to cause a crash
    /\%'(
    /
+   bwipe
  endfunc
  
  " Test that there is no crash when there is a last search pattern but no last
*** ../vim-8.2.2884/src/version.c       2021-05-24 19:37:17.529851135 +0200
--- src/version.c       2021-05-24 22:28:30.195602276 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2885,
  /**/

-- 
I'm sure that I asked CBuilder to do a "full" install.  Looks like I got
a "fool" install, instead.              Charles E Campbell, Jr, PhD


 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202105242057.14OKvHIs302006%40masaka.moolenaar.net.

Raspunde prin e-mail lui