Redo VFM interface. Get rid of compaction_necessary, compaction_nval,
[pspp-builds.git] / src / list.q
index 174c7ead573ad9f30900bb4b9d4851b565ec8aea..c875e6f53a17d81136879c37db39a109db956974 100644 (file)
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    02111-1307, USA. */
 
-/* AIX requires this to be the first thing in the file.  */
 #include <config.h>
-#if __GNUC__
-#define alloca __builtin_alloca
-#else
-#if HAVE_ALLOCA_H
-#include <alloca.h>
-#else
-#ifdef _AIX
-#pragma alloca
-#else
-#ifndef alloca                 /* predefined by HP cc +Olibcalls */
-char *alloca ();
-#endif
-#endif
-#endif
-#endif
-
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include "alloc.h"
 #include "command.h"
+#include "devind.h"
 #include "lexer.h"
 #include "error.h"
 #include "magic.h"
@@ -47,6 +31,7 @@ char *alloca ();
 #include "htmlP.h"
 #include "output.h"
 #include "som.h"
+#include "tab.h"
 #include "var.h"
 #include "vfm.h"
 #include "format.h"
@@ -92,11 +77,11 @@ static int n_chars_width (struct outp_driver *d);
 static void write_line (struct outp_driver *d, char *s);
 
 /* Other functions. */
-static int list_cases (struct ccase *);
+static int list_cases (struct ccase *, void *);
 static void determine_layout (void);
 static void clean_up (void);
 static void write_header (struct outp_driver *);
-static void write_all_headers (void);
+static void write_all_headers (void *);
 
 /* Returns the number of text lines that can fit on the remainder of
    the page. */
@@ -152,8 +137,8 @@ cmd_list (void)
   if (cmd.last == NOT_LONG)
     cmd.last = LONG_MAX;
   if (!cmd.sbc_variables)
-    fill_all_vars (&cmd.v_variables, &cmd.n_variables,
-                  FV_NO_SYSTEM | FV_NO_SCRATCH);
+    dict_get_vars (default_dict, &cmd.v_variables, &cmd.n_variables,
+                  (1u << DC_SYSTEM) | (1u << DC_SCRATCH));
   if (cmd.n_variables == 0)
     {
       msg (SE, _("No variables specified."));
@@ -192,13 +177,12 @@ cmd_list (void)
   /* Weighting variable. */
   if (cmd.weight == LST_WEIGHT)
     {
-      update_weighting (&default_dict);
-      if (default_dict.weight_index != -1)
+      if (dict_get_weight (default_dict) != NULL)
        {
          int i;
 
          for (i = 0; i < cmd.n_variables; i++)
-           if (cmd.v_variables[i]->index == default_dict.weight_index)
+           if (cmd.v_variables[i] == dict_get_weight (default_dict))
              break;
          if (i >= cmd.n_variables)
            {
@@ -208,7 +192,7 @@ cmd_list (void)
                                          (cmd.n_variables
                                           * sizeof *cmd.v_variables));
              cmd.v_variables[cmd.n_variables - 1]
-               = default_dict.var[default_dict.weight_index];
+                = dict_get_weight (default_dict);
            }
        }
       else
@@ -243,7 +227,7 @@ cmd_list (void)
   determine_layout ();
 
   case_num = 0;
-  procedure (write_all_headers, list_cases, NULL);
+  procedure_with_splits (write_all_headers, list_cases, NULL, NULL);
   free (line_buf);
 
   clean_up ();
@@ -254,7 +238,7 @@ cmd_list (void)
 /* Writes headers to all devices.  This is done at the beginning of
    each SPLIT FILE group. */
 static void
-write_all_headers (void)
+write_all_headers (void *aux UNUSED)
 {
   struct outp_driver *d;
 
@@ -269,7 +253,7 @@ write_all_headers (void)
        {
          struct html_driver_ext *x = d->ext;
   
-         assert (d->driver_open && d->page_open);
+         assert (d->driver_open);
          if (x->sequence_no == 0 && !d->class->open_page (d))
            {
              msg (ME, _("Cannot open first page on HTML device %s."),
@@ -289,6 +273,10 @@ write_all_headers (void)
 
          fputs ("  <TR>\n", x->file.file);
        }
+      else if (d->class == &devind_class) 
+        {
+          /* FIXME */
+        }
       else
        assert (0);
     }
@@ -407,6 +395,10 @@ clean_up (void)
            fputs ("</TABLE>\n", x->file.file);
          }
       }
+    else if (d->class == &devind_class) 
+      {
+        /* FIXME */
+      }
     else
       assert (0);
   
@@ -538,6 +530,12 @@ determine_layout (void)
 
       if (d->class == &html_class)
        continue;
+      else if (d->class == &devind_class) 
+        {
+          /* FIXME */
+          tab_output_text (TAT_NONE, "(devind not supported on LIST yet)");
+          continue;
+        }
       
       assert (d->class->special == 0);
 
@@ -620,7 +618,7 @@ determine_layout (void)
 }
 
 static int
-list_cases (struct ccase *c)
+list_cases (struct ccase *c, void *aux UNUSED)
 {
   struct outp_driver *d;
   
@@ -671,19 +669,15 @@ list_cases (struct ccase *c)
                memset(&line_buf[x], ' ', width - v->print.w);
                x += width - v->print.w;
              }
-         
-           {
-             union value value;
-           
-             if (formats[v->print.type].cat & FCAT_STRING)
-               value.c = c->data[v->fv].s;
-             else if (v->fv == -1)
-               value.f = case_num;
-             else
-               value.f = c->data[v->fv].f;
-               
-             data_out (&line_buf[x], &v->print, &value);
-           }
+
+            if ((formats[v->print.type].cat & FCAT_STRING) || v->fv != -1)
+             data_out (&line_buf[x], &v->print, &c->data[v->fv]);
+            else 
+              {
+                union value case_num_value;
+                case_num_value.f = case_num;
+                data_out (&line_buf[x], &v->print, &case_num_value); 
+              }
            x += v->print.w;
          
            line_buf[x++] = ' ';
@@ -708,17 +702,16 @@ list_cases (struct ccase *c)
        for (column = 0; column < cmd.n_variables; column++)
          {
            struct variable *v = cmd.v_variables[column];
-           union value value;
            char buf[41];
            
-           if (formats[v->print.type].cat & FCAT_STRING)
-             value.c = c->data[v->fv].s;
-           else if (v->fv == -1)
-             value.f = case_num;
-           else
-             value.f = c->data[v->fv].f;
-               
-           data_out (buf, &v->print, &value);
+            if ((formats[v->print.type].cat & FCAT_STRING) || v->fv != -1)
+             data_out (buf, &v->print, &c->data[v->fv]);
+            else 
+              {
+                union value case_num_value;
+                case_num_value.f = case_num;
+                data_out (buf, &v->print, &case_num_value); 
+              }
            buf[v->print.w] = 0;
 
            fprintf (x->file.file, "    <TD ALIGN=RIGHT>%s</TD>\n",
@@ -727,6 +720,10 @@ list_cases (struct ccase *c)
          
        fputs ("  </TR>\n", x->file.file);
       }
+    else if (d->class == &devind_class) 
+      {
+        /* FIXME */
+      }
     else
       assert (0);