From: Ben Pfaff Date: Wed, 25 Jul 2007 04:03:58 +0000 (+0000) Subject: Fix bugs #20493, #20494. X-Git-Tag: sav-api~1361 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;ds=inline;h=032679867d61ec9a4784aa5f4cf68bde67c5513e;p=pspp Fix bugs #20493, #20494. * flip.c (struct flip_pgm): Remove `case_size' member (now unused). (cmd_flip): Pass var_cnt as number of cases instead of case_cnt, to fix bug #20494. Don't assign to `case_size' member, which was unused after assignment. (build_dictionary): When NEWNAMES not used, get the number of variables right, to fix bug #20493. * tests/command/flip.sh: Add tests to avoid regression on bugs #20493, #20494. --- diff --git a/src/language/stats/ChangeLog b/src/language/stats/ChangeLog index 3ec57a78da..78a256afca 100644 --- a/src/language/stats/ChangeLog +++ b/src/language/stats/ChangeLog @@ -1,3 +1,13 @@ +2007-07-24 Ben Pfaff + + * flip.c (struct flip_pgm): Remove `case_size' member (now + unused). + (cmd_flip): Pass var_cnt as number of cases instead of case_cnt, + to fix bug #20494. Don't assign to `case_size' member, which was + unused after assignment. + (build_dictionary): When NEWNAMES not used, get the number of + variables right, to fix bug #20493. + 2007-07-10 Jason Stover * glm.q: Initial version of the GLM procedure. diff --git a/src/language/stats/flip.c b/src/language/stats/flip.c index 9afcf422c5..53d9873d53 100644 --- a/src/language/stats/flip.c +++ b/src/language/stats/flip.c @@ -65,7 +65,6 @@ struct flip_pgm int *idx_to_fv; /* var[]->index to compacted sink case fv. */ size_t var_cnt; /* Number of elements in `var'. */ int case_cnt; /* Pre-flip case count. */ - size_t case_size; /* Post-flip bytes per case. */ struct variable *new_names; /* Variable containing new variable names. */ struct varname *new_names_head; /* First new variable. */ @@ -119,7 +118,7 @@ cmd_flip (struct lexer *lexer, struct dataset *ds) { lex_match (lexer, '='); if (!parse_variables_const (lexer, dict, &flip->var, &flip->var_cnt, - PV_NO_DUPLICATE)) + PV_NO_DUPLICATE)) goto error; lex_match (lexer, '/'); } @@ -149,8 +148,7 @@ cmd_flip (struct lexer *lexer, struct dataset *ds) } } - output_buf = pool_nalloc (flip->pool, - flip->var_cnt, sizeof *output_buf); + output_buf = pool_nalloc (flip->pool, flip->var_cnt, sizeof *output_buf); flip->file = pool_tmpfile (flip->pool); if (flip->file == NULL) @@ -199,11 +197,10 @@ cmd_flip (struct lexer *lexer, struct dataset *ds) proc_discard_active_file (ds); goto error; } - flip->case_size = dict_get_case_size (dict); /* Set up flipped data for reading. */ reader = casereader_create_sequential (NULL, dict_get_next_value_idx (dict), - flip->case_cnt, + flip->var_cnt, &flip_casereader_class, flip); proc_set_active_file_data (ds, reader); return lex_end_of_command (lexer); @@ -288,7 +285,7 @@ build_dictionary (struct dictionary *dict, struct flip_pgm *flip) return false; } - for (i = 0; i < flip->case_cnt; i++) + for (i = 0; i < flip->case_cnt - 1; i++) { struct variable *v; char s[SHORT_NAME_LEN + 1]; diff --git a/tests/ChangeLog b/tests/ChangeLog index 5c851b2045..795da07ec6 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2007-07-24 Ben Pfaff + + * tests/command/flip.sh: Add tests to avoid regression on bugs + #20493, #20494. + 2007-07-22 Ben Pfaff * command/very-long-strings.sh: Test both compressed and diff --git a/tests/command/flip.sh b/tests/command/flip.sh index 29caa1422c..cfafa9612c 100755 --- a/tests/command/flip.sh +++ b/tests/command/flip.sh @@ -56,7 +56,8 @@ cd $TEMPDIR activity="create flip.stat" cat > $TEMPDIR/flip.stat <