diff --git a/Source/DOH/base.c b/Source/DOH/base.c index f5e418893..442ea3934 100644 --- a/Source/DOH/base.c +++ b/Source/DOH/base.c @@ -18,10 +18,6 @@ * DohDelete() * ----------------------------------------------------------------------------- */ -#ifndef SWIG_DEBUG_DELETE -#define SWIG_DEBUG_DELETE 0 -#endif - void DohDelete(DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; @@ -29,13 +25,8 @@ void DohDelete(DOH *obj) { if (!obj) return; if (!DohCheck(b)) { -#if SWIG_DEBUG_DELETE - fputs("DOH: Fatal error. Attempt to delete a non-doh object.\n", stderr); - abort(); -#else - assert(0); -#endif - return; + fputs("Fatal internal error: Attempt to delete a non-DOH object.\n", stderr); + Exit(EXIT_FAILURE); } if (b->flag_intern) return; @@ -64,13 +55,8 @@ DOH *DohCopy(const DOH *obj) { if (!obj) return 0; if (!DohCheck(b)) { -#if SWIG_DEBUG_DELETE - fputs("DOH: Fatal error. Attempt to copy a non-doh object.\n", stderr); - abort(); -#else - assert(0); -#endif - return 0; + fputs("Fatal internal error: Attempt to copy a non-DOH object.\n", stderr); + Exit(EXIT_FAILURE); } objinfo = b->type; if (objinfo->doh_copy) { diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index e8b5975d2..c30bf06f0 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -476,7 +476,8 @@ public: Printf(f_init, "}\n"); break; default: - abort(); // for now + fputs("Fatal internal error: Invalid Guile linkage setting.\n", stderr); + Exit(EXIT_FAILURE); } if (scmstub) { diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 2938c1f3b..6e45309e8 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -398,26 +398,18 @@ public: */ void oc_SwigType_del_reference(SwigType *t) { - char *c = Char(t); - if (strncmp(c, "q(", 2) == 0) { - Delete(SwigType_pop(t)); - c = Char(t); + if (SwigType_isqualifier(t)) { + SwigType_del_qualifier(t); } - if (strncmp(c, "r.", 2)) { - printf("Fatal error. SwigType_del_pointer applied to non-pointer.\n"); - abort(); - } - Replace(t, "r.", "", DOH_REPLACE_FIRST); + SwigType_del_reference(t); } void oc_SwigType_del_array(SwigType *t) { - char *c = Char(t); - if (strncmp(c, "q(", 2) == 0) { - Delete(SwigType_pop(t)); - c = Char(t); + if (SwigType_isqualifier(t)) { + SwigType_del_qualifier(t); } - if (strncmp(c, "a(", 2) == 0) { - Delete(SwigType_pop(t)); + if (SwigType_isarray(t)) { + SwigType_del_array(t); } } diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 1ede58354..439788b4b 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -2055,8 +2055,7 @@ String *Preprocessor_parse(String *s) { break; default: Printf(stderr, "cpp: Invalid parser state %d\n", state); - abort(); - break; + Exit(EXIT_FAILURE); } } while (level > 0) { diff --git a/Source/Preprocessor/expr.c b/Source/Preprocessor/expr.c index d7a65a77e..e5c768765 100644 --- a/Source/Preprocessor/expr.c +++ b/Source/Preprocessor/expr.c @@ -443,7 +443,7 @@ int Preprocessor_expr(DOH *s, int *error) { default: fprintf(stderr, "Internal error in expression evaluator.\n"); - abort(); + Exit(EXIT_FAILURE); } } diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index 9944a9eeb..9102b80d1 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -359,8 +359,8 @@ SwigType *SwigType_del_pointer(SwigType *t) { c++; } if (strncmp(c, "p.", 2)) { - printf("Fatal error. SwigType_del_pointer applied to non-pointer.\n"); - abort(); + printf("Fatal error: SwigType_del_pointer applied to non-pointer.\n"); + Exit(EXIT_FAILURE); } Delslice(t, 0, (int)((c - s) + 2)); return t; @@ -402,9 +402,10 @@ SwigType *SwigType_add_reference(SwigType *t) { SwigType *SwigType_del_reference(SwigType *t) { char *c = Char(t); - int check = strncmp(c, "r.", 2); - assert(check == 0); - (void)check; + if (strncmp(c, "r.", 2)) { + printf("Fatal error: SwigType_del_reference applied to non-reference.\n"); + Exit(EXIT_FAILURE); + } Delslice(t, 0, 2); return t; } @@ -438,9 +439,10 @@ SwigType *SwigType_add_rvalue_reference(SwigType *t) { SwigType *SwigType_del_rvalue_reference(SwigType *t) { char *c = Char(t); - int check = strncmp(c, "z.", 2); - assert(check == 0); - (void)check; + if (strncmp(c, "z.", 2)) { + fprintf(stderr, "Fatal error: SwigType_del_rvalue_reference() applied to non-rvalue-reference.\n"); + Exit(EXIT_FAILURE); + } Delslice(t, 0, 2); return t; } @@ -643,9 +645,10 @@ SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size) { SwigType *SwigType_del_array(SwigType *t) { char *c = Char(t); - int check = strncmp(c, "a(", 2); - assert(check == 0); - (void)check; + if (strncmp(c, "a(", 2)) { + fprintf(stderr, "Fatal error: SwigType_del_array() applied to non-array.\n"); + Exit(EXIT_FAILURE); + } Delslice(t, 0, element_size(c)); return t; } @@ -738,8 +741,10 @@ void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep) { char *c = Char(t); start = c; - if (strncmp(c, "a(", 2)) - abort(); + if (strncmp(c, "a(", 2)) { + fprintf(stderr, "Fatal error: SwigType_array_type applied to non-array.\n"); + Exit(EXIT_FAILURE); + } while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) { c = strchr(c, '.'); @@ -831,8 +836,8 @@ SwigType *SwigType_pop_function(SwigType *t) { c = Char(t); } if (strncmp(c, "f(", 2)) { - printf("Fatal error. SwigType_pop_function applied to non-function.\n"); - abort(); + fprintf(stderr, "Fatal error. SwigType_pop_function applied to non-function.\n"); + Exit(EXIT_FAILURE); } g = SwigType_pop(t); if (f)