]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
updated for version 7.0-084 v7.0.084
authorBram Moolenaar <Bram@vim.org>
Tue, 5 Sep 2006 10:59:47 +0000 (10:59 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 5 Sep 2006 10:59:47 +0000 (10:59 +0000)
src/eval.c
src/getchar.c
src/globals.h
src/main.c
src/version.c

index 162cdf4c7be85ea792ee6dcfd979c140f9fab9be..5b5bfbc75b29e24ca32d113b3bf26976246918b2 100644 (file)
@@ -6074,6 +6074,10 @@ garbage_collect()
     tabpage_T  *tp;
 #endif
 
+    /* Only do this once. */
+    want_garbage_collect = FALSE;
+    may_garbage_collect = FALSE;
+
     /*
      * 1. Go through all accessible variables and mark all lists and dicts
      *    with copyID.
@@ -9636,7 +9640,9 @@ f_garbagecollect(argvars, rettv)
     typval_T   *argvars;
     typval_T   *rettv;
 {
-    garbage_collect();
+    /* This is postponed until we are back at the toplevel, because we may be
+     * using Lists and Dicts internally.  E.g.: ":echo [garbagecollect()]". */
+    want_garbage_collect = TRUE;
 }
 
 /*
index 7d2cfd786c4849695cd4c95512d4123975a6b1a9..f840e0bd4b3bd0974e67933fad7b6e2998089480 100644 (file)
@@ -1451,7 +1451,8 @@ before_blocking()
 {
     updatescript(0);
 #ifdef FEAT_EVAL
-    garbage_collect();
+    if (may_garbage_collect)
+       garbage_collect();
 #endif
 }
 
@@ -1502,6 +1503,13 @@ vgetc()
     int                i;
 #endif
 
+#ifdef FEAT_EVAL
+    /* Do garbage collection when garbagecollect() was called previously and
+     * we are now at the toplevel. */
+    if (may_garbage_collect && want_garbage_collect)
+       garbage_collect();
+#endif
+
     /*
      * If a character was put back with vungetc, it was already processed.
      * Return it directly.
@@ -1511,13 +1519,13 @@ vgetc()
        c = old_char;
        old_char = -1;
        mod_mask = old_mod_mask;
-       return c;
     }
-
-    mod_mask = 0x0;
-    last_recorded_len = 0;
-    for (;;)                   /* this is done twice if there are modifiers */
+    else
     {
+      mod_mask = 0x0;
+      last_recorded_len = 0;
+      for (;;)                 /* this is done twice if there are modifiers */
+      {
        if (mod_mask)           /* no mapping after modifier has been read */
        {
            ++no_mapping;
@@ -1695,8 +1703,20 @@ vgetc()
        }
 #endif
 
-       return c;
+       break;
+      }
     }
+
+#ifdef FEAT_EVAL
+    /*
+     * In the main loop "may_garbage_collect" can be set to do garbage
+     * collection in the first next vgetc().  It's disabled after that to
+     * avoid internally used Lists and Dicts to be freed.
+     */
+    may_garbage_collect = FALSE;
+#endif
+
+    return c;
 }
 
 /*
index 4106742a9a5776f02372de1e64deb62e8c7fca87..b768127fd8479abab4244cbf92a3c11cbe9caca1 100644 (file)
@@ -300,9 +300,16 @@ EXTERN except_T *caught_stack INIT(= NULL);
 #endif
 
 #ifdef FEAT_EVAL
-EXTERN scid_T  current_SID INIT(= 0);      /* ID of script being sourced or
-                                              was sourced to define the
-                                              current function. */
+/* Garbage collection can only take place when we are sure there are no Lists
+ * or Dictionaries being used internally.  This is flagged with
+ * "may_garbage_collect" when we are at the toplevel.
+ * "want_garbage_collect" is set by the garbagecollect() function, which means
+ * we do garbage collection before waiting for a char at the toplevel. */
+EXTERN int     may_garbage_collect INIT(= FALSE);
+EXTERN int     want_garbage_collect INIT(= FALSE);
+
+/* ID of script being sourced or was sourced to define the current function. */
+EXTERN scid_T  current_SID INIT(= 0);
 #endif
 
 #if defined(FEAT_EVAL) || defined(FEAT_SYN_HL)
index 5051adbf97af1d2e5161d014cb415a69d15762ce..f903d06e2abdd4df84b2545bf8ea13bb5f20c07e 100644 (file)
@@ -1130,6 +1130,16 @@ main_loop(cmdwin, noexmode)
         */
        update_curswant();
 
+#ifdef FEAT_EVAL
+       /*
+        * May perform garbage collection when waiting for a character, but
+        * only at the very toplevel.  Otherwise we may be using a List or
+        * Dict internally somewhere.
+        * "may_garbage_collect" is reset in vgetc() which is invoked through
+        * do_exmode() and normal_cmd().
+        */
+       may_garbage_collect = (!cmdwin && !noexmode);
+#endif
        /*
         * If we're invoked as ex, do a round of ex commands.
         * Otherwise, get and execute a normal mode command.
index aeab51e4eea03a89cfbd1446c7ffb3be9a92fe56..cac03679ef58125e62bea7bf11f51e8e84eb4f5f 100644 (file)
@@ -666,6 +666,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    84,
 /**/
     83,
 /**/