First step in making struct variable opaque: the boring mechanical
[pspp-builds.git] / src / language / stats / flip.c
index 465ea79c65ae2211279aa38c085c5c16b0fc1276..a8f135806640ffb7888fccdcb0e04ea57c96ef70 100644 (file)
@@ -49,6 +49,7 @@
 #include <libpspp/str.h>
 
 #include "intprops.h"
+#include "minmax.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -231,7 +232,7 @@ make_new_var (struct dictionary *dict, char name[])
 
     for (i = 1; i < 10000000; i++)
       {
-       int ofs = min (7 - intlog10 (i), len);
+       int ofs = MIN (7 - intlog10 (i), len);
        memcpy (n, name, ofs);
        sprintf (&n[ofs], "%d", i);
 
@@ -300,7 +301,7 @@ flip_sink_create (struct dictionary *dict, struct flip_pgm *flip)
   /* Write variable names as first case. */
   for (i = 0; i < flip->var_cnt; i++) 
     buf_copy_str_rpad (flip->output_buf[i].s, MAX_SHORT_STRING,
-                       flip->var[i]->name);
+                       var_get_name (flip->var[i]));
   if (fwrite (flip->output_buf, sizeof *flip->output_buf,
               flip->var_cnt, flip->file) != (size_t) flip->var_cnt) 
     {
@@ -327,7 +328,7 @@ flip_sink_write (struct case_sink *sink, const struct ccase *c)
     {
       struct varname *v = pool_alloc (flip->pool, sizeof *v);
       v->next = NULL;
-      if (flip->new_names->type == NUMERIC) 
+      if (var_is_numeric (flip->new_names))
         {
           double f = case_num (c, flip->idx_to_fv[flip->new_names->index]);
 
@@ -342,7 +343,7 @@ flip_sink_write (struct case_sink *sink, const struct ccase *c)
         }
       else
        {
-         int width = min (flip->new_names->width, MAX_SHORT_STRING);
+         int width = MIN (var_get_width (flip->new_names), MAX_SHORT_STRING);
          memcpy (v->name, case_str (c, flip->idx_to_fv[flip->new_names->index]),
                   width);
          v->name[width] = 0;
@@ -360,7 +361,7 @@ flip_sink_write (struct case_sink *sink, const struct ccase *c)
     {
       double out;
       
-      if (flip->var[i]->type == NUMERIC)
+      if (var_is_numeric (flip->var[i]))
         out = case_num (c, flip->idx_to_fv[flip->var[i]->index]);
       else
         out = SYSMIS;
@@ -430,7 +431,7 @@ flip_file (struct flip_pgm *flip)
   
   for (case_idx = 0; case_idx < flip->case_cnt; )
     {
-      unsigned long read_cases = min (flip->case_cnt - case_idx,
+      unsigned long read_cases = MIN (flip->case_cnt - case_idx,
                                       case_capacity);
       size_t i;