GET: Fix confusion over the type of the 'type' parameter.
[pspp-builds.git] / src / language / data-io / get.c
index aa2b91fe6a92d3a8259c6475c597869c007ca12b..d32f25567a25dcfd28cf7b3dad7189cc2bee29f6 100644 (file)
@@ -22,9 +22,9 @@
 #include "data/case-map.h"
 #include "data/case.h"
 #include "data/casereader.h"
+#include "data/dataset.h"
 #include "data/dictionary.h"
 #include "data/por-file-writer.h"
-#include "data/procedure.h"
 #include "language/command.h"
 #include "language/data-io/file-handle.h"
 #include "language/data-io/trim.h"
@@ -66,7 +66,8 @@ cmd_import (struct lexer *lexer, struct dataset *ds)
 
 /* Parses a GET or IMPORT command. */
 static int
-parse_read_command (struct lexer *lexer, struct dataset *ds, enum reader_command type)
+parse_read_command (struct lexer *lexer, struct dataset *ds,
+                    enum reader_command command)
 {
   struct casereader *reader = NULL;
   struct file_handle *fh = NULL;
@@ -82,21 +83,18 @@ parse_read_command (struct lexer *lexer, struct dataset *ds, enum reader_command
          lex_match (lexer, T_EQUALS);
 
           fh_unref (fh);
-         fh = fh_parse (lexer, FH_REF_FILE | FH_REF_SCRATCH);
+         fh = fh_parse (lexer, FH_REF_FILE, NULL);
          if (fh == NULL)
             goto error;
        }
-      else if (type == IMPORT_CMD && lex_match_id (lexer, "TYPE"))
+      else if (command == IMPORT_CMD && lex_match_id (lexer, "TYPE"))
        {
          lex_match (lexer, T_EQUALS);
 
-         if (lex_match_id (lexer, "COMM"))
-           type = PFM_COMM;
-         else if (lex_match_id (lexer, "TAPE"))
-           type = PFM_TAPE;
-         else
+         if (!lex_match_id (lexer, "COMM")
+              && !lex_match_id (lexer, "TAPE"))
            {
-             lex_error (lexer, _("expecting %s or %s"), "COMM", "TAPE");
+             lex_error_expecting (lexer, "COMM", "TAPE", NULL_SENTINEL);
               goto error;
            }
        }
@@ -106,7 +104,7 @@ parse_read_command (struct lexer *lexer, struct dataset *ds, enum reader_command
 
   if (fh == NULL)
     {
-      lex_sbc_missing (lexer, "FILE");
+      lex_sbc_missing ("FILE");
       goto error;
     }
 
@@ -128,7 +126,8 @@ parse_read_command (struct lexer *lexer, struct dataset *ds, enum reader_command
   if (map != NULL)
     reader = case_map_create_input_translator (map, reader);
 
-  proc_set_active_file (ds, reader, dict);
+  dataset_set_dict (ds, dict);
+  dataset_set_source (ds, reader);
 
   fh_unref (fh);
   return CMD_SUCCESS;