From: Ben Pfaff Date: Sat, 8 Jul 2006 03:05:51 +0000 (+0000) Subject: Apply patch #5225, assertions. X-Git-Tag: v0.6.0~775 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97d4f38945476834fd7fce612b663f19f2b291f8;p=pspp-builds.git Apply patch #5225, assertions. --- diff --git a/src/data/any-reader.c b/src/data/any-reader.c index 0ab6dc23..691bc475 100644 --- a/src/data/any-reader.c +++ b/src/data/any-reader.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "file-handle-def.h" #include "file-name.h" @@ -139,7 +140,7 @@ any_reader_open (struct file_handle *handle, struct dictionary **dict) return make_any_reader (SCRATCH_FILE, scratch_reader_open (handle, dict)); } - abort (); + NOT_REACHED (); } /* Reads a single case from READER into C. @@ -158,7 +159,7 @@ any_reader_read (struct any_reader *reader, struct ccase *c) case SCRATCH_FILE: return scratch_reader_read_case (reader->private, c); } - abort (); + NOT_REACHED (); } /* Returns true if an I/O error has occurred on READER, false @@ -177,7 +178,7 @@ any_reader_error (struct any_reader *reader) case SCRATCH_FILE: return scratch_reader_error (reader->private); } - abort (); + NOT_REACHED (); } /* Closes READER. */ @@ -202,7 +203,7 @@ any_reader_close (struct any_reader *reader) break; default: - abort (); + NOT_REACHED (); } free (reader); diff --git a/src/data/any-writer.c b/src/data/any-writer.c index 5c3c0aee..7043b65e 100644 --- a/src/data/any-writer.c +++ b/src/data/any-writer.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "file-handle-def.h" #include "file-name.h" @@ -85,7 +86,7 @@ any_writer_open (struct file_handle *handle, struct dictionary *dict) dict)); } - abort (); + NOT_REACHED (); } /* If PRIVATE is non-null, creates and returns a new any_writer, @@ -162,7 +163,7 @@ any_writer_write (struct any_writer *writer, const struct ccase *c) case SCRATCH_FILE: return scratch_writer_write_case (writer->private, c); } - abort (); + NOT_REACHED (); } /* Returns true if an I/O error has occurred on WRITER, false @@ -181,7 +182,7 @@ any_writer_error (const struct any_writer *writer) case SCRATCH_FILE: return scratch_writer_error (writer->private); } - abort (); + NOT_REACHED (); } /* Closes WRITER. @@ -209,7 +210,7 @@ any_writer_close (struct any_writer *writer) break; default: - abort (); + NOT_REACHED (); } free (writer); diff --git a/src/data/category.c b/src/data/category.c index 50908549..cfde5331 100644 --- a/src/data/category.c +++ b/src/data/category.c @@ -32,12 +32,16 @@ 'cat_var'. */ #include + +#include "category.h" + +#include #include +#include + #include #include -#include "category.h" #include "cat-routines.h" -#include #include "variable.h" #define N_INITIAL_CATEGORIES 1 diff --git a/src/data/category.h b/src/data/category.h index 30ca2722..35df104b 100644 --- a/src/data/category.h +++ b/src/data/category.h @@ -37,7 +37,7 @@ #define CAT_H #define CAT_VALUE_NOT_FOUND -2 #include - +#include union value; struct variable ; diff --git a/src/data/data-out.c b/src/data/data-out.c index 53d9850d..0585dc2b 100644 --- a/src/data/data-out.c +++ b/src/data/data-out.c @@ -25,6 +25,7 @@ #include #include #include "calendar.h" +#include #include #include "format.h" #include @@ -101,12 +102,10 @@ data_out (char *s, const struct fmt_spec *fp, const union value *v) break; case FMT_A: - assert (0); - abort (); + NOT_REACHED (); case FMT_AHEX: - assert (0); - abort (); + NOT_REACHED (); case FMT_IB: ok = convert_IB (s, fp, number); @@ -159,8 +158,7 @@ data_out (char *s, const struct fmt_spec *fp, const union value *v) break; default: - assert (0); - abort (); + NOT_REACHED (); } } else @@ -179,8 +177,7 @@ data_out (char *s, const struct fmt_spec *fp, const union value *v) break; default: - assert (0); - abort (); + NOT_REACHED (); } } @@ -751,7 +748,7 @@ convert_date (char *dst, const struct fmt_spec *fp, double number) } break; default: - assert (0); + NOT_REACHED (); } if (buf[0] == 0) diff --git a/src/data/file-handle-def.c b/src/data/file-handle-def.c index 4b83c3e1..32ca5c94 100644 --- a/src/data/file-handle-def.c +++ b/src/data/file-handle-def.c @@ -18,16 +18,19 @@ 02110-1301, USA. */ #include + #include "file-handle-def.h" -#include + +#include #include #include #include + #include #include -#include "file-name.h" -#include #include +#include +#include "file-name.h" #include "variable.h" #include "scratch-handle.h" diff --git a/src/data/format.c b/src/data/format.c index a552f867..f4a61d34 100644 --- a/src/data/format.c +++ b/src/data/format.c @@ -20,6 +20,7 @@ #include #include "format.h" #include +#include #include #include #include @@ -280,7 +281,7 @@ convert_fmt_ItoO (const struct fmt_spec *input, struct fmt_spec *output) case FMT_CCC: case FMT_CCD: case FMT_CCE: - assert (0); + NOT_REACHED (); case FMT_Z: case FMT_A: /* nothing is necessary */ @@ -314,7 +315,7 @@ convert_fmt_ItoO (const struct fmt_spec *input, struct fmt_spec *output) /* nothing is necessary */ break; default: - assert (0); + NOT_REACHED (); } assert (check_output_specifier (output, 0)); diff --git a/src/data/missing-values.c b/src/data/missing-values.c index fabf98b7..d3b872e0 100644 --- a/src/data/missing-values.c +++ b/src/data/missing-values.c @@ -21,6 +21,7 @@ #include "missing-values.h" #include #include +#include #include @@ -90,7 +91,7 @@ mv_add_value (struct missing_values *mv, const union value *v) case MV_RANGE_1: return false; } - abort (); + NOT_REACHED (); } /* Attempts to add S to the set of string missing values MV. S @@ -139,7 +140,7 @@ mv_add_num_range (struct missing_values *mv, double low, double high) case MV_RANGE_1: return false; } - abort (); + NOT_REACHED (); } /* Returns true if MV contains an individual value, @@ -159,7 +160,7 @@ mv_has_value (const struct missing_values *mv) case MV_RANGE: return false; } - abort (); + NOT_REACHED (); } /* Removes one individual value from MV and stores it in *V. @@ -224,7 +225,7 @@ mv_has_range (const struct missing_values *mv) case MV_3: return false; } - abort (); + NOT_REACHED (); } /* Removes the numeric range from MV and stores it in *LOW and @@ -275,7 +276,7 @@ using_element (unsigned type, int idx) case MV_RANGE_1: return true; } - abort (); + NOT_REACHED (); } /* Returns true if S contains only spaces between indexes @@ -398,7 +399,7 @@ mv_is_num_user_missing (const struct missing_values *mv, double d) case MV_RANGE_1: return v[0].f == d || (v[1].f <= d && d <= v[2].f); } - abort (); + NOT_REACHED (); } /* Returns true if S[] is a missing value in MV, false otherwise. @@ -425,9 +426,9 @@ mv_is_str_user_missing (const struct missing_values *mv, || !memcmp (v[2].s, s, mv->width)); case MV_RANGE: case MV_RANGE_1: - abort (); + NOT_REACHED (); } - abort (); + NOT_REACHED (); } /* Returns true if MV is a set of numeric missing values and V is diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index 52a14a45..072fca3b 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -1619,7 +1620,7 @@ read_compressed_data (struct sfm_reader *r, flt64 *buf) p = r->x; } - abort (); + NOT_REACHED (); success: /* We have filled up an entire record. Update state and return diff --git a/src/data/variable.c b/src/data/variable.c index 64e4b3f0..435980e3 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -19,6 +19,7 @@ #include #include "variable.h" +#include #include #include #include @@ -346,8 +347,7 @@ dict_class_to_name (enum dict_class dict_class) case DC_SCRATCH: return _("scratch"); default: - assert (0); - abort (); + NOT_REACHED (); } } diff --git a/src/language/command.c b/src/language/command.c index 61d54f9c..a465aa0d 100644 --- a/src/language/command.c +++ b/src/language/command.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -421,7 +422,7 @@ find_command (const char *name) for (cmd = commands; cmd < commands + command_cnt; cmd++) if (!strcmp (cmd->name, name)) return cmd; - abort (); + NOT_REACHED (); } /* Frees the WORD_CNT words in WORDS. */ @@ -595,7 +596,7 @@ report_state_mismatch (const struct command *command, enum cmd_state state) else if (allowed_cnt == 3) s = xasprintf (_("%s, %s, or %s"), allowed[0], allowed[1], allowed[2]); else - abort (); + NOT_REACHED (); msg (SE, _("%s is allowed only %s."), command->name, s); diff --git a/src/language/data-io/data-list.c b/src/language/data-io/data-list.c index 6998cc92..95b80368 100644 --- a/src/language/data-io/data-list.c +++ b/src/language/data-io/data-list.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -999,7 +1000,7 @@ read_from_data_list (const struct data_list_pgm *dls, struct ccase *c) retval = read_from_data_list_list (dls, c); break; default: - abort (); + NOT_REACHED (); } dfm_pop (dls->reader); diff --git a/src/language/data-io/data-reader.c b/src/language/data-io/data-reader.c index c2da5504..1899acfb 100644 --- a/src/language/data-io/data-reader.c +++ b/src/language/data-io/data-reader.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -224,7 +225,7 @@ read_file_record (struct dfm_reader *r) } } else - abort (); + NOT_REACHED (); r->where.line_number++; diff --git a/src/language/data-io/file-handle.q b/src/language/data-io/file-handle.q index b3110ac8..81094a95 100644 --- a/src/language/data-io/file-handle.q +++ b/src/language/data-io/file-handle.q @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -109,7 +110,7 @@ cmd_file_handle (void) properties.record_width = cmd.n_lrecl[0]; break; default: - assert (0); + NOT_REACHED (); } if (cmd.mode != FH_SCRATCH) @@ -154,7 +155,7 @@ referent_name (enum fh_referent referent) case FH_REF_SCRATCH: return _("scratch file"); default: - abort (); + NOT_REACHED (); } } diff --git a/src/language/data-io/get.c b/src/language/data-io/get.c index 0f082477..fc4d2c12 100644 --- a/src/language/data-io/get.c +++ b/src/language/data-io/get.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -843,7 +844,7 @@ cmd_match_files (void) saw_table = true; } else - assert (0); + NOT_REACHED (); lex_match ('='); file->by = NULL; @@ -1169,7 +1170,7 @@ mtf_processing_finish (void *mtf_) if (iter->handle == NULL) { if (!mtf_delete_file_in_place (mtf, &iter)) - abort (); + NOT_REACHED (); break; } diff --git a/src/language/data-io/inpt-pgm.c b/src/language/data-io/inpt-pgm.c index 94fa4044..d4e08392 100644 --- a/src/language/data-io/inpt-pgm.c +++ b/src/language/data-io/inpt-pgm.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -205,7 +206,7 @@ init_case (const struct input_program_pgm *inp, struct ccase *c) memset (case_data_rw (c, i)->s, ' ', sizeof case_data_rw (c, i)->s); break; default: - assert (0); + NOT_REACHED (); } } @@ -229,7 +230,7 @@ clear_case (const struct input_program_pgm *inp, struct ccase *c) memset (case_data_rw (c, i)->s, ' ', sizeof case_data_rw (c, i)->s); break; default: - assert (0); + NOT_REACHED (); } } diff --git a/src/language/data-io/list.q b/src/language/data-io/list.q index 19c1bb45..51623aac 100644 --- a/src/language/data-io/list.q +++ b/src/language/data-io/list.q @@ -269,7 +269,7 @@ write_all_headers (const struct ccase *c, void *aux UNUSED) fputs (" \n", x->file); } else - assert (0); + NOT_REACHED (); } } @@ -387,7 +387,7 @@ clean_up (void) } } else - assert (0); + NOT_REACHED (); free (cmd.v_variables); } @@ -718,7 +718,7 @@ list_cases (const struct ccase *c, void *aux UNUSED) fputs (" \n", x->file); } else - assert (0); + NOT_REACHED (); return true; } diff --git a/src/language/data-io/matrix-data.c b/src/language/data-io/matrix-data.c index 5a664911..5526db91 100644 --- a/src/language/data-io/matrix-data.c +++ b/src/language/data-io/matrix-data.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -754,7 +755,7 @@ mdump_token (const struct matrix_token *token) printf (" '%.*s'", token->length, token->string); break; default: - assert (0); + NOT_REACHED (); } fflush (stdout); } @@ -1066,16 +1067,14 @@ nr_read_data_lines (struct nr_aux_data *nr, n_cols = mx->n_continuous; break; default: - assert (0); - abort (); + NOT_REACHED (); } break; case 2: n_cols = 1; break; default: - assert (0); - abort (); + NOT_REACHED (); } { @@ -1935,13 +1934,11 @@ wr_read_indeps (struct wr_aux_data *wr) n_cols = mx->n_continuous; break; default: - assert (0); - abort (); + NOT_REACHED (); } break; default: - assert (0); - abort (); + NOT_REACHED (); } c->n_rows[wr->content]++; diff --git a/src/language/data-io/print.c b/src/language/data-io/print.c index 061aafc6..3c8db1cb 100644 --- a/src/language/data-io/print.c +++ b/src/language/data-io/print.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -838,7 +839,7 @@ dump_table (const struct file_handle *fh) case PRT_SPACE: break; case PRT_ERROR: - assert (0); + NOT_REACHED (); } if (fh != NULL) @@ -883,8 +884,7 @@ alloc_line (void) break; case PRT_ERROR: default: - assert (0); - abort (); + NOT_REACHED (); } if (pot_w > w) w = pot_w; @@ -958,8 +958,7 @@ print_trns_proc (void *trns_, struct ccase *c, int case_num UNUSED) break; case PRT_ERROR: - assert (0); - break; + NOT_REACHED (); } if (t->writer != NULL && dfm_write_error (t->writer)) @@ -988,8 +987,7 @@ print_trns_free (void *prt_) /* nothing to do */ break; case PRT_ERROR: - assert (0); - break; + NOT_REACHED (); } n = i->next; free (i); diff --git a/src/language/dictionary/modify-variables.c b/src/language/dictionary/modify-variables.c index c17bb562..1632f6ea 100644 --- a/src/language/dictionary/modify-variables.c +++ b/src/language/dictionary/modify-variables.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -259,7 +260,7 @@ cmd_modify_vars (void) compare_variables_given_ordering, &forward_positional_ordering) != drop_cnt) - assert (0); + NOT_REACHED (); free (keep_vars); free (all_vars); @@ -420,7 +421,7 @@ validate_var_modification (const struct dictionary *d, keep_vars, compare_variables_given_ordering, &forward_positional_ordering) != keep_cnt) - assert (0); + NOT_REACHED (); /* Copy variables into var_renaming array. */ var_renaming = xnmalloc (keep_cnt, sizeof *var_renaming); @@ -514,7 +515,7 @@ rearrange_dict (struct dictionary *d, const struct var_modification *vm) /* Do renaming. */ if (dict_rename_vars (d, rename_vars, rename_new_names, rename_cnt, NULL) == 0) - assert (0); + NOT_REACHED (); /* Clean up. */ for (i = 0; i < vm->rename_cnt; i++) diff --git a/src/language/dictionary/numeric.c b/src/language/dictionary/numeric.c index a914b06a..82b58c02 100644 --- a/src/language/dictionary/numeric.c +++ b/src/language/dictionary/numeric.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include @@ -151,8 +151,7 @@ cmd_string (void) width = f.w / 2; break; default: - assert (0); - abort (); + NOT_REACHED (); } /* Create each variable. */ diff --git a/src/language/dictionary/vector.c b/src/language/dictionary/vector.c index b4a212d2..17cbb1a6 100644 --- a/src/language/dictionary/vector.c +++ b/src/language/dictionary/vector.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -177,7 +178,7 @@ cmd_vector (void) v[i] = dict_create_var_assert (default_dict, name, 0); } if (!dict_create_vector (default_dict, cp, v, nv)) - assert (0); + NOT_REACHED (); cp += strlen (cp) + 1; } free (v); diff --git a/src/language/expressions/evaluate.c b/src/language/expressions/evaluate.c index 9398b41c..ac36d181 100644 --- a/src/language/expressions/evaluate.c +++ b/src/language/expressions/evaluate.c @@ -22,6 +22,7 @@ #include #include +#include #include #include "helpers.h" #include "evaluate.h" @@ -67,7 +68,7 @@ expr_evaluate (struct expression *e, const struct ccase *c, int case_idx, #include "evaluate.inc" default: - abort (); + NOT_REACHED (); } } } @@ -233,7 +234,7 @@ cmd_debug_evaluate (void) } default: - assert (0); + NOT_REACHED (); } expr_free (expr); @@ -299,7 +300,7 @@ expr_debug_print_postfix (const struct expression *e) fprintf (stderr, "i<%d>", op->integer); break; default: - abort (); + NOT_REACHED (); } } fprintf (stderr, "\n"); diff --git a/src/language/expressions/evaluate.inc.pl b/src/language/expressions/evaluate.inc.pl index 85112f96..7b6b1a3e 100644 --- a/src/language/expressions/evaluate.inc.pl +++ b/src/language/expressions/evaluate.inc.pl @@ -6,7 +6,7 @@ sub generate_output { if ($op->{UNIMPLEMENTED}) { print "case $opname:\n"; - print " abort ();\n\n"; + print " NOT_REACHED ();\n\n"; next; } diff --git a/src/language/expressions/optimize.c b/src/language/expressions/optimize.c index c5ba6224..15451792 100644 --- a/src/language/expressions/optimize.c +++ b/src/language/expressions/optimize.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -157,12 +158,10 @@ evaluate_tree (struct composite_node *node, struct expression *e) #include "optimize.inc" default: - assert (0); + NOT_REACHED (); } - /* Not reached. */ - assert (0); - abort (); + NOT_REACHED (); } static double @@ -302,7 +301,7 @@ flatten_atom (union any_node *n, struct expression *e) break; default: - abort (); + NOT_REACHED (); } } @@ -363,7 +362,7 @@ flatten_node (union any_node *n, struct expression *e) else if (is_composite (n->type)) flatten_composite (n, e); else - abort (); + NOT_REACHED (); } static union operation_data * diff --git a/src/language/expressions/optimize.inc.pl b/src/language/expressions/optimize.inc.pl index 798c5001..fce530f7 100644 --- a/src/language/expressions/optimize.inc.pl +++ b/src/language/expressions/optimize.inc.pl @@ -6,7 +6,7 @@ sub generate_output { if (!$op->{OPTIMIZABLE} || $op->{UNIMPLEMENTED}) { print "case $opname:\n"; - print " abort ();\n\n"; + print " NOT_REACHED ();\n\n"; next; } diff --git a/src/language/expressions/parse.c b/src/language/expressions/parse.c index 72604ed9..bb567d2c 100644 --- a/src/language/expressions/parse.c +++ b/src/language/expressions/parse.c @@ -31,6 +31,7 @@ #include "helpers.h" #include #include +#include #include #include #include @@ -167,7 +168,7 @@ atom_type_stack (atom_type type) return ¬_on_stack; default: - abort (); + NOT_REACHED (); } } @@ -271,7 +272,7 @@ type_check (struct expression *e, break; default: - abort (); + NOT_REACHED (); } return true; @@ -345,7 +346,7 @@ type_coercion_core (struct expression *e, break; case OP_format: - abort (); + NOT_REACHED (); case OP_ni_format: if ((*node)->type == OP_format @@ -399,7 +400,7 @@ type_coercion_core (struct expression *e, break; default: - abort (); + NOT_REACHED (); } if (do_coercion) @@ -1282,7 +1283,7 @@ expr_node_returns (const union any_node *n) else if (is_composite (n->type)) return operations[n->type].returns; else - abort (); + NOT_REACHED (); } static const char * diff --git a/src/language/lexer/lexer.c b/src/language/lexer/lexer.c index c9e71b9f..7358c71b 100644 --- a/src/language/lexer/lexer.c +++ b/src/language/lexer/lexer.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -934,7 +935,7 @@ lex_token_representation (void) } } - assert (0); + NOT_REACHED (); } /* Really weird functions. */ @@ -1018,7 +1019,7 @@ convert_numeric_string_to_char_string (enum string_type type) chars_per_byte = 2; break; default: - abort (); + NOT_REACHED (); } byte_cnt = ds_length (&tokstr) / chars_per_byte; diff --git a/src/language/lexer/q2c.c b/src/language/lexer/q2c.c index df6f5d9f..a6de4ac6 100644 --- a/src/language/lexer/q2c.c +++ b/src/language/lexer/q2c.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include "exit.h" @@ -1321,7 +1322,7 @@ dump_vars_init (int persistent) break; default: - assert (0); + NOT_REACHED (); } } } @@ -1709,7 +1710,7 @@ dump_subcommand (const subcommand *sbc) dump (0, "goto lossage;"); dump (-1, "default:"); indent (); - dump (0, "assert (0);"); + dump (0, "NOT_REACHED ();"); dump (-1, "}"); outdent (); } @@ -1775,7 +1776,7 @@ dump_parser (int persistent) dump (0, "break;"); dump (-1, "default:"); indent (); - dump (0, "assert (0);"); + dump (0, "NOT_REACHED ();"); dump (-1, "}"); outdent (); } @@ -2030,6 +2031,7 @@ main (int argc, char *argv[]) dump (0, "#include "); dump (0, "#include "); + dump (0, "#include "); dump (0, "#include "); dump (0, "#include "); dump (0, "#include "); diff --git a/src/language/line-buffer.c b/src/language/line-buffer.c index f0e69720..146ca00a 100644 --- a/src/language/line-buffer.c +++ b/src/language/line-buffer.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -493,7 +494,7 @@ read_line_from_source (struct string *line, struct getl_source *s) return s->u.interactive (line, get_prompt_style ()); } - abort (); + NOT_REACHED (); } /* Reads a single line into LINE. diff --git a/src/language/stats/aggregate.c b/src/language/stats/aggregate.c index 78c29c4f..7c8245e0 100644 --- a/src/language/stats/aggregate.c +++ b/src/language/stats/aggregate.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -892,7 +892,7 @@ accumulate_aggregate_info (struct agr_proc *agr, caught earlier. Nothing to do. */ break; default: - assert (0); + NOT_REACHED (); } } else { switch (iter->function) @@ -904,7 +904,7 @@ accumulate_aggregate_info (struct agr_proc *agr, iter->int1++; break; default: - assert (0); + NOT_REACHED (); } } } @@ -1033,7 +1033,7 @@ dump_aggregate_info (struct agr_proc *agr, struct ccase *output) v->f = i->int1; break; default: - assert (0); + NOT_REACHED (); } } } diff --git a/src/language/stats/crosstabs.q b/src/language/stats/crosstabs.q index d13a1432..a2115cef 100644 --- a/src/language/stats/crosstabs.q +++ b/src/language/stats/crosstabs.q @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -1799,8 +1800,7 @@ display_crosstabulation (void) * (1. - col_tot[c] / W))); break; default: - assert (0); - abort (); + NOT_REACHED (); } format_cell_entry (table, c, i, v, suffix, mark_missing); @@ -1855,8 +1855,7 @@ display_crosstabulation (void) v = 0.; break; default: - assert (0); - abort (); + NOT_REACHED (); } format_cell_entry (table, n_cols, 0, v, suffix, mark_missing); @@ -1911,8 +1910,7 @@ display_crosstabulation (void) case CRS_CL_ASRESIDUAL: continue; default: - assert (0); - abort (); + NOT_REACHED (); } format_cell_entry (table, c, i, v, suffix, mark_missing); diff --git a/src/language/stats/flip.c b/src/language/stats/flip.c index 0e9b56c5..0b452cb7 100644 --- a/src/language/stats/flip.c +++ b/src/language/stats/flip.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -538,7 +539,7 @@ flip_source_read (struct case_source *source, else if (feof (flip->file)) msg (SE, _("Unexpected end of file reading FLIP temporary file.")); else - abort (); + NOT_REACHED (); ok = false; break; } diff --git a/src/language/stats/frequencies.q b/src/language/stats/frequencies.q index 5c3de42c..c1e40d62 100644 --- a/src/language/stats/frequencies.q +++ b/src/language/stats/frequencies.q @@ -557,7 +557,7 @@ calc (const struct ccase *c, void *aux UNUSED) ft->out_of_range += weight; break; default: - assert (0); + NOT_REACHED (); } } return true; @@ -645,7 +645,7 @@ postcalc (void *aux UNUSED) dump_full (v); break; default: - assert (0); + NOT_REACHED (); } else dumped_freq_tab = 0; @@ -706,7 +706,7 @@ get_freq_comparator (int frq_sort, int var_type) case FRQ_AFREQ | (ALPHA << 16): return compare_freq_alpha_a; case FRQ_DFREQ | (NUMERIC << 16): return compare_freq_numeric_d; case FRQ_DFREQ | (ALPHA << 16): return compare_freq_alpha_d; - default: assert (0); + default: NOT_REACHED (); } return 0; diff --git a/src/language/stats/t-test.q b/src/language/stats/t-test.q index 3116f625..9e332df8 100644 --- a/src/language/stats/t-test.q +++ b/src/language/stats/t-test.q @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -623,7 +624,7 @@ ssbox_create(struct ssbox *ssb, struct cmd_t_test *cmd, int mode) ssbox_paired_init(ssb,cmd); break; default: - assert(0); + NOT_REACHED (); } } @@ -937,7 +938,7 @@ trbox_create(struct trbox *trb, trbox_paired_init(trb,cmd); break; default: - assert(0); + NOT_REACHED (); } } @@ -1970,7 +1971,7 @@ hash_group_binary(const struct group_statistics *g, flag = which_group(g,p); } else - assert(0); + NOT_REACHED (); return flag; } diff --git a/src/language/utilities/set.q b/src/language/utilities/set.q index b403843a..4a603de7 100644 --- a/src/language/utilities/set.q +++ b/src/language/utilities/set.q @@ -110,6 +110,8 @@ int tgetnum (const char *); xsort=xsort:yes/no. */ +/* (headers) */ + /* (declarations) */ /* (_functions) */ diff --git a/src/language/xforms/recode.c b/src/language/xforms/recode.c index 5aaeb559..03fd0bc3 100644 --- a/src/language/xforms/recode.c +++ b/src/language/xforms/recode.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -560,7 +561,7 @@ find_src_numeric (struct recode_trns *trns, double value, struct variable *v) match = true; break; default: - abort (); + NOT_REACHED (); } if (match) @@ -609,7 +610,7 @@ find_src_string (struct recode_trns *trns, const char *value, int width) break; } default: - abort (); + NOT_REACHED (); } if (match) diff --git a/src/libpspp/ChangeLog b/src/libpspp/ChangeLog index a9f270c6..0d700060 100644 --- a/src/libpspp/ChangeLog +++ b/src/libpspp/ChangeLog @@ -1,3 +1,18 @@ +Fri Jul 7 20:01:26 2006 Ben Pfaff + + * automake.mk: (src_libpspp_libpspp_a_SOURCES) Add assertion.h. + + * assertion.h: New file. Replaced usage of assert(0) and abort() + with NOT_REACHED() from this file throughout the source tree. + + * message.c: (request_bug_report_and_abort) Revise message printed + to include request to include lines above the message, which + should include an assertion failure message in many cases. + (msg_assert_fail) Removed. + + * message.h: (assert) Removed. + (request_bug_report_and_abort) Mark NO_RETURN. + Mon Jul 3 09:36:42 WST 2006 John Darrington * i18n.c: Made character conversion tolerant of failure to create the diff --git a/src/libpspp/array.c b/src/libpspp/array.c index 945874cf..f4fca27e 100644 --- a/src/libpspp/array.c +++ b/src/libpspp/array.c @@ -96,14 +96,8 @@ #include #include #include "alloc.h" +#include -/* Some of the assertions in this file are very expensive. We - don't use them by default. */ -#ifdef EXTRA_CHECKS -#define expensive_assert(X) assert(X) -#else -#define expensive_assert(X) ((void) 0) -#endif #include "message.h" /* Finds an element in ARRAY, which contains COUNT elements of diff --git a/src/libpspp/assertion.h b/src/libpspp/assertion.h new file mode 100644 index 00000000..96b2d6fc --- /dev/null +++ b/src/libpspp/assertion.h @@ -0,0 +1,42 @@ +/* PSPP - computes sample statistics. + Copyright (C) 2006 Free Software Foundation, Inc. + Written by John Darrington + and 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 + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#ifndef __PSPP_ASSERT_H +#define __PSPP_ASSERT_H + +#include +#include "compiler.h" + +#define NOT_REACHED() do { assert (0); abort (); } while (0) + +#endif + +#include + +#ifndef ASSERT_LEVEL +#define ASSERT_LEVEL 2 +#endif + +#undef expensive_assert +#if ASSERT_LEVEL >= 5 +#define expensive_assert(EXPR) assert (EXPR) +#else +#define expensive_assert(EXPR) ((void) 0) +#endif diff --git a/src/libpspp/automake.mk b/src/libpspp/automake.mk index a8154966..98681f8b 100644 --- a/src/libpspp/automake.mk +++ b/src/libpspp/automake.mk @@ -6,6 +6,7 @@ noinst_LIBRARIES += src/libpspp/libpspp.a src_libpspp_libpspp_a_SOURCES = \ src/libpspp/array.c \ src/libpspp/array.h \ + src/libpspp/assertion.h \ src/libpspp/alloc.c \ src/libpspp/alloc.h \ src/libpspp/bit-vector.h \ diff --git a/src/libpspp/message.c b/src/libpspp/message.c index fe16c6b2..eaad1a69 100644 --- a/src/libpspp/message.c +++ b/src/libpspp/message.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -122,58 +123,30 @@ msg_get_command_name (void) } void -request_bug_report_and_abort(const char *msg ) +request_bug_report_and_abort (const char *msg) { - fprintf(stderr, - "******************************************************************\n" - "You have discovered a bug in PSPP.\n\n" - " Please report this, by sending " - "an email to " PACKAGE_BUGREPORT ",\n" - "explaining what you were doing when this happened, and including\n" - "a sample of your input file which caused it.\n"); - - fprintf(stderr, - "Also, please copy the following lines into your bug report:\n\n" - "bare_version: %s\n" - "version: %s\n" - "stat_version: %s\n" - "host_system: %s\n" - "build_system: %s\n" - "default_config_path: %s\n" - "include_path: %s\n" - "locale_dir: %s\n" - "compiler version: %s\n" - , - - bare_version, - version, - stat_version, - host_system, - build_system, - default_config_path, - include_path, - locale_dir, + fprintf (stderr, "******************************************************\n"); + fprintf (stderr, "You have discovered a bug in PSPP. Please report this\n"); + fprintf (stderr, "to " PACKAGE_BUGREPORT ". Please include this entire\n"); + fprintf (stderr, "message, *plus* several lines of output just above it.\n"); + fprintf (stderr, "For the best chance at having the bug fixed, also\n"); + fprintf (stderr, "include the syntax file that triggered it and a sample\n"); + fprintf (stderr, "of any data file used for input.\n"); + fprintf (stderr, "proximate cause: %s\n", msg); + fprintf (stderr, "version: %s\n", stat_version); + fprintf (stderr, "host_system: %s\n", host_system); + fprintf (stderr, "build_system: %s\n", build_system); + fprintf (stderr, "default_config_path: %s\n", default_config_path); + fprintf (stderr, "include_path: %s\n", include_path); + fprintf (stderr, "locale_dir: %s\n", locale_dir); + fprintf (stderr, "compiler version: %s\n", #ifdef __VERSION__ - __VERSION__ + __VERSION__ #else - "Unknown" + "Unknown" #endif - ); + ); + fprintf (stderr, "******************************************************\n"); - if ( msg ) - fprintf(stderr,"Diagnosis: %s\n",msg); - - fprintf(stderr, - "******************************************************************\n"); - - abort(); + _exit (EXIT_FAILURE); } - -void -msg_assert_fail(const char *expr, const char *file, int line) -{ - char msg[256]; - snprintf(msg,256,"Assertion failed: %s:%d; (%s)",file,line,expr); - request_bug_report_and_abort( msg ); -} - diff --git a/src/libpspp/message.h b/src/libpspp/message.h index 9f037cb2..604f185d 100644 --- a/src/libpspp/message.h +++ b/src/libpspp/message.h @@ -107,15 +107,6 @@ void msg_pop_msg_locator (const struct msg_locator *); /* Used in panic situations only. */ -void request_bug_report_and_abort (const char *msg); - -void msg_assert_fail (const char *expr, const char *file, int line); - -#undef __STRING -#define __STRING(x) #x -#undef assert - -#define assert(expr) ( (void) ( expr ? (void) 0 : \ - msg_assert_fail(__STRING(expr), __FILE__, __LINE__)) ) +void request_bug_report_and_abort (const char *msg) NO_RETURN; #endif /* message.h */ diff --git a/src/libpspp/pool.c b/src/libpspp/pool.c index 0e6c9358..d4c00b38 100644 --- a/src/libpspp/pool.c +++ b/src/libpspp/pool.c @@ -21,6 +21,7 @@ #include "pool.h" #include #include "alloc.h" +#include #include "message.h" #include "size_max.h" #include "str.h" @@ -915,7 +916,7 @@ free_gizmo (struct pool_gizmo *gizmo) gizmo->p.registered.free (gizmo->p.registered.p); break; default: - assert (0); + NOT_REACHED (); } } diff --git a/src/math/design-matrix.c b/src/math/design-matrix.c index 63c1dd9e..8678f56c 100644 --- a/src/math/design-matrix.c +++ b/src/math/design-matrix.c @@ -21,14 +21,19 @@ Create design matrices for procedures that need them. */ #include + +#include "design-matrix.h" + +#include +#include #include +#include + #include #include #include #include -#include "design-matrix.h" -#include -#include + #include #include #include diff --git a/src/math/sort.c b/src/math/sort.c index 01e95533..3ce5da57 100644 --- a/src/math/sort.c +++ b/src/math/sort.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -173,7 +174,7 @@ do_internal_sort (struct casereader *reader, { bool ok = casereader_read_xfer (reader, &cases[i].c); if (!ok) - abort (); + NOT_REACHED (); cases[i].idx = i; } @@ -183,7 +184,7 @@ do_internal_sort (struct casereader *reader, for (i = 0; i < case_cnt; i++) casefile_append_xfer (dst, &cases[i].c); if (casefile_error (dst)) - abort (); + NOT_REACHED (); free (cases); } diff --git a/src/output/afm.c b/src/output/afm.c index fedd9315..e45ab85d 100644 --- a/src/output/afm.c +++ b/src/output/afm.c @@ -31,6 +31,7 @@ #include #include "error.h" #include "minmax.h" +#include #include #include @@ -1146,7 +1147,7 @@ afm_encode_string (const struct afm *afm, break; default: - abort (); + NOT_REACHED (); } binary_finish (&e); } diff --git a/src/output/ascii.c b/src/output/ascii.c index e4b10270..3dba9775 100644 --- a/src/output/ascii.c +++ b/src/output/ascii.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -323,7 +324,7 @@ handle_option (struct outp_driver *this, const char *key, this->width = arg; break; default: - abort (); + NOT_REACHED (); } } break; @@ -365,7 +366,7 @@ handle_option (struct outp_driver *this, const char *key, x->tab_width = arg; break; default: - abort (); + NOT_REACHED (); } } break; @@ -395,12 +396,12 @@ handle_option (struct outp_driver *this, const char *key, x->squeeze_blank_lines = setting; break; default: - abort (); + NOT_REACHED (); } } break; default: - abort (); + NOT_REACHED (); } return true; @@ -511,7 +512,7 @@ text_draw (struct outp_driver *this, x += width - length; break; default: - abort (); + NOT_REACHED (); } if (y >= this->length || x >= this->width) diff --git a/src/output/charts/plot-chart.c b/src/output/charts/plot-chart.c index 497251f0..8a1dc0bd 100644 --- a/src/output/charts/plot-chart.c +++ b/src/output/charts/plot-chart.c @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -76,7 +77,7 @@ draw_tick(struct chart *chart, else if (orientation == TICK_ORDINATE ) pl_flinerel_r(chart->lp, 0, position, -tickSize, position); else - assert(0); + NOT_REACHED (); if ( label ) { char buf[10]; diff --git a/src/output/html.c b/src/output/html.c index b79deb45..021200bc 100644 --- a/src/output/html.c +++ b/src/output/html.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include "error.h" @@ -183,11 +184,11 @@ handle_option (struct outp_driver *this, error (0, 0, _("`chart-files' value must contain `#'")); break; default: - abort (); + NOT_REACHED (); } break; default: - abort (); + NOT_REACHED (); } return true; @@ -212,7 +213,7 @@ html_submit (struct outp_driver *this, struct som_entity *s) link_image (x->file, ((struct chart *)s->ext)->file_name); break; default: - abort (); + NOT_REACHED (); } } diff --git a/src/output/manager.c b/src/output/manager.c index c8ff70c0..468b2c23 100644 --- a/src/output/manager.c +++ b/src/output/manager.c @@ -21,6 +21,7 @@ #include "manager.h" #include #include +#include #include "output.h" /* Table. */ @@ -110,7 +111,7 @@ som_submit (struct som_entity *t) { printf ("headers: (l,r)=(%d,%d), (t,b)=(%d,%d) in table size (%d,%d)\n", hl, hr, ht, hb, nc, nr); - abort (); + NOT_REACHED (); } else if (hl + hr == nc) printf ("warning: headers (l,r)=(%d,%d) in table width %d\n", hl, hr, nc); diff --git a/src/output/postscript.c b/src/output/postscript.c index d65162da..bd7a088a 100644 --- a/src/output/postscript.c +++ b/src/output/postscript.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -374,7 +375,7 @@ handle_option (struct outp_driver *this, const char *key, this->font_height = arg; break; default: - abort (); + NOT_REACHED (); } } break; @@ -400,7 +401,7 @@ handle_option (struct outp_driver *this, const char *key, x->line_width = dimension; break; default: - abort (); + NOT_REACHED (); } } break; @@ -417,7 +418,7 @@ handle_option (struct outp_driver *this, const char *key, } break; default: - abort (); + NOT_REACHED (); } return true; @@ -608,8 +609,7 @@ ps_submit (struct outp_driver *this UNUSED, struct som_entity *s) case SOM_CHART: break; default: - abort (); - break; + NOT_REACHED (); } } diff --git a/src/output/table.c b/src/output/table.c index 1b120124..430742d7 100644 --- a/src/output/table.c +++ b/src/output/table.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -305,7 +306,7 @@ tab_box (struct tab_table *t, int f_h, int f_v, int i_h, int i_v, x2, t->col_ofs, x2 + t->col_ofs, y2, t->row_ofs, y2 + t->row_ofs, t->nc, t->nr); - abort (); + NOT_REACHED (); } #endif @@ -804,12 +805,12 @@ tab_offset (struct tab_table *t, int col, int row) if (row < -1 || row >= t->nr) { printf ("tab_offset(): row=%d in %d-row table\n", row, t->nr); - abort (); + NOT_REACHED (); } if (col < -1 || col >= t->nc) { printf ("tab_offset(): col=%d in %d-column table\n", col, t->nc); - abort (); + NOT_REACHED (); } #endif @@ -870,7 +871,7 @@ rule_to_spacing_type (unsigned char type) case TAL_2: return OUTP_L_DOUBLE; default: - abort (); + NOT_REACHED (); } } @@ -1256,7 +1257,7 @@ translate_justification (unsigned int opt) case TAB_CENTER: return OUTP_CENTER; default: - abort (); + NOT_REACHED (); } } @@ -1275,7 +1276,7 @@ rule_to_draw_type (unsigned char type) case TAL_2: return OUTP_L_DOUBLE; default: - abort (); + NOT_REACHED (); } } diff --git a/src/ui/terminal/ChangeLog b/src/ui/terminal/ChangeLog index 039ac644..7129d050 100644 --- a/src/ui/terminal/ChangeLog +++ b/src/ui/terminal/ChangeLog @@ -1,3 +1,8 @@ +Fri Jul 7 20:03:42 2006 Ben Pfaff + + * main.c: (main) Register SIGABRT with bug_handler also. + (bug_handler) Handle SIGABRT also. + Tue Jun 27 22:44:56 2006 Ben Pfaff Fix regression in command name completion reported by John diff --git a/src/ui/terminal/command-line.c b/src/ui/terminal/command-line.c index 94c5eea1..8511f290 100644 --- a/src/ui/terminal/command-line.c +++ b/src/ui/terminal/command-line.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -180,7 +181,7 @@ parse_command_line (int argc, char **argv) case 0: break; default: - assert (0); + NOT_REACHED (); } } diff --git a/src/ui/terminal/main.c b/src/ui/terminal/main.c index 2ad53d36..edc59edd 100644 --- a/src/ui/terminal/main.c +++ b/src/ui/terminal/main.c @@ -75,6 +75,7 @@ void interrupt_handler(int sig); int main (int argc, char **argv) { + signal (SIGABRT, bug_handler); signal (SIGSEGV, bug_handler); signal (SIGFPE, bug_handler); signal (SIGINT, interrupt_handler); @@ -149,15 +150,14 @@ bug_handler(int sig) { switch (sig) { + case SIGABRT: + request_bug_report_and_abort("Assertion Failure/Abort"); case SIGFPE: request_bug_report_and_abort("Floating Point Exception"); - break; case SIGSEGV: request_bug_report_and_abort("Segmentation Violation"); - break; default: - request_bug_report_and_abort(""); - break; + request_bug_report_and_abort("Unknown"); } }