Patch #5209
[pspp-builds.git] / src / language / data-io / get.c
index cdae706653af17a12965ed1f3b85b6dabb10cc9e..789d259e6cbb1a3a197788ff92ed64b7d3f439e8 100644 (file)
@@ -27,6 +27,7 @@
 #include <data/case-source.h>
 #include <data/case.h>
 #include <data/casefile.h>
+#include <data/fastfile.h>
 #include <data/dictionary.h>
 #include <data/por-file-writer.h>
 #include <data/procedure.h>
@@ -39,7 +40,9 @@
 #include <language/command.h>
 #include <language/data-io/file-handle.h>
 #include <language/lexer/lexer.h>
+#include <language/lexer/variable-parser.h>
 #include <libpspp/alloc.h>
+#include <libpspp/assertion.h>
 #include <libpspp/compiler.h>
 #include <libpspp/hash.h>
 #include <libpspp/message.h>
@@ -439,6 +442,8 @@ parse_write_command (enum writer_type writer_type,
     }
   else
     aw->writer = any_writer_open (handle, dict);
+  if (aw->writer == NULL)
+    goto error;
   dict_destroy (dict);
   
   return aw;
@@ -840,7 +845,7 @@ cmd_match_files (void)
           saw_table = true;
         }
       else
-        assert (0);
+        NOT_REACHED ();
       lex_match ('=');
 
       file->by = NULL;
@@ -1122,7 +1127,7 @@ cmd_match_files (void)
     discard_variables ();
 
   dict_compact_values (mtf.dict);
-  mtf.output = casefile_create (dict_get_next_value_idx (mtf.dict));
+  mtf.output = fastfile_create (dict_get_next_value_idx (mtf.dict));
   mtf.seq_nums = xcalloc (dict_get_var_cnt (mtf.dict), sizeof *mtf.seq_nums);
   case_create (&mtf.mtf_case, dict_get_next_value_idx (mtf.dict));
 
@@ -1139,6 +1144,7 @@ cmd_match_files (void)
 
   discard_variables ();
 
+  dict_destroy (default_dict);
   default_dict = mtf.dict;
   mtf.dict = NULL;
   proc_set_source (storage_source_create (mtf.output));
@@ -1165,7 +1171,7 @@ mtf_processing_finish (void *mtf_)
     if (iter->handle == NULL)
       {
         if (!mtf_delete_file_in_place (mtf, &iter))
-          abort ();
+          NOT_REACHED ();
         break;
       }
   
@@ -1540,8 +1546,11 @@ mtf_merge_dictionary (struct dictionary *const m, struct mtf_file *f)
           if (dv->width == mv->width)
             {
               if (val_labs_count (dv->val_labs)
-                  && !val_labs_count (mv->val_labs))
-                mv->val_labs = val_labs_copy (dv->val_labs);
+                  && !val_labs_count (mv->val_labs)) 
+                {
+                  val_labs_destroy (mv->val_labs);
+                  mv->val_labs = val_labs_copy (dv->val_labs); 
+                }
               if (!mv_is_empty (&dv->miss) && mv_is_empty (&mv->miss))
                 mv_copy (&mv->miss, &dv->miss);
             }