]> granicus.if.org Git - vim/commitdiff
patch 9.0.0380: deleting files in tests is a hassle v9.0.0380
authorBram Moolenaar <Bram@vim.org>
Sun, 4 Sep 2022 17:10:11 +0000 (18:10 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 4 Sep 2022 17:10:11 +0000 (18:10 +0100)
Problem:    Deleting files in tests is a hassle.
Solution:   Use the new 'D' flag of writefile().

src/vim9cmds.c

index c294d70a85193d508d81687c6ef6e966bbe5fa87..33e9be981cf4f84495e592eb60b7f0bc0478fcc4 100644 (file)
@@ -1705,6 +1705,27 @@ get_defer_var_idx(cctx_T *cctx)
     return dfunc->df_defer_var_idx;
 }
 
+/*
+ * Get the local variable index for deferred function calls.
+ * Reserve it when not done already.
+ * Returns zero for failure.
+ */
+    int
+get_defer_var_idx(cctx_T *cctx)
+{
+    dfunc_T    *dfunc = ((dfunc_T *)def_functions.ga_data)
+                                              + cctx->ctx_ufunc->uf_dfunc_idx;
+    if (dfunc->df_defer_var_idx == 0)
+    {
+       lvar_T *lvar = reserve_local(cctx, (char_u *)"@defer@", 7,
+                                                           TRUE, &t_list_any);
+       if (lvar == NULL)
+           return 0;
+       dfunc->df_defer_var_idx = lvar->lv_idx + 1;
+    }
+    return dfunc->df_defer_var_idx;
+}
+
 /*
  * Compile "defer func(arg)".
  */