We've had a mix of min, max from libpspp/misc.h and MIN, MAX from
[pspp-builds.git] / src / language / data-io / list.q
index 8bb55106e96554e10f78321f5376336275b101ea..d4e24cddfb0e9313b98a74e9dd1121ae7fd8e03f 100644 (file)
@@ -26,6 +26,7 @@
 #include "size_max.h"
 #include <data/case.h>
 #include <data/dictionary.h>
+#include <data/data-out.h>
 #include <data/format.h>
 #include <data/procedure.h>
 #include <data/variable.h>
@@ -43,6 +44,8 @@
 #include <output/output.h>
 #include <output/table.h>
 
+#include "minmax.h"
+
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 
@@ -129,12 +132,12 @@ write_line (struct outp_driver *d, const char *s)
     
 /* Parses and executes the LIST procedure. */
 int
-cmd_list (struct dataset *ds)
+cmd_list (struct lexer *lexer, struct dataset *ds)
 {
   struct variable casenum_var;
   bool ok;
 
-  if (!parse_list (ds, &cmd, NULL))
+  if (!parse_list (lexer, ds, &cmd, NULL))
     return CMD_FAILURE;
   
   /* Fill in defaults. */
@@ -213,9 +216,9 @@ cmd_list (struct dataset *ds)
       strcpy (casenum_var.name, "Case#");
       casenum_var.type = NUMERIC;
       casenum_var.fv = -1;
-      casenum_var.print = make_output_format (FMT_F,
-                                              (cmd.last == LONG_MAX
-                                               ? 5 : intlog10 (cmd.last)), 0);
+      casenum_var.print = fmt_for_output (FMT_F,
+                                          (cmd.last == LONG_MAX
+                                           ? 5 : intlog10 (cmd.last)), 0);
 
       /* Add the weight variable at the beginning of the variable list. */
       cmd.n_variables++;
@@ -325,7 +328,7 @@ write_header (struct outp_driver *d)
          struct variable *v = cmd.v_variables[i];
          
          memset (&prc->header[prc->header_rows - 1][x], '-',
-                 max (v->print.w, (int) strlen (v->name)));
+                 MAX (v->print.w, (int) strlen (v->name)));
          if ((int) strlen (v->name) < v->print.w)
            x += v->print.w - strlen (v->name);
          memcpy (&prc->header[0][x], v->name, strlen (v->name));
@@ -532,7 +535,7 @@ determine_layout (void)
       outp_open_page (d);
       
       max_width = n_chars_width (d);
-      largest_page_width = max (largest_page_width, max_width);
+      largest_page_width = MAX (largest_page_width, max_width);
 
       prc = d->prc = xmalloc (sizeof *prc);
       prc->type = 0;
@@ -543,7 +546,7 @@ determine_layout (void)
       for (width = cmd.n_variables - 1, column = 0; column < cmd.n_variables; column++)
        {
          struct variable *v = cmd.v_variables[column];
-         width += max (v->print.w, (int) strlen (v->name));
+         width += MAX (v->print.w, (int) strlen (v->name));
        }
       if (width <= max_width)
        {
@@ -573,7 +576,7 @@ determine_layout (void)
            {
              struct variable *v = cmd.v_variables[column];
              int trial_width = (width - v->print.w
-                                + max (v->print.w, (int) strlen (v->name)));
+                                + MAX (v->print.w, (int) strlen (v->name)));
              
              if (trial_width > max_width)
                {
@@ -589,7 +592,7 @@ determine_layout (void)
          for (prc->header_rows = 0, column = 0;
               column < prc->n_vertical;
               column++)
-           prc->header_rows = max (prc->header_rows,
+           prc->header_rows = MAX (prc->header_rows,
                                    strlen (cmd.v_variables[column]->name));
          prc->header_rows++;
          continue;
@@ -637,7 +640,7 @@ list_cases (const struct ccase *c, void *aux UNUSED, const struct dataset *ds UN
            int width;
 
            if (prc->type == 0 && column >= prc->n_vertical)
-             width = max ((int) strlen (v->name), v->print.w);
+             width = MAX ((int) strlen (v->name), v->print.w);
            else
              width = v->print.w;
 
@@ -664,17 +667,17 @@ list_cases (const struct ccase *c, void *aux UNUSED, const struct dataset *ds UN
                ds_put_char_multiple(&line_buffer, ' ', width - v->print.w);
              }
 
-            if ((formats[v->print.type].cat & FCAT_STRING) || v->fv != -1)
+            if (fmt_is_string (v->print.type) || v->fv != -1)
              {
-                data_out (ds_put_uninit(&line_buffer, v->print.w),
-                         &v->print, case_data (c, v->fv));
+                data_out (case_data (c, v->fv), &v->print,
+                          ds_put_uninit (&line_buffer, v->print.w));
              }
             else 
               {
                 union value case_idx_value;
                 case_idx_value.f = case_idx;
-                data_out (ds_put_uninit(&line_buffer,v->print.w), 
-                         &v->print,   &case_idx_value); 
+                data_out (&case_idx_value, &v->print,
+                          ds_put_uninit (&line_buffer,v->print.w)); 
               }
 
            ds_put_char(&line_buffer, ' ');
@@ -701,13 +704,13 @@ list_cases (const struct ccase *c, void *aux UNUSED, const struct dataset *ds UN
            struct variable *v = cmd.v_variables[column];
            char buf[256];
            
-            if ((formats[v->print.type].cat & FCAT_STRING) || v->fv != -1)
-             data_out (buf, &v->print, case_data (c, v->fv));
+            if (fmt_is_string (v->print.type) || v->fv != -1)
+             data_out (case_data (c, v->fv), &v->print, buf);
             else 
               {
                 union value case_idx_value;
                 case_idx_value.f = case_idx;
-                data_out (buf, &v->print, &case_idx_value); 
+                data_out (&case_idx_value, &v->print, buf);
               }
 
             fputs ("    <TD>", x->file);