Hi Bram and list,

Although specify a string to {expr} in matchstrpos(), the return value may not 
be a list of 3 elements.

How to reproduce:
- Execute the following command from Vim. Note: The numerical value of the 
third argument must be greater than the character string length of the first 
argument. 
  :echo matchstrpos('testing', 'ing', 8)

Expect behavior:
result is ['', -1, -1]

Actual behavior:
result is ['', -1, -1, -1]


I wrote a patch with a test.
--
Best regards,
Hirohito Higashi (h_east)

-- 
-- 
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].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/evalfunc.c b/src/evalfunc.c
index c85c334..958b1bc 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -7472,12 +7472,11 @@ find_some_match(typval_T *argvars, typval_T *rettv, int type)
 	vim_regfree(regmatch.regprog);
     }
 
-    if (type == 4 && l == NULL)
+theend:
+    if (type == 4 && l == NULL && rettv->vval.v_list != NULL)
 	/* matchstrpos() without a list: drop the second item. */
 	listitem_remove(rettv->vval.v_list,
 				       rettv->vval.v_list->lv_first->li_next);
-
-theend:
     vim_free(tofree);
     p_cpo = save_cpo;
 }
diff --git a/src/testdir/test_match.vim b/src/testdir/test_match.vim
index 9398ef2..a78883a 100644
--- a/src/testdir/test_match.vim
+++ b/src/testdir/test_match.vim
@@ -152,13 +152,10 @@ endfunc
 
 func Test_matchstrpos()
   call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing'))
-
   call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing', 2))
-
   call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 5))
-
+  call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 8))
   call assert_equal(['ing', 1, 4, 7], matchstrpos(['vim', 'testing', 'execute'], 'ing'))
-
   call assert_equal(['', -1, -1, -1], matchstrpos(['vim', 'testing', 'execute'], 'img'))
 endfunc
 

Raspunde prin e-mail lui