Make the expression code a little nicer and fix bugs found
[pspp-builds.git] / src / data-list.c
index a5ec8da24cbae3ba5eb36a36e7a953995ad3566f..92be7cb8d51615400c473f74a697dfd232caf870 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <config.h>
 #include "data-list.h"
-#include <assert.h>
+#include "error.h"
 #include <ctype.h>
 #include <float.h>
 #include <stdio.h>
@@ -111,9 +111,6 @@ cmd_data_list (void)
   /* 0=print no table, 1=print table.  (TABLE subcommand.)  */
   int table = -1;
 
-  lex_match_id ("DATA");
-  lex_match_id ("LIST");
-
   if (!case_source_is_complex (vfm_source))
     discard_variables ();
 
@@ -237,6 +234,9 @@ cmd_data_list (void)
        dump_free_table (dls);
     }
 
+  if (!dfm_open_for_reading (dls->handle))
+    goto error;
+
   if (vfm_source != NULL)
     {
       struct data_list_pgm *new_pgm;
@@ -783,7 +783,7 @@ dump_fixed_table (const struct dls_var_spec *specs,
                    fmt_to_string (&spec->input));
     }
 
-  filename = fh_handle_name (handle);
+  filename = handle_get_filename (handle);
   if (filename == NULL)
     filename = "";
   buf = local_alloc (strlen (filename) + INT_DIGITS + 80);
@@ -797,7 +797,6 @@ dump_fixed_table (const struct dls_var_spec *specs,
   
   tab_title (t, 0, buf);
   tab_submit (t);
-  fh_handle_name (NULL);
   local_free (buf);
 }
 \f
@@ -915,7 +914,7 @@ dump_free_table (const struct data_list_pgm *dls)
   {
     const char *filename;
 
-    filename = fh_handle_name (dls->handle);
+    filename = handle_get_filename (dls->handle);
     if (filename == NULL)
       filename = "";
     tab_title (t, 1,
@@ -926,7 +925,6 @@ dump_free_table (const struct data_list_pgm *dls)
   }
   
   tab_submit (t);
-  fh_handle_name (NULL);
 }
 \f
 /* Input procedure. */ 
@@ -1013,6 +1011,7 @@ get_data_list_read_func (const struct data_list_pgm *dls)
 
     default:
       assert (0);
+      abort ();
     }
 }
 
@@ -1322,9 +1321,6 @@ cmd_repeating_data (void)
   /* Bits are set when a particular subcommand has been seen. */
   unsigned seen = 0;
   
-  lex_match_id ("REPEATING");
-  lex_match_id ("DATA");
-
   assert (case_source_is_complex (vfm_source));
 
   rpd = xmalloc (sizeof *rpd);
@@ -1539,9 +1535,9 @@ cmd_repeating_data (void)
 
   /* Calculate starts_end, cont_end if necessary. */
   if (rpd->starts_end.num == 0 && rpd->starts_end.var == NULL)
-    rpd->starts_end.num = fh_record_width (rpd->handle);
+    rpd->starts_end.num = handle_get_record_width (rpd->handle);
   if (rpd->cont_end.num == 0 && rpd->starts_end.var == NULL)
-    rpd->cont_end.num = fh_record_width (rpd->handle);
+    rpd->cont_end.num = handle_get_record_width (rpd->handle);
       
   /* Calculate length if possible. */
   if ((seen & 4) == 0)