Hi

This thread was in vim_use but I reckon it is more
appropriate to vim_dev now.

First A. Politz  noticed that with the cursor somewhere in
`text' in the example below,

   void fun( /*)*/text())

and with an appropriate function Skip() to reject the `)' in
the comment,

   :call searchpair('(','',')','bcW','Skip()')

would not move the cursor. This is caused by the `c' in the
flags. After finding the `)' in the comment the skip
function rejects it and it matches again. The cursor doesn't
move and do_searchpair() bails out.

And then today,

On 04/09/07, A.Politz <[EMAIL PROTECTED]> wrote:

 > There is another `problem`. The 'r' flag in searchpos()
 > searches for the outermost match, but this searches
 > forever if 'wrapscan' is set and the 'W' flag is not
 > given. Since this is pretty much useless in any case, 'r'
 > therefore should imply 'W'.
 >
 > This is the behaviour at least in this case :
 >
 > :set wrapscan
 >
 > f(a,b,c,d)
 >
 > Cursor on a comma and
 >
 > call searchpair('(',',',')','r')

Or even

   (,)

and use the same call to searchpair('(', ',', ')', 'r')
with the cursor on the `('.

Might the following patch help at all? (I've also included
it as an attachment because I expect gmail to insert
linebreaks, sorry.) I'm not sure about forcing 'W' if 'r' is
in the flags; having 'rw' in flags but getting 'W' behaviour
might cause hard-to-find bugs in somebody's script.
Disallowing the combination might be better. --Antony

*** eval.c.orig Tue Sep 04 22:22:42 2007
--- eval.c      Tue Sep 04 22:42:20 2007
***************
*** 14015,14020 ****
--- 14015,14023 ----
        options |= SEARCH_START;
      if (flags & SP_END)
        options |= SEARCH_END;
+     /* Force 'W' if 'r' is in flags. */
+     if (flags & SP_REPEAT)
+       p_ws = FALSE;

      /* Optional extra argument: line number to stop searching. */
      if (argvars[1].v_type != VAR_UNKNOWN
***************
*** 14275,14280 ****
--- 14278,14287 ----
      {
        n = searchit(curwin, curbuf, &pos, dir, pat, 1L,
                                               options, RE_SEARCH, lnum_stop);
+       /* Clear the flag for a match at the starting position: it only makes
+        * sense for the very first search. Otherwise, in conjunction with
+        * the skip function, it can cause an early termination of the loop. */
+       options &= !SEARCH_START;
        if (n == FAIL || (firstpos.lnum != 0 && equalpos(pos, firstpos)))
            /* didn't find it or found the first match again: FAIL */
            break;

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Attachment: eval.c.diff
Description: Binary data

Raspunde prin e-mail lui