value: Get rid of value_str(), value_str_rw(), value_num().
[pspp] / src / language / stats / aggregate.c
index 4d95e62e64f6ea098bad20b7e181927a6a0271a2..c0d1438ecb4849609b00c1a8a5c68516de41dd5a 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 2008, 2009, 2010, 2011, 2012, 2014 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -224,7 +224,7 @@ cmd_aggregate (struct lexer *lexer, struct dataset *ds)
          lex_match (lexer, T_EQUALS);
          if (!lex_match_id (lexer, "COLUMNWISE"))
            {
-             lex_error_expecting (lexer, "COLUMNWISE", NULL);
+             lex_error_expecting (lexer, "COLUMNWISE");
               goto error;
            }
          agr.missing = COLUMNWISE;
@@ -470,7 +470,6 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict,
        {
          if (function->src_vars == AGR_SV_YES)
            {
-              lex_force_match (lexer, T_LPAREN);
              goto error;
            }
        }
@@ -639,7 +638,7 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict,
 
            free (dest[i]);
            if (dest_label[i])
-              var_set_label (destvar, dest_label[i], true);
+              var_set_label (destvar, dest_label[i]);
 
            v->dest = destvar;
          }
@@ -734,7 +733,7 @@ agr_destroy (struct agr_proc *agr)
       free (iter);
     }
   if (agr->dict != NULL)
-    dict_destroy (agr->dict);
+    dict_unref (agr->dict);
 }
 \f
 /* Execution. */
@@ -811,8 +810,8 @@ accumulate_aggregate_info (struct agr_proc *agr, const struct ccase *input)
            break;
          case MAX | FSTRING:
             /* Need to do some kind of Unicode collation thingy here */
-           if (memcmp (iter->string, value_str (v, src_width), src_width) < 0)
-             memcpy (iter->string, value_str (v, src_width), src_width);
+           if (memcmp (iter->string, v->s, src_width) < 0)
+             memcpy (iter->string, v->s, src_width);
            iter->int1 = 1;
            break;
          case MIN:
@@ -820,8 +819,8 @@ accumulate_aggregate_info (struct agr_proc *agr, const struct ccase *input)
            iter->int1 = 1;
            break;
          case MIN | FSTRING:
-           if (memcmp (iter->string, value_str (v, src_width), src_width) > 0)
-             memcpy (iter->string, value_str (v, src_width), src_width);
+           if (memcmp (iter->string, v->s, src_width) > 0)
+             memcpy (iter->string, v->s, src_width);
            iter->int1 = 1;
            break;
          case FGT:
@@ -832,8 +831,7 @@ accumulate_aggregate_info (struct agr_proc *agr, const struct ccase *input)
             break;
          case FGT | FSTRING:
          case PGT | FSTRING:
-            if (memcmp (iter->arg[0].c,
-                        value_str (v, src_width), src_width) < 0)
+            if (memcmp (iter->arg[0].c, v->s, src_width) < 0)
               iter->dbl[0] += weight;
             iter->dbl[1] += weight;
             break;
@@ -845,8 +843,7 @@ accumulate_aggregate_info (struct agr_proc *agr, const struct ccase *input)
             break;
          case FLT | FSTRING:
          case PLT | FSTRING:
-            if (memcmp (iter->arg[0].c,
-                        value_str (v, src_width), src_width) > 0)
+            if (memcmp (iter->arg[0].c, v->s, src_width) > 0)
               iter->dbl[0] += weight;
             iter->dbl[1] += weight;
             break;
@@ -858,10 +855,8 @@ accumulate_aggregate_info (struct agr_proc *agr, const struct ccase *input)
             break;
          case FIN | FSTRING:
          case PIN | FSTRING:
-            if (memcmp (iter->arg[0].c,
-                        value_str (v, src_width), src_width) <= 0
-                && memcmp (iter->arg[1].c,
-                           value_str (v, src_width), src_width) >= 0)
+            if (memcmp (iter->arg[0].c, v->s, src_width) <= 0
+                && memcmp (iter->arg[1].c, v->s, src_width) >= 0)
               iter->dbl[0] += weight;
             iter->dbl[1] += weight;
             break;
@@ -873,10 +868,8 @@ accumulate_aggregate_info (struct agr_proc *agr, const struct ccase *input)
             break;
          case FOUT | FSTRING:
          case POUT | FSTRING:
-            if (memcmp (iter->arg[0].c,
-                        value_str (v, src_width), src_width) > 0
-                || memcmp (iter->arg[1].c,
-                           value_str (v, src_width), src_width) < 0)
+            if (memcmp (iter->arg[0].c, v->s, src_width) > 0
+                || memcmp (iter->arg[1].c, v->s, src_width) < 0)
               iter->dbl[0] += weight;
             iter->dbl[1] += weight;
             break;
@@ -898,7 +891,7 @@ accumulate_aggregate_info (struct agr_proc *agr, const struct ccase *input)
          case FIRST | FSTRING:
            if (iter->int1 == 0)
              {
-               memcpy (iter->string, value_str (v, src_width), src_width);
+               memcpy (iter->string, v->s, src_width);
                iter->int1 = 1;
              }
            break;
@@ -907,7 +900,7 @@ accumulate_aggregate_info (struct agr_proc *agr, const struct ccase *input)
            iter->int1 = 1;
            break;
          case LAST | FSTRING:
-           memcpy (iter->string, value_str (v, src_width), src_width);
+           memcpy (iter->string, v->s, src_width);
            iter->int1 = 1;
            break;
           case NMISS:
@@ -1025,7 +1018,7 @@ dump_aggregate_info (const struct agr_proc *agr, struct casewriter *output, cons
          case MAX | FSTRING:
          case MIN | FSTRING:
            if (i->int1)
-             memcpy (value_str_rw (v, width), i->string, width);
+             memcpy (v->s, i->string, width);
            else
               value_set_missing (v, width);
            break;
@@ -1064,7 +1057,7 @@ dump_aggregate_info (const struct agr_proc *agr, struct casewriter *output, cons
          case FIRST | FSTRING:
          case LAST | FSTRING:
            if (i->int1)
-             memcpy (value_str_rw (v, width), i->string, width);
+             memcpy (v->s, i->string, width);
            else
               value_set_missing (v, width);
            break;