Refactored to make it easier to abstract a dictionary from the rest of PSPP.
[pspp] / src / vfm.c
index 6d7e526bf1a5d66a015eb3658e4dd22184f2264b..b88d3eb13847f34e47d4e83e419f60f3a3f57b0d 100644 (file)
--- a/src/vfm.c
+++ b/src/vfm.c
@@ -30,6 +30,7 @@
 #include "alloc.h"
 #include "case.h"
 #include "casefile.h"
+#include "command.h"
 #include "dictionary.h"
 #include "do-ifP.h"
 #include "error.h"
@@ -907,3 +908,32 @@ multipass_split_output (struct multipass_split_aux_data *aux)
   casefile_destroy (aux->casefile);
   aux->casefile = NULL;
 }
+
+
+/* Discards all the current state in preparation for a data-input
+   command like DATA LIST or GET. */
+void
+discard_variables (void)
+{
+  dict_clear (default_dict);
+  default_handle = NULL;
+
+  n_lag = 0;
+  
+  if (vfm_source != NULL)
+    {
+      free_case_source (vfm_source);
+      vfm_source = NULL;
+    }
+
+  cancel_transformations ();
+
+  ctl_stack = NULL;
+
+  expr_free (process_if_expr);
+  process_if_expr = NULL;
+
+  cancel_temporary ();
+
+  pgm_state = STATE_INIT;
+}