Implemented long variable names a la spss V12.
[pspp-builds.git] / src / aggregate.c
index 47f34dcab440fc6fe81a573d512eb91398d8a8cf..6da6242c670a0be3fad5dfaf321f1db73cfd2495 100644 (file)
@@ -213,7 +213,9 @@ cmd_aggregate (void)
           for (i = 0; i < agr.break_var_cnt; i++)
             {
               struct variable *v = dict_clone_var (agr.dict, agr.break_vars[i],
-                                                   agr.break_vars[i]->name);
+                                                   agr.break_vars[i]->name, 
+                                                  agr.break_vars[i]->longname 
+                                                  );
               assert (v != NULL);
             }
 
@@ -276,7 +278,7 @@ cmd_aggregate (void)
     }
   else
     {
-      agr.writer = sfm_open_writer (out_file, agr.dict, get_scompression ());
+      agr.writer = sfm_open_writer (out_file, agr.dict, get_scompression (), 0);
       if (agr.writer == NULL)
         goto error;
       
@@ -396,7 +398,7 @@ parse_aggregate_functions (struct agr_proc *agr)
        }
       
       for (function = agr_func_tab; function->name; function++)
-       if (!strcmp (function->name, tokid))
+       if (!strcasecmp (function->name, tokid))
          break;
       if (NULL == function->name)
        {
@@ -540,21 +542,20 @@ parse_aggregate_functions (struct agr_proc *agr)
                  }
 
                if (function->alpha_type == ALPHA)
-                 destvar = dict_clone_var (agr->dict, v->src, dest[i]);
+                 destvar = dict_clone_var (agr->dict, v->src, 0, dest[i] );
                else if (v->src->type == NUMERIC
                          || function->alpha_type == NUMERIC)
                   {
                     destvar = dict_create_var (agr->dict, dest[i], 0);
-                        
-                    if ((func_index == N || func_index == NMISS)
-                        && dict_get_weight (default_dict) != NULL)
-                      destvar->print = destvar->write = f8_2; 
-                    else
-                      destvar->print = destvar->write = function->format;
+                    if (destvar != NULL) 
+                      {
+                        if ((func_index == N || func_index == NMISS)
+                            && dict_get_weight (default_dict) != NULL)
+                          destvar->print = destvar->write = f8_2; 
+                        else
+                          destvar->print = destvar->write = function->format;
+                      }
                   }
-                else 
-                  destvar = dict_create_var (agr->dict, dest[i],
-                                             v->src->width);
              } else {
                v->src = NULL;
                destvar = dict_create_var (agr->dict, dest[i], 0);
@@ -572,7 +573,6 @@ parse_aggregate_functions (struct agr_proc *agr)
                           "the aggregate variables and the break "
                           "variables."),
                     dest[i]);
-               free (dest[i]);
                goto error;
              }