Replace all exit() with SWIG_exit()

For consistent cleanup on error
This commit is contained in:
William S Fulton 2019-07-29 19:35:54 +01:00
commit 2cf075558c
11 changed files with 24 additions and 24 deletions

View file

@ -16,7 +16,6 @@
* sure there are no unmarked options.
*
* TODO:
* - This module needs to be modified so that it doesn't call exit().
* Should have cleaner error handling in general.
* ----------------------------------------------------------------------------- */
@ -88,11 +87,11 @@ void Swig_check_options(int check_input) {
}
if (error) {
Printf(stderr, "Use 'swig -help' for available options.\n");
exit(1);
SWIG_exit(EXIT_FAILURE);
}
if (check_input && marked[numargs - 1]) {
Printf(stderr, "Must specify an input file. Use -help for available options.\n");
exit(1);
SWIG_exit(EXIT_FAILURE);
}
}
@ -105,5 +104,5 @@ void Swig_check_options(int check_input) {
void Swig_arg_error(void) {
Printf(stderr, "SWIG : Unable to parse command line options.\n");
Printf(stderr, "Use 'swig -help' for available options.\n");
exit(1);
SWIG_exit(EXIT_FAILURE);
}

View file

@ -1177,7 +1177,7 @@ String *Swig_string_command(String *s) {
pclose(fp);
} else {
Swig_error("SWIG", Getline(s), "Command encoder fails attempting '%s'.\n", s);
exit(1);
SWIG_exit(EXIT_FAILURE);
}
}
#endif
@ -1327,7 +1327,8 @@ static int split_regex_pattern_subst(String *s, String **pattern, String **subst
err_out:
Swig_error("SWIG", Getline(s), "Invalid regex substitution: '%s'.\n", s);
exit(1);
SWIG_exit(EXIT_FAILURE);
return 0;
}
/* This function copies len characters from src to dst, possibly applying case conversions to them: if convertCase is 1, to upper case and if it is -1, to lower
@ -1449,7 +1450,7 @@ String *Swig_string_regex(String *s) {
if (!compiled_pat) {
Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n",
pcre_error, Char(pattern), pcre_errorpos);
exit(1);
SWIG_exit(EXIT_FAILURE);
}
rc = pcre_exec(compiled_pat, NULL, input, (int)strlen(input), 0, 0, captures, 30);
if (rc >= 0) {
@ -1457,7 +1458,7 @@ String *Swig_string_regex(String *s) {
} else if (rc != PCRE_ERROR_NOMATCH) {
Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" using \"%s\".\n",
rc, Char(pattern), input);
exit(1);
SWIG_exit(EXIT_FAILURE);
}
}
@ -1475,7 +1476,8 @@ String *Swig_pcre_version(void) {
String *Swig_string_regex(String *s) {
Swig_error("SWIG", Getline(s), "PCRE regex support not enabled in this SWIG build.\n");
exit(1);
SWIG_exit(EXIT_FAILURE);
return 0;
}
String *Swig_pcre_version(void) {

View file

@ -1105,7 +1105,7 @@ static int name_regexmatch_value(Node *n, String *pattern, String *s) {
Swig_error("SWIG", Getline(n),
"Invalid regex \"%s\": compilation failed at %d: %s\n",
Char(pattern), errpos, err);
exit(1);
SWIG_exit(EXIT_FAILURE);
}
rc = pcre_exec(compiled_pat, NULL, Char(s), Len(s), 0, 0, NULL, 0);
@ -1118,7 +1118,7 @@ static int name_regexmatch_value(Node *n, String *pattern, String *s) {
Swig_error("SWIG", Getline(n),
"Matching \"%s\" against regex \"%s\" failed: %d\n",
Char(s), Char(pattern), rc);
exit(1);
SWIG_exit(EXIT_FAILURE);
}
return 1;
@ -1131,7 +1131,7 @@ static int name_regexmatch_value(Node *n, String *pattern, String *s) {
(void)s;
Swig_error("SWIG", Getline(n),
"PCRE regex matching is not available in this SWIG build.\n");
exit(1);
SWIG_exit(EXIT_FAILURE);
}
#endif /* HAVE_PCRE/!HAVE_PCRE */

View file

@ -833,7 +833,7 @@ static int look(Scanner *s) {
return SWIG_TOKEN_MODEQUAL;
} else if (c == '}') {
Swig_error(cparse_file, cparse_line, "Syntax error. Extraneous '%%}'\n");
exit(1);
SWIG_exit(EXIT_FAILURE);
} else {
retract(s, 1);
return SWIG_TOKEN_PERCENT;

View file

@ -438,6 +438,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern void Language_replace_special_variables(String *method, String *tm, Parm *parm);
extern void Swig_print(DOH *object, int count);
extern void Swig_print_with_location(DOH *object, int count);
extern void SWIG_exit(int exit_code);
/* -- template init -- */