psppire-output-view: Consistently apply "transparent" and "systemcolors".
[pspp] / src / language / stats / aggregate.c
index 678ea5334afd6e7c9692252fe0f049468cda30d4..965e6e3903d420fc044f9d038671dab840ff03f8 100644 (file)
@@ -206,7 +206,7 @@ cmd_aggregate (struct lexer *lexer, struct dataset *ds)
        goto error;
     }
 
-  if ( agr.add_variables )
+  if (agr.add_variables)
     agr.dict = dict_clone (dict);
   else
     agr.dict = dict_create (dict_get_encoding (dict));
@@ -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;
@@ -312,7 +312,7 @@ cmd_aggregate (struct lexer *lexer, struct dataset *ds)
 
       initialize_aggregate_info (&agr);
 
-      if ( agr.add_variables )
+      if (agr.add_variables)
        placeholder = casereader_clone (group);
 
       {
@@ -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;
            }
        }
@@ -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:
@@ -941,7 +934,7 @@ dump_aggregate_info (const struct agr_proc *agr, struct casewriter *output, cons
 {
   struct ccase *c = case_create (dict_get_proto (agr->dict));
 
-  if ( agr->add_variables)
+  if (agr->add_variables)
     {
       case_copy (c, 0, break_case, 0, dict_get_var_cnt (agr->src_dict));
     }
@@ -987,7 +980,7 @@ dump_aggregate_info (const struct agr_proc *agr, struct casewriter *output, cons
            break;
          case MEDIAN:
            {
-             if ( i->writer)
+             if (i->writer)
                {
                  struct percentile *median = percentile_create (0.5, i->cc);
                  struct order_stats *os = &median->parent;
@@ -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;
@@ -1119,10 +1112,10 @@ initialize_aggregate_info (struct agr_proc *agr)
             proto = caseproto_add_width (proto, 0);
             proto = caseproto_add_width (proto, 0);
 
-           if ( ! iter->subject)
+           if (! iter->subject)
              iter->subject = dict_create_internal_var (0, 0);
 
-           if ( ! iter->weight)
+           if (! iter->weight)
              iter->weight = dict_create_internal_var (1, 0);
 
             subcase_init_var (&ordering, iter->subject, SC_ASCEND);