Remove "Written by Ben Pfaff <blp@gnu.org>" lines everywhere.
[pspp-builds.git] / src / language / data-io / matrix-data.c
index 6283279cad6effec032a93da06998a486af1e3be..f958584b5403f7442984e8922e783b355ec0e851 100644 (file)
@@ -1,6 +1,5 @@
 /* PSPP - computes sample statistics.
    Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
-   Written by Ben Pfaff <blp@gnu.org>.
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -44,6 +43,7 @@
 #include <libpspp/pool.h>
 #include <libpspp/str.h>
 
+#include "minmax.h"
 #include "size_max.h"
 
 #include "gettext.h"
@@ -350,8 +350,7 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds)
 
             for (i = 0; i < split_cnt; i++)
               {
-                struct mxd_var *mv = split[i]->aux;
-                assert (mv != NULL);
+                struct mxd_var *mv = var_get_aux (split[i]);
                if (mv->var_type != MXD_CONTINUOUS)
                  {
                    msg (SE, _("Split variable %s is already another type."),
@@ -384,8 +383,7 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds)
            for (i = 0; i < mx->n_factors; i++)
              {
                 struct variable *v = mx->factors[i];
-                struct mxd_var *mv = v->aux;
-                assert (mv != NULL);
+                struct mxd_var *mv = var_get_aux (v);
                if (mv->var_type != MXD_CONTINUOUS)
                  {
                    msg (SE, _("Factor variable %s is already another type."),
@@ -605,11 +603,11 @@ cmd_matrix_data (struct lexer *lexer, struct dataset *ds)
     for (i = 0; i < dict_get_var_cnt (dataset_dict (ds)); i++)
       {
        struct variable *v = dict_get_var (dataset_dict (ds), i);
-        struct mxd_var *mv = v->aux;
+        struct mxd_var *mv = var_get_aux (v);
        int type = mv->var_type;
        
        assert (type >= 0 && type < MXD_COUNT);
-       v->print = v->write = fmt_tab[type];
+        var_set_both_formats (v, &fmt_tab[type]);
 
        if (type == MXD_CONTINUOUS)
          mx->n_continuous++;
@@ -698,8 +696,8 @@ compare_variables_by_mxd_var_type (const void *a_, const void *b_)
 {
   struct variable *const *pa = a_;
   struct variable *const *pb = b_;
-  const struct mxd_var *a = (*pa)->aux;
-  const struct mxd_var *b = (*pb)->aux;
+  const struct mxd_var *a = var_get_aux (*pa);
+  const struct mxd_var *b = var_get_aux (*pb);
   
   if (a->var_type != b->var_type)
     return a->var_type > b->var_type ? 1 : -1;
@@ -714,7 +712,7 @@ attach_mxd_aux (struct variable *v, int var_type, int sub_type)
 {
   struct mxd_var *mv;
   
-  assert (v->aux == NULL);
+  assert (var_get_aux (v) == NULL);
   mv = xmalloc (sizeof *mv);
   mv->var_type = var_type;
   mv->sub_type = sub_type;
@@ -1084,7 +1082,7 @@ nr_read_data_lines (struct nr_aux_data *nr,
            if (token.type != MNUM)
              {
                msg (SE, _("expecting value for %s %s"),
-                    dict_get_var (nr->dict, j)->name,
+                    var_get_name (dict_get_var (nr->dict, j)),
                      context (mx->reader));
                return 0;
              }
@@ -1231,7 +1229,7 @@ nr_read_splits (struct nr_aux_data *nr, int compare)
     {
       if (!compare) 
         {
-          struct mxd_var *mv = dict_get_split_vars (nr->dict)[0]->aux;
+          struct mxd_var *mv = var_get_aux (dict_get_split_vars (nr->dict)[0]);
           nr->split_values[0] = ++mv->sub_type; 
         }
       return true;
@@ -1259,7 +1257,7 @@ nr_read_splits (struct nr_aux_data *nr, int compare)
         {
           msg (SE, _("Expecting value %g for %s."),
                nr->split_values[i],
-               dict_get_split_vars (nr->dict)[i]->name);
+               var_get_name (dict_get_split_vars (nr->dict)[i]));
           return false;
         }
     }
@@ -1309,7 +1307,7 @@ nr_read_factors (struct nr_aux_data *nr, int cell)
          {
            msg (SE, _("Syntax error expecting value %g for %s %s."),
                 nr->factor_values[i + mx->n_factors * cell],
-                mx->factors[i]->name, context (mx->reader));
+                var_get_name (mx->factors[i]), context (mx->reader));
            return false;
          }
       }
@@ -1330,11 +1328,11 @@ dump_cell_content (const struct dictionary *dict,
   int type = content_type[content];
 
   {
-    buf_copy_str_rpad (case_data_rw (c, mx->rowtype_->fv)->s, 8,
+    buf_copy_str_rpad (case_data_rw (c, mx->rowtype_)->s, 8,
                        content_names[content]);
     
     if (type != 1)
-      memset (case_data_rw (c, mx->varname_->fv)->s, ' ', 8);
+      memset (case_data_rw (c, mx->varname_)->s, ' ', 8);
   }
 
   {
@@ -1347,14 +1345,14 @@ dump_cell_content (const struct dictionary *dict,
 
        for (j = 0; j < mx->n_continuous; j++)
          {
-            int fv = dict_get_var (dict, mx->first_continuous + j)->fv;
-            case_data_rw (c, fv)->f = *cp;
+            struct variable *v = dict_get_var (dict, mx->first_continuous + j);
+            case_data_rw (c, v)->f = *cp;
            cp++;
          }
        if (type == 1)
-         buf_copy_str_rpad (case_data_rw (c, mx->varname_->fv)->s, 8,
-                             dict_get_var (dict,
-                                           mx->first_continuous + i)->name);
+         buf_copy_str_rpad (case_data_rw (c, mx->varname_)->s, 8,
+                             var_get_name (
+                               dict_get_var (dict, mx->first_continuous + i)));
        if (!write_case (wc_data))
           return false;
       }
@@ -1377,7 +1375,7 @@ nr_output_data (struct nr_aux_data *nr, struct ccase *c,
     split_cnt = dict_get_split_cnt (nr->dict);
     split = dict_get_split_vars (nr->dict);
     for (i = 0; i < split_cnt; i++)
-      case_data_rw (c, split[i]->fv)->f = nr->split_values[i];
+      case_data_rw (c, split[i])->f = nr->split_values[i];
   }
 
   if (mx->n_factors)
@@ -1390,7 +1388,7 @@ nr_output_data (struct nr_aux_data *nr, struct ccase *c,
            size_t factor;
 
            for (factor = 0; factor < mx->n_factors; factor++)
-              case_data_rw (c, mx->factors[factor]->fv)->f
+              case_data_rw (c, mx->factors[factor])->f
                 = nr->factor_values[factor + cell * mx->n_factors];
          }
          
@@ -1419,7 +1417,7 @@ nr_output_data (struct nr_aux_data *nr, struct ccase *c,
       size_t factor;
 
       for (factor = 0; factor < mx->n_factors; factor++)
-       case_data_rw (c, mx->factors[factor]->fv)->f = SYSMIS;
+       case_data_rw (c, mx->factors[factor])->f = SYSMIS;
     }
     
     for (content = 0; content <= PROX; content++)
@@ -1630,7 +1628,7 @@ wr_output_data (struct wr_aux_data *wr,
     split_cnt = dict_get_split_cnt (wr->dict);
     split = dict_get_split_vars (wr->dict);
     for (i = 0; i < split_cnt; i++)
-      case_data_rw (c, split[i]->fv)->f = wr->split_values[i];
+      case_data_rw (c, split[i])->f = wr->split_values[i];
   }
 
   /* Sort the wr->data list. */
@@ -1664,8 +1662,7 @@ wr_output_data (struct wr_aux_data *wr,
          size_t factor;
 
          for (factor = 0; factor < mx->n_factors; factor++)
-            case_data_rw (c, mx->factors[factor]->fv)->f
-              = iter->factors[factor];
+            case_data_rw (c, mx->factors[factor])->f = iter->factors[factor];
        }
        
        {
@@ -1737,8 +1734,8 @@ wr_read_rowtype (struct wr_aux_data *wr,
     char s[16];
     char *cp;
     
-    memcpy (s, token->string, min (15, token->length));
-    s[min (15, token->length)] = 0;
+    memcpy (s, token->string, MIN (15, token->length));
+    s[MIN (15, token->length)] = 0;
 
     for (cp = s; *cp; cp++)
       *cp = toupper ((unsigned char) *cp);
@@ -1956,7 +1953,8 @@ wr_read_indeps (struct wr_aux_data *wr)
        if (token.type != MNUM)
          {
            msg (SE, _("Syntax error expecting value for %s %s."),
-                 dict_get_var (wr->dict, mx->first_continuous + j)->name,
+                 var_get_name (dict_get_var (wr->dict,
+                                             mx->first_continuous + j)),
                  context (mx->reader));
            return false;
          }