aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2019-07-29 19:35:54 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2019-07-31 00:08:49 +0100
commit2cf075558ce27ee0d88b71441c8cd83aabbf8028 (patch)
tree2147805a146816462cd16377c6bbba09e7641383
parentb36ae64185cc6d293d9350126f51ab23c0c7e36a (diff)
downloadswig-2cf075558ce27ee0d88b71441c8cd83aabbf8028.tar.gz
Replace all exit() with SWIG_exit()
For consistent cleanup on error
-rw-r--r--Source/CParse/parser.y8
-rw-r--r--Source/Modules/guile.cxx2
-rw-r--r--Source/Modules/php.cxx4
-rw-r--r--Source/Modules/python.cxx1
-rw-r--r--Source/Modules/swigmod.h1
-rw-r--r--Source/Modules/typepass.cxx4
-rw-r--r--Source/Swig/getopt.c7
-rw-r--r--Source/Swig/misc.c12
-rw-r--r--Source/Swig/naming.c6
-rw-r--r--Source/Swig/scanner.c2
-rw-r--r--Source/Swig/swig.h1
11 files changed, 24 insertions, 24 deletions
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index 08c92b9cf..470b7d065 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -1779,7 +1779,7 @@ declaration : swig_directive { $$ = $1; }
} else {
Swig_error(cparse_file, cparse_line, "Syntax error in input(1).\n");
}
- exit(1);
+ SWIG_exit(EXIT_FAILURE);
}
/* Out of class constructor/destructor declarations */
| c_constructor_decl {
@@ -3359,7 +3359,7 @@ c_decl_tail : SEMI {
} else {
Swig_error(cparse_file, cparse_line, "Syntax error - possibly a missing semicolon.\n");
}
- exit(1);
+ SWIG_exit(EXIT_FAILURE);
}
;
@@ -3649,7 +3649,7 @@ c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end {
}
if (err) {
Swig_error(cparse_file,cparse_line,"Syntax error in input(2).\n");
- exit(1);
+ SWIG_exit(EXIT_FAILURE);
}
}
;
@@ -4632,7 +4632,7 @@ cpp_members : cpp_member cpp_members {
int start_line = cparse_line;
skip_decl();
Swig_error(cparse_file,start_line,"Syntax error in input(3).\n");
- exit(1);
+ SWIG_exit(EXIT_FAILURE);
} cpp_members {
$$ = $3;
}
diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx
index 7b42ff94f..461c69e50 100644
--- a/Source/Modules/guile.cxx
+++ b/Source/Modules/guile.cxx
@@ -255,7 +255,7 @@ public:
if (goops) {
if (linkage != GUILE_LSTYLE_PASSIVE && linkage != GUILE_LSTYLE_MODULE) {
Printf(stderr, "guile: GOOPS support requires passive or module linkage\n");
- exit(1);
+ SWIG_exit(EXIT_FAILURE);
}
}
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index b192d6f6e..1edbd874c 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -1223,7 +1223,7 @@ public:
/* FIXME: How should this be handled? The rest of SWIG just seems
* to not bother checking for malloc failing! */
fprintf(stderr, "Malloc failed!\n");
- exit(1);
+ SWIG_exit(EXIT_FAILURE);
}
for (i = 0; i < max_num_of_arguments; ++i) {
arg_names[i] = NULL;
@@ -1235,7 +1235,7 @@ public:
/* FIXME: How should this be handled? The rest of SWIG just seems
* to not bother checking for malloc failing! */
fprintf(stderr, "Malloc failed!\n");
- exit(1);
+ SWIG_exit(EXIT_FAILURE);
}
for (i = 0; i < max_num_of_arguments; ++i) {
arg_values[i] = NULL;
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index 39308d4b8..ea31af029 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -16,7 +16,6 @@
#include "cparse.h"
#include <ctype.h>
#include <errno.h>
-#include <stdlib.h>
#include "pydoc.h"
#include <stdint.h>
diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h
index 583cb13fe..bfb93d1a7 100644
--- a/Source/Modules/swigmod.h
+++ b/Source/Modules/swigmod.h
@@ -371,7 +371,6 @@ struct TargetLanguageModule {
int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm);
void emit_parameter_variables(ParmList *l, Wrapper *f);
void emit_return_variable(Node *n, SwigType *rt, Wrapper *f);
-void SWIG_exit(int); /* use EXIT_{SUCCESS,FAILURE} */
void SWIG_config_file(const_String_or_char_ptr );
const String *SWIG_output_directory();
void SWIG_config_cppext(const char *ext);
diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx
index 57125fcbb..8dbf0865e 100644
--- a/Source/Modules/typepass.cxx
+++ b/Source/Modules/typepass.cxx
@@ -961,7 +961,7 @@ class TypePass:private Dispatcher {
if (Getattr(c, "sym:overloaded") != checkoverloaded) {
Printf(stdout, "sym:overloaded error c:%p checkoverloaded:%p\n", c, checkoverloaded);
Swig_print_node(c);
- exit (1);
+ SWIG_exit(EXIT_FAILURE);
}
String *decl = Strcmp(nodeType(c), "using") == 0 ? NewString("------") : Getattr(c, "decl");
@@ -969,7 +969,7 @@ class TypePass:private Dispatcher {
if (!Getattr(c, "sym:overloaded")) {
Printf(stdout, "sym:overloaded error.....%p\n", c);
Swig_print_node(c);
- exit (1);
+ SWIG_exit(EXIT_FAILURE);
}
c = Getattr(c, "sym:nextSibling");
}
diff --git a/Source/Swig/getopt.c b/Source/Swig/getopt.c
index 74076a5f0..6970dc177 100644
--- a/Source/Swig/getopt.c
+++ b/Source/Swig/getopt.c
@@ -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);
}
diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
index 6b071185b..7b818478f 100644
--- a/Source/Swig/misc.c
+++ b/Source/Swig/misc.c
@@ -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) {
diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c
index 1b6c963e7..6689ceb7a 100644
--- a/Source/Swig/naming.c
+++ b/Source/Swig/naming.c
@@ -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 */
diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c
index 908bc747f..e5a267ae5 100644
--- a/Source/Swig/scanner.c
+++ b/Source/Swig/scanner.c
@@ -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;
diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
index 1acd32d5d..e0783dae1 100644
--- a/Source/Swig/swig.h
+++ b/Source/Swig/swig.h
@@ -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 -- */