Eliminate calls to abort()

Call Exit(EXIT_FAILURE) instead so that output files get removed.
This commit is contained in:
Olly Betts 2022-03-06 12:45:18 +13:00
commit 735732d721
6 changed files with 35 additions and 52 deletions

View file

@ -18,10 +18,6 @@
* DohDelete() * DohDelete()
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
#ifndef SWIG_DEBUG_DELETE
#define SWIG_DEBUG_DELETE 0
#endif
void DohDelete(DOH *obj) { void DohDelete(DOH *obj) {
DohBase *b = (DohBase *) obj; DohBase *b = (DohBase *) obj;
DohObjInfo *objinfo; DohObjInfo *objinfo;
@ -29,13 +25,8 @@ void DohDelete(DOH *obj) {
if (!obj) if (!obj)
return; return;
if (!DohCheck(b)) { if (!DohCheck(b)) {
#if SWIG_DEBUG_DELETE fputs("Fatal internal error: Attempt to delete a non-DOH object.\n", stderr);
fputs("DOH: Fatal error. Attempt to delete a non-doh object.\n", stderr); Exit(EXIT_FAILURE);
abort();
#else
assert(0);
#endif
return;
} }
if (b->flag_intern) if (b->flag_intern)
return; return;
@ -64,13 +55,8 @@ DOH *DohCopy(const DOH *obj) {
if (!obj) if (!obj)
return 0; return 0;
if (!DohCheck(b)) { if (!DohCheck(b)) {
#if SWIG_DEBUG_DELETE fputs("Fatal internal error: Attempt to copy a non-DOH object.\n", stderr);
fputs("DOH: Fatal error. Attempt to copy a non-doh object.\n", stderr); Exit(EXIT_FAILURE);
abort();
#else
assert(0);
#endif
return 0;
} }
objinfo = b->type; objinfo = b->type;
if (objinfo->doh_copy) { if (objinfo->doh_copy) {

View file

@ -476,7 +476,8 @@ public:
Printf(f_init, "}\n"); Printf(f_init, "}\n");
break; break;
default: default:
abort(); // for now fputs("Fatal internal error: Invalid Guile linkage setting.\n", stderr);
Exit(EXIT_FAILURE);
} }
if (scmstub) { if (scmstub) {

View file

@ -398,26 +398,18 @@ public:
*/ */
void oc_SwigType_del_reference(SwigType *t) { void oc_SwigType_del_reference(SwigType *t) {
char *c = Char(t); if (SwigType_isqualifier(t)) {
if (strncmp(c, "q(", 2) == 0) { SwigType_del_qualifier(t);
Delete(SwigType_pop(t));
c = Char(t);
} }
if (strncmp(c, "r.", 2)) { SwigType_del_reference(t);
printf("Fatal error. SwigType_del_pointer applied to non-pointer.\n");
abort();
}
Replace(t, "r.", "", DOH_REPLACE_FIRST);
} }
void oc_SwigType_del_array(SwigType *t) { void oc_SwigType_del_array(SwigType *t) {
char *c = Char(t); if (SwigType_isqualifier(t)) {
if (strncmp(c, "q(", 2) == 0) { SwigType_del_qualifier(t);
Delete(SwigType_pop(t));
c = Char(t);
} }
if (strncmp(c, "a(", 2) == 0) { if (SwigType_isarray(t)) {
Delete(SwigType_pop(t)); SwigType_del_array(t);
} }
} }

View file

@ -2055,8 +2055,7 @@ String *Preprocessor_parse(String *s) {
break; break;
default: default:
Printf(stderr, "cpp: Invalid parser state %d\n", state); Printf(stderr, "cpp: Invalid parser state %d\n", state);
abort(); Exit(EXIT_FAILURE);
break;
} }
} }
while (level > 0) { while (level > 0) {

View file

@ -443,7 +443,7 @@ int Preprocessor_expr(DOH *s, int *error) {
default: default:
fprintf(stderr, "Internal error in expression evaluator.\n"); fprintf(stderr, "Internal error in expression evaluator.\n");
abort(); Exit(EXIT_FAILURE);
} }
} }

View file

@ -359,8 +359,8 @@ SwigType *SwigType_del_pointer(SwigType *t) {
c++; c++;
} }
if (strncmp(c, "p.", 2)) { if (strncmp(c, "p.", 2)) {
printf("Fatal error. SwigType_del_pointer applied to non-pointer.\n"); printf("Fatal error: SwigType_del_pointer applied to non-pointer.\n");
abort(); Exit(EXIT_FAILURE);
} }
Delslice(t, 0, (int)((c - s) + 2)); Delslice(t, 0, (int)((c - s) + 2));
return t; return t;
@ -402,9 +402,10 @@ SwigType *SwigType_add_reference(SwigType *t) {
SwigType *SwigType_del_reference(SwigType *t) { SwigType *SwigType_del_reference(SwigType *t) {
char *c = Char(t); char *c = Char(t);
int check = strncmp(c, "r.", 2); if (strncmp(c, "r.", 2)) {
assert(check == 0); printf("Fatal error: SwigType_del_reference applied to non-reference.\n");
(void)check; Exit(EXIT_FAILURE);
}
Delslice(t, 0, 2); Delslice(t, 0, 2);
return t; return t;
} }
@ -438,9 +439,10 @@ SwigType *SwigType_add_rvalue_reference(SwigType *t) {
SwigType *SwigType_del_rvalue_reference(SwigType *t) { SwigType *SwigType_del_rvalue_reference(SwigType *t) {
char *c = Char(t); char *c = Char(t);
int check = strncmp(c, "z.", 2); if (strncmp(c, "z.", 2)) {
assert(check == 0); fprintf(stderr, "Fatal error: SwigType_del_rvalue_reference() applied to non-rvalue-reference.\n");
(void)check; Exit(EXIT_FAILURE);
}
Delslice(t, 0, 2); Delslice(t, 0, 2);
return t; return t;
} }
@ -643,9 +645,10 @@ SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size) {
SwigType *SwigType_del_array(SwigType *t) { SwigType *SwigType_del_array(SwigType *t) {
char *c = Char(t); char *c = Char(t);
int check = strncmp(c, "a(", 2); if (strncmp(c, "a(", 2)) {
assert(check == 0); fprintf(stderr, "Fatal error: SwigType_del_array() applied to non-array.\n");
(void)check; Exit(EXIT_FAILURE);
}
Delslice(t, 0, element_size(c)); Delslice(t, 0, element_size(c));
return t; return t;
} }
@ -738,8 +741,10 @@ void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep) {
char *c = Char(t); char *c = Char(t);
start = c; start = c;
if (strncmp(c, "a(", 2)) if (strncmp(c, "a(", 2)) {
abort(); fprintf(stderr, "Fatal error: SwigType_array_type applied to non-array.\n");
Exit(EXIT_FAILURE);
}
while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) { while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) {
c = strchr(c, '.'); c = strchr(c, '.');
@ -831,8 +836,8 @@ SwigType *SwigType_pop_function(SwigType *t) {
c = Char(t); c = Char(t);
} }
if (strncmp(c, "f(", 2)) { if (strncmp(c, "f(", 2)) {
printf("Fatal error. SwigType_pop_function applied to non-function.\n"); fprintf(stderr, "Fatal error. SwigType_pop_function applied to non-function.\n");
abort(); Exit(EXIT_FAILURE);
} }
g = SwigType_pop(t); g = SwigType_pop(t);
if (f) if (f)