]> granicus.if.org Git - vim/commitdiff
patch 8.0.0137 v8.0.0137
authorBram Moolenaar <Bram@vim.org>
Mon, 2 Jan 2017 14:26:27 +0000 (15:26 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 2 Jan 2017 14:26:27 +0000 (15:26 +0100)
Problem:    When 'maxfuncdepth' is set above 200 the nesting is limited to
            200. (Brett Stahlman)
Solution:   Allow for Ex command recursion depending on 'maxfuncdepth'.

src/ex_docmd.c
src/testdir/test_nested_function.vim
src/version.c

index 1af60abd28b7b4f794c335a2a49c9a70550a0322..eebdcffb483dd53055c265a747d3f26217bac653 100644 (file)
@@ -787,8 +787,9 @@ do_cmdline(
 #endif
 
     /* It's possible to create an endless loop with ":execute", catch that
-     * here.  The value of 200 allows nested function calls, ":source", etc. */
-    if (call_depth == 200)
+     * here.  The value of 200 allows nested function calls, ":source", etc.
+     * Allow 200 or 'maxfuncdepth', whatever is larger. */
+    if (call_depth >= 200 && call_depth >= p_mfd)
     {
        EMSG(_("E169: Command too recursive"));
 #ifdef FEAT_EVAL
index 7e301ed33e4aec88443ab3004abe5f989da9e57c..afaaea6cebe4052414773ac91457d4411f9ef953 100644 (file)
@@ -40,3 +40,24 @@ func Test_nested_argument()
   delfunc g:X
   unlet g:Y
 endfunc
+
+func Recurse(count)
+  if a:count > 0
+    call Recurse(a:count - 1)
+  endif
+endfunc
+
+func Test_max_nesting()
+  let call_depth_here = 2
+  let ex_depth_here = 5
+  set mfd&
+
+  call Recurse(99 - call_depth_here)
+  call assert_fails('call Recurse(' . (100 - call_depth_here) . ')', 'E132:')
+
+  set mfd=210
+  call Recurse(209 - ex_depth_here)
+  call assert_fails('call Recurse(' . (210 - ex_depth_here) . ')', 'E169:')
+
+  set mfd&
+endfunc
index f4f20fa2614cc6a2b8877908b45c9ec09ca5cda1..4a2b3c72041d197a28ef4bd0cef3d273d955a6e3 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    137,
 /**/
     136,
 /**/