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);
}
}
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;
}
for (function = agr_func_tab; function->name; function++)
- if (!strcmp (function->name, tokid))
+ if (!strcasecmp (function->name, tokid))
break;
if (NULL == function->name)
{
/* Create the target variable in the aggregate
dictionary. */
{
+ static const struct fmt_spec f8_2 = {FMT_F, 8, 2};
struct variable *destvar;
v->function = func_index;
}
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 == N_NO_VARS
- || func_index == NMISS)
- && dict_get_weight (default_dict) != NULL)
+ if (destvar != NULL)
{
- static const struct fmt_spec f8_2 = {FMT_F, 8, 2};
-
- destvar->print = destvar->write = f8_2;
+ 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->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);
+ if (func_index == N_NO_VARS
+ && dict_get_weight (default_dict) != NULL)
+ destvar->print = destvar->write = f8_2;
+ else
+ destvar->print = destvar->write = function->format;
}
if (!destvar)
"the aggregate variables and the break "
"variables."),
dest[i]);
- free (dest[i]);
goto error;
}
switch (iter->function)
{
case NMISS:
+ case NMISS | FSTRING:
iter->dbl[0] += weight;
break;
case NUMISS:
+ case NUMISS | FSTRING:
iter->int1++;
break;
}
{
case SUM:
iter->dbl[0] += v->f * weight;
+ iter->int1 = 1;
break;
case MEAN:
iter->dbl[0] += v->f * weight;
case FOUT | FSTRING:
case POUT | FSTRING:
if (memcmp (iter->arg[0].c, v->s, iter->src->width) > 0
- && memcmp (iter->arg[1].c, v->s, iter->src->width) < 0)
+ || memcmp (iter->arg[1].c, v->s, iter->src->width) < 0)
iter->dbl[0] += weight;
iter->dbl[1] += weight;
break;
&& (i->function & FUNC) != N && (i->function & FUNC) != NU
&& (i->function & FUNC) != NMISS && (i->function & FUNC) != NUMISS)
{
- if (i->function & FSTRING)
+ if (i->dest->type == ALPHA)
memset (v->s, ' ', i->dest->width);
else
v->f = SYSMIS;
switch (i->function)
{
case SUM:
- v->f = i->dbl[0];
+ v->f = i->int1 ? i->dbl[0] : SYSMIS;
break;
case MEAN:
v->f = i->dbl[1] != 0.0 ? i->dbl[0] / i->dbl[1] : SYSMIS;
else
memset (v->s, ' ', i->dest->width);
break;
- case FGT | FSTRING:
- case FLT | FSTRING:
- case FIN | FSTRING:
- case FOUT | FSTRING:
- v->f = i->int2 ? (double) i->int1 / (double) i->int2 : SYSMIS;
- break;
case FGT:
+ case FGT | FSTRING:
case FLT:
+ case FLT | FSTRING:
case FIN:
+ case FIN | FSTRING:
case FOUT:
+ case FOUT | FSTRING:
v->f = i->dbl[1] ? i->dbl[0] / i->dbl[1] : SYSMIS;
break;
case PGT:
for (iter = agr->agr_vars; iter; iter = iter->next)
{
iter->missing = 0;
+ iter->dbl[0] = iter->dbl[1] = iter->dbl[2] = 0.0;
+ iter->int1 = iter->int2 = 0;
switch (iter->function)
{
case MIN:
iter->dbl[0] = DBL_MAX;
- iter->int1 = 0;
break;
case MIN | FSTRING:
memset (iter->string, 255, iter->src->width);
break;
case MAX:
iter->dbl[0] = -DBL_MAX;
- iter->int1 = 0;
break;
case MAX | FSTRING:
memset (iter->string, 0, iter->src->width);
else
moments1_clear (iter->moments);
break;
- default:
- iter->dbl[0] = iter->dbl[1] = iter->dbl[2] = 0.0;
- iter->int1 = iter->int2 = 0;
- break;
+ default:
+ break;
}
}
}