From: Ben Pfaff Date: Fri, 14 Jul 2006 02:28:29 +0000 (+0000) Subject: Fixes for bugs/warts found in debug mode compile (bug #17092). X-Git-Tag: v0.6.0~766 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6492b3b49661963dc6d78201a1eb3927fdf54b68;p=pspp-builds.git Fixes for bugs/warts found in debug mode compile (bug #17092). Thanks to Jason for reporting this bug and John for insight. --- diff --git a/src/data/ChangeLog b/src/data/ChangeLog index 5297f3b9..0d10921c 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,3 +1,17 @@ +Wed Jul 12 21:02:26 2006 Ben Pfaff + + * procedure.c (internal_procedure): Create sink_case with only as + many values as the compacted dictionary. + +Wed Jul 12 21:01:00 2006 Ben Pfaff + + Remove "debugging" code that caused plenty of false positives and + no true positives. + + * case.h (struct ccase): [DEBUGGING] Remove `this' member. + + * case.c: Remove all references to `this' member. + Thu Jul 6 19:09:53 2006 Ben Pfaff Fix link error noted by Jason Stover. diff --git a/src/data/case.c b/src/data/case.c index 6e65af97..98de9ec6 100644 --- a/src/data/case.c +++ b/src/data/case.c @@ -45,9 +45,6 @@ case_unshare (struct ccase *c) { struct case_data *cd; - assert (c != NULL); - assert (c->this == c); - assert (c->case_data != NULL); assert (c->case_data->ref_cnt > 1); cd = c->case_data; @@ -72,7 +69,6 @@ void case_nullify (struct ccase *c) { c->case_data = NULL; - c->this = c; } #endif /* DEBUGGING */ @@ -100,17 +96,10 @@ case_create (struct ccase *c, size_t value_cnt) void case_clone (struct ccase *clone, const struct ccase *orig) { - assert (orig != NULL); - assert (orig->this == orig); - assert (orig->case_data != NULL); assert (orig->case_data->ref_cnt > 0); - assert (clone != NULL); if (clone != orig) - { - *clone = *orig; - clone->this = clone; - } + *clone = *orig; orig->case_data->ref_cnt++; } #endif /* DEBUGGING */ @@ -121,16 +110,11 @@ case_clone (struct ccase *clone, const struct ccase *orig) void case_move (struct ccase *dst, struct ccase *src) { - assert (src != NULL); - assert (src->this == src); - assert (src->case_data != NULL); assert (src->case_data->ref_cnt > 0); - assert (dst != NULL); if (dst != src) { *dst = *src; - dst->this = dst; case_nullify (src); } } @@ -144,7 +128,6 @@ case_destroy (struct ccase *c) struct case_data *cd; assert (c != NULL); - assert (c->this == c); cd = c->case_data; if (cd != NULL && --cd->ref_cnt == 0) @@ -183,9 +166,6 @@ case_swap (struct ccase *a, struct ccase *b) int case_try_create (struct ccase *c, size_t value_cnt) { -#ifdef DEBUGGING - c->this = c; -#endif c->case_data = malloc (case_size (value_cnt)); if (c->case_data != NULL) { @@ -215,17 +195,11 @@ case_copy (struct ccase *dst, size_t dst_idx, const struct ccase *src, size_t src_idx, size_t value_cnt) { - assert (dst != NULL); - assert (dst->this == dst); - assert (dst->case_data != NULL); assert (dst->case_data->ref_cnt > 0); assert (dst_idx + value_cnt <= dst->case_data->value_cnt); - assert (src != NULL); - assert (src->this == src); - assert (src->case_data != NULL); assert (src->case_data->ref_cnt > 0); - assert (src_idx + value_cnt <= dst->case_data->value_cnt); + assert (src_idx + value_cnt <= src->case_data->value_cnt); if (dst->case_data != src->case_data || dst_idx != src_idx) { @@ -246,9 +220,6 @@ void case_to_values (const struct ccase *c, union value *output, size_t output_size UNUSED) { - assert (c != NULL); - assert (c->this == c); - assert (c->case_data != NULL); assert (c->case_data->ref_cnt > 0); assert (output_size == c->case_data->value_cnt); assert (output != NULL || output_size == 0); @@ -267,7 +238,6 @@ case_from_values (struct ccase *c, const union value *input, size_t input_size UNUSED) { assert (c != NULL); - assert (c->this == c); assert (c->case_data != NULL); assert (c->case_data->ref_cnt > 0); assert (input_size == c->case_data->value_cnt); @@ -288,7 +258,6 @@ const union value * case_data (const struct ccase *c, size_t idx) { assert (c != NULL); - assert (c->this == c); assert (c->case_data != NULL); assert (c->case_data->ref_cnt > 0); assert (idx < c->case_data->value_cnt); @@ -304,7 +273,6 @@ double case_num (const struct ccase *c, size_t idx) { assert (c != NULL); - assert (c->this == c); assert (c->case_data != NULL); assert (c->case_data->ref_cnt > 0); assert (idx < c->case_data->value_cnt); @@ -322,7 +290,6 @@ const char * case_str (const struct ccase *c, size_t idx) { assert (c != NULL); - assert (c->this == c); assert (c->case_data != NULL); assert (c->case_data->ref_cnt > 0); assert (idx < c->case_data->value_cnt); @@ -339,7 +306,6 @@ union value * case_data_rw (struct ccase *c, size_t idx) { assert (c != NULL); - assert (c->this == c); assert (c->case_data != NULL); assert (c->case_data->ref_cnt > 0); assert (idx < c->case_data->value_cnt); @@ -405,7 +371,6 @@ const union value * case_data_all (const struct ccase *c) { assert (c != NULL); - assert (c->this == c); assert (c->case_data != NULL); assert (c->case_data->ref_cnt > 0); @@ -421,7 +386,6 @@ union value * case_data_all_rw (struct ccase *c) { assert (c != NULL); - assert (c->this == c); assert (c->case_data != NULL); assert (c->case_data->ref_cnt > 0); diff --git a/src/data/case.h b/src/data/case.h index 05c4568c..d0b9fc9d 100644 --- a/src/data/case.h +++ b/src/data/case.h @@ -30,9 +30,6 @@ struct ccase { struct case_data *case_data; /* Actual data. */ -#if DEBUGGING - struct ccase *this; /* Detects unauthorized move/copy. */ -#endif }; /* Invisible to user code. */ diff --git a/src/data/procedure.c b/src/data/procedure.c index a2ca8b23..4dcce32b 100644 --- a/src/data/procedure.c +++ b/src/data/procedure.c @@ -219,7 +219,8 @@ internal_procedure (bool (*case_func) (const struct ccase *, void *), wc_data.case_func = case_func; wc_data.aux = aux; create_trns_case (&wc_data.trns_case, default_dict); - case_create (&wc_data.sink_case, dict_get_next_value_idx (default_dict)); + case_create (&wc_data.sink_case, + dict_get_compacted_value_cnt (default_dict)); wc_data.cases_written = 0; ok = proc_source->class->read (proc_source, diff --git a/src/language/expressions/ChangeLog b/src/language/expressions/ChangeLog index 82421672..ab68d8ca 100644 --- a/src/language/expressions/ChangeLog +++ b/src/language/expressions/ChangeLog @@ -1,3 +1,8 @@ +Wed Jul 12 21:03:17 2006 Ben Pfaff + + * evaluate.c (cmd_debug_evaluate): Don't try to resize a null + case. + Fri Jun 9 13:59:15 2006 Ben Pfaff Reform string library. diff --git a/src/language/expressions/evaluate.c b/src/language/expressions/evaluate.c index ac36d181..fd12a04b 100644 --- a/src/language/expressions/evaluate.c +++ b/src/language/expressions/evaluate.c @@ -163,9 +163,10 @@ cmd_debug_evaluate (void) if (c == NULL) { c = xmalloc (sizeof *c); - case_nullify (c); + case_create (c, dict_get_next_value_idx (d)); } - case_resize (c, old_value_cnt, dict_get_next_value_idx (d)); + else + case_resize (c, old_value_cnt, dict_get_next_value_idx (d)); if (lex_is_number ()) case_data_rw (c, v->fv)->f = tokval; diff --git a/src/output/ChangeLog b/src/output/ChangeLog index 2757aa16..b7e72cc7 100644 --- a/src/output/ChangeLog +++ b/src/output/ChangeLog @@ -1,3 +1,13 @@ +Wed Jul 12 21:03:37 2006 Ben Pfaff + + * table.c (tab_natural_width): Get rid of warning on empty column, + which tended to just trigger false positives because we handle + joined cells so badly. We need a real fix, and the warning is not + helpful. + + * table.c (tab_offset): [DEBUGGING] Let row, col arguments be as + big as row or column count. + Wed Jul 12 20:58:19 2006 Ben Pfaff * output.c (outp_drivers): [DEBUGGING] Delete unused declaration. diff --git a/src/output/table.c b/src/output/table.c index 430742d7..8d5ed12b 100644 --- a/src/output/table.c +++ b/src/output/table.c @@ -435,10 +435,10 @@ tab_natural_width (struct tab_table *t, struct outp_driver *d, int c) if (width == 0) { - width = d->prop_em_width * 8; -#if DEBUGGING - printf ("warning: table column %d contains no data.\n", c); -#endif + /* FIXME: This is an ugly kluge to compensate for the fact + that we don't let joined cells contribute to column + widths. */ + width = d->prop_em_width * 8; } { @@ -802,12 +802,12 @@ tab_offset (struct tab_table *t, int col, int row) assert (t != NULL); #if DEBUGGING - if (row < -1 || row >= t->nr) + if (row < -1 || row > t->nr) { printf ("tab_offset(): row=%d in %d-row table\n", row, t->nr); NOT_REACHED (); } - if (col < -1 || col >= t->nc) + if (col < -1 || col > t->nc) { printf ("tab_offset(): col=%d in %d-column table\n", col, t->nc); NOT_REACHED ();