X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Faggregate.c;h=4151860e109bc4e1c8cf49af8f65789140e25d48;hb=e784ed9c161b6b7aec1402de566e6c09cb2031e0;hp=9f0b271533888cc195c68637b9f569451d56e490;hpb=eeb5800b97c3d4e768fb3f7cbdabf54b3bd162b4;p=pspp diff --git a/src/language/stats/aggregate.c b/src/language/stats/aggregate.c index 9f0b271533..4151860e10 100644 --- a/src/language/stats/aggregate.c +++ b/src/language/stats/aggregate.c @@ -129,13 +129,13 @@ struct agr_proc /* Break variables. */ struct subcase sort; /* Sort criteria (break variables). */ const struct variable **break_vars; /* Break variables. */ - size_t break_var_cnt; /* Number of break variables. */ + size_t break_n_vars; /* Number of break variables. */ enum missing_treatment missing; /* How to treat missing values. */ struct agr_var *agr_vars; /* First aggregate variable. */ struct dictionary *dict; /* Aggregate dictionary. */ const struct dictionary *src_dict; /* Dict of the source */ - int case_cnt; /* Counts aggregated cases. */ + int n_cases; /* Counts aggregated cases. */ bool add_variables; /* True iff the aggregated variables should be appended to the existing dictionary */ @@ -241,10 +241,10 @@ cmd_aggregate (struct lexer *lexer, struct dataset *ds) if (!parse_sort_criteria (lexer, dict, &agr.sort, &agr.break_vars, &saw_direction)) goto error; - agr.break_var_cnt = subcase_get_n_fields (&agr.sort); + agr.break_n_vars = subcase_get_n_fields (&agr.sort); if (! agr.add_variables) - for (i = 0; i < agr.break_var_cnt; i++) + for (i = 0; i < agr.break_n_vars; i++) dict_clone_var_assert (agr.dict, agr.break_vars[i]); /* BREAK must follow the options. */ @@ -269,10 +269,10 @@ cmd_aggregate (struct lexer *lexer, struct dataset *ds) dict_clear_documents (agr.dict); /* Cancel SPLIT FILE. */ - dict_set_split_vars (agr.dict, NULL, 0); + dict_clear_split_vars (agr.dict); /* Initialize. */ - agr.case_cnt = 0; + agr.n_cases = 0; if (out_file == NULL) { @@ -297,7 +297,7 @@ cmd_aggregate (struct lexer *lexer, struct dataset *ds) } for (grouper = casegrouper_create_vars (input, agr.break_vars, - agr.break_var_cnt); + agr.break_n_vars); casegrouper_get_next_group (grouper, &group); casereader_destroy (group)) { @@ -565,7 +565,7 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, variables. */ for (i = 0; i < n_dest; i++) { - struct agr_var *v = xzalloc (sizeof *v); + struct agr_var *v = XZALLOC (struct agr_var); /* Add variable to chain. */ if (agr->agr_vars != NULL) @@ -708,7 +708,7 @@ agr_destroy (struct agr_proc *agr) { struct agr_var *iter, *next; - subcase_destroy (&agr->sort); + subcase_uninit (&agr->sort); free (agr->break_vars); for (iter = agr->agr_vars; iter; iter = next) { @@ -754,7 +754,7 @@ accumulate_aggregate_info (struct agr_proc *agr, const struct ccase *input) const union value *v = case_data (input, iter->src); int src_width = var_get_width (iter->src); - if (var_is_value_missing (iter->src, v, iter->exclude)) + if (var_is_value_missing (iter->src, v) & iter->exclude) { switch (iter->function) { @@ -789,12 +789,11 @@ accumulate_aggregate_info (struct agr_proc *agr, const struct ccase *input) cout = case_create (casewriter_get_proto (iter->writer)); - case_data_rw (cout, iter->subject)->f - = case_data (input, iter->src)->f; + *case_num_rw (cout, iter->subject) = case_num (input, iter->src); wv = dict_get_case_weight (agr->src_dict, input, NULL); - case_data_rw (cout, iter->weight)->f = wv; + *case_num_rw (cout, iter->weight) = wv; iter->cc += wv; @@ -936,14 +935,14 @@ dump_aggregate_info (const struct agr_proc *agr, struct casewriter *output, cons if (agr->add_variables) { - case_copy (c, 0, break_case, 0, dict_get_var_cnt (agr->src_dict)); + case_copy (c, 0, break_case, 0, dict_get_n_vars (agr->src_dict)); } else { int value_idx = 0; int i; - for (i = 0; i < agr->break_var_cnt; i++) + for (i = 0; i < agr->break_n_vars; i++) { const struct variable *v = agr->break_vars[i]; value_copy (case_data_rw_idx (c, value_idx), @@ -1120,7 +1119,7 @@ initialize_aggregate_info (struct agr_proc *agr) subcase_init_var (&ordering, iter->subject, SC_ASCEND); iter->writer = sort_create_writer (&ordering, proto); - subcase_destroy (&ordering); + subcase_uninit (&ordering); caseproto_unref (proto); iter->cc = 0;