Continue reforming procedure execution. In this phase, get rid of
[pspp-builds.git] / src / language / data-io / get.c
index c6ae3ed3090f6e3f2a0aa5a8edd11e63b89173cb..b9634b1942d645ba1d86aad729fca50b19e9ca2c 100644 (file)
    02110-1301, USA. */
 
 #include <config.h>
-#include "message.h"
+
 #include <stdlib.h>
-#include "alloc.h"
-#include "any-reader.h"
-#include "any-writer.h"
-#include "case.h"
-#include "command.h"
-#include "dictionary.h"
-#include "message.h"
-#include "file-handle.h"
-#include "hash.h"
-#include "lexer.h"
-#include "misc.h"
-#include "por-file-writer.h"
-#include "settings.h"
-#include "sys-file-writer.h"
-#include "str.h"
-#include "value-labels.h"
-#include "variable.h"
-#include "procedure.h"
+
+#include <data/any-reader.h>
+#include <data/any-writer.h>
+#include <data/case-sink.h>
+#include <data/case-source.h>
+#include <data/case.h>
+#include <data/dictionary.h>
+#include <data/por-file-writer.h>
+#include <data/settings.h>
+#include <data/storage-stream.h>
+#include <data/sys-file-writer.h>
+#include <data/transformations.h>
+#include <data/value-labels.h>
+#include <data/variable.h>
+#include <language/command.h>
+#include <language/data-io/file-handle.h>
+#include <language/lexer/lexer.h>
+#include <libpspp/alloc.h>
+#include <libpspp/compiler.h>
+#include <libpspp/hash.h>
+#include <libpspp/message.h>
+#include <libpspp/message.h>
+#include <libpspp/misc.h>
+#include <libpspp/str.h>
+#include <procedure.h>
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 
-#include "debug-print.h"
-
 /* Rearranging and reducing a dictionary. */
 static void start_case_map (struct dictionary *);
 static struct case_map *finish_case_map (struct dictionary *);
@@ -143,7 +148,7 @@ parse_read_command (enum reader_command type)
   dict_destroy (default_dict);
   default_dict = dict;
 
-  vfm_source = create_case_source (&case_reader_source_class, pgm);
+  proc_set_source (create_case_source (&case_reader_source_class, pgm));
 
   return CMD_SUCCESS;
 
@@ -734,8 +739,6 @@ keep_variables (struct dictionary *dict)
 \f
 /* MATCH FILES. */
 
-#include "debug-print.h"
-
 /* File types. */
 enum
   {
@@ -885,22 +888,18 @@ cmd_match_files (void)
             }
           used_active_file = true;
 
-          assert (pgm_state != STATE_INPUT);
-          if (pgm_state == STATE_INIT)
+          if (!proc_has_source ())
             {
               msg (SE, _("Cannot specify the active file since no active "
                          "file has been defined."));
               goto error;
             }
 
-          if (temporary != 0)
-            {
-              msg (SE,
-                   _("MATCH FILES may not be used after TEMPORARY when "
-                     "the active file is an input source.  "
-                     "Temporary transformations will be made permanent."));
-              cancel_temporary (); 
-            }
+          if (proc_make_temporary_transformations_permanent ())
+            msg (SE,
+                 _("MATCH FILES may not be used after TEMPORARY when "
+                   "the active file is an input source.  "
+                   "Temporary transformations will be made permanent."));
 
           file->dict = default_dict;
         }
@@ -1133,17 +1132,18 @@ cmd_match_files (void)
     goto error;
 
   if (used_active_file) 
-    ok = procedure (mtf_processing, &mtf) && mtf_processing_finish (&mtf);
+    {
+      proc_set_sink (create_case_sink (&null_sink_class, default_dict, NULL));
+      ok = procedure (mtf_processing, &mtf) && mtf_processing_finish (&mtf); 
+    }
   else
     ok = mtf_processing_finish (&mtf);
 
-  free_case_source (vfm_source);
-  vfm_source = NULL;
+  discard_variables ();
 
-  dict_destroy (default_dict);
   default_dict = mtf.dict;
   mtf.dict = NULL;
-  vfm_source = mtf.sink->class->make_source (mtf.sink);
+  proc_set_source (mtf.sink->class->make_source (mtf.sink));
   free_case_sink (mtf.sink);
   
   if (!mtf_free (&mtf))