X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fflip.c;h=b1e9c3b423facc42b46500b9ee1e5fc5c145e71b;hb=4f2f805c653f0dc901924944ea4c55309ff14d32;hp=c4242728a679dad1e1cd4df901bac6ad86686468;hpb=19d0debdc5b72e1bb6c79956403a4d3bc054f300;p=pspp diff --git a/src/language/stats/flip.c b/src/language/stats/flip.c index c4242728a6..b1e9c3b423 100644 --- a/src/language/stats/flip.c +++ b/src/language/stats/flip.c @@ -1,6 +1,5 @@ /* PSPP - computes sample statistics. Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. - Written by Ben Pfaff . This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -104,7 +103,7 @@ cmd_flip (struct lexer *lexer, struct dataset *ds) flip = pool_create_container (struct flip_pgm, pool); flip->var = NULL; - flip->idx_to_fv = dict_get_compacted_idx_to_fv (dict); + flip->idx_to_fv = dict_get_compacted_dict_index_to_case_index (dict); pool_register (flip->pool, free, flip->idx_to_fv); flip->var_cnt = 0; flip->case_cnt = 0; @@ -301,7 +300,7 @@ flip_sink_create (struct dictionary *dict, struct flip_pgm *flip) /* Write variable names as first case. */ for (i = 0; i < flip->var_cnt; i++) buf_copy_str_rpad (flip->output_buf[i].s, MAX_SHORT_STRING, - flip->var[i]->name); + var_get_name (flip->var[i])); if (fwrite (flip->output_buf, sizeof *flip->output_buf, flip->var_cnt, flip->file) != (size_t) flip->var_cnt) { @@ -327,10 +326,11 @@ flip_sink_write (struct case_sink *sink, const struct ccase *c) if (flip->new_names != NULL) { struct varname *v = pool_alloc (flip->pool, sizeof *v); + int fv = flip->idx_to_fv[var_get_dict_index (flip->new_names)]; v->next = NULL; - if (flip->new_names->type == NUMERIC) + if (var_is_numeric (flip->new_names)) { - double f = case_num (c, flip->idx_to_fv[flip->new_names->index]); + double f = case_num_idx (c, fv); if (f == SYSMIS) strcpy (v->name, "VSYSMIS"); @@ -343,9 +343,8 @@ flip_sink_write (struct case_sink *sink, const struct ccase *c) } else { - int width = MIN (flip->new_names->width, MAX_SHORT_STRING); - memcpy (v->name, case_str (c, flip->idx_to_fv[flip->new_names->index]), - width); + int width = MIN (var_get_width (flip->new_names), MAX_SHORT_STRING); + memcpy (v->name, case_str_idx (c, fv), width); v->name[width] = 0; } @@ -361,8 +360,11 @@ flip_sink_write (struct case_sink *sink, const struct ccase *c) { double out; - if (flip->var[i]->type == NUMERIC) - out = case_num (c, flip->idx_to_fv[flip->var[i]->index]); + if (var_is_numeric (flip->var[i])) + { + int fv = flip->idx_to_fv[var_get_dict_index (flip->var[i])]; + out = case_num_idx (c, fv); + } else out = SYSMIS; flip->output_buf[i].f = out; @@ -547,7 +549,7 @@ flip_source_read (struct case_source *source, } for (j = 0; j < flip->case_cnt; j++) - case_data_rw (c, j)->f = input_buf[j].f; + case_data_rw_idx (c, j)->f = input_buf[j].f; ok = write_case (wc_data); } free (input_buf);