diff --git a/CHANGES.current b/CHANGES.current index 257565587..90dcbcb94 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,31 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2022-03-06: olly + SWIG should now reliably exit with status 0 if the run was + successful and status 1 if there was an error (or a warning and + -Werror was in effect). + + Previously in some situations SWIG would try to exit with the + status set to the number of errors encountered, but that's + problematic - for example if there were 256 errors this would + result in exit status 0 on most platforms. Also some error + statuses have special meanings e.g. those defined by . + Also SWIG/Javascript tried to exit with status -1 in a few places + (which typically results in exit status 255). + +2022-03-03: olly + #1901 #2223 SWIG should now always exit cleanly if memory + allocation fails, including removing any output files created + during the current run. + + Previously most places in the code didn't check for a NULL return + from malloc()/realloc()/calloc() at all, typically resulting in + undefined behaviour; some places used assert() to check for a NULL + return (which is a misuse of assert() and such checks disappear if + built with NDEBUG defined leaving us back with undefined + behaviour). + 2022-03-03: olly #891 Report errors for typemap attributes without a value (previously SWIG segfaulted) and for typemap types with a value diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index fd607f1d7..ad90d7b63 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -2807,7 +2807,7 @@ int Python::top(Node *n) { f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 40d58f2bd..3ca06e6b0 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1782,7 +1782,7 @@ declaration : swig_directive { $$ = $1; } } else { Swig_error(cparse_file, cparse_line, "Syntax error in input(1).\n"); } - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } /* Out of class constructor/destructor declarations */ | c_constructor_decl { @@ -2015,7 +2015,7 @@ constant_directive : CONSTANT identifier EQUAL definetype SEMI { } | CONSTANT error END { Swig_error(cparse_file,cparse_line,"Missing semicolon (';') after %%constant.\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } ; @@ -3372,7 +3372,7 @@ c_decl_tail : SEMI { } else { Swig_error(cparse_file, cparse_line, "Syntax error - possibly a missing semicolon (';').\n"); } - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } ; @@ -3666,7 +3666,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"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } ; @@ -4661,7 +4661,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"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } cpp_members { $$ = $3; } diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h index 8353863d6..273966d19 100644 --- a/Source/DOH/doh.h +++ b/Source/DOH/doh.h @@ -126,6 +126,8 @@ #define DohRealloc DOH_NAMESPACE(Realloc) #define DohCalloc DOH_NAMESPACE(Calloc) #define DohFree DOH_NAMESPACE(Free) +#define DohSetExitHandler DOH_NAMESPACE(SetExitHandler) +#define DohExit DOH_NAMESPACE(Exit) #endif #define DOH_MAJOR_VERSION 0 @@ -274,6 +276,24 @@ extern int DohGetMaxHashExpand(void); extern void DohSetmark(DOH *obj, int x); extern int DohGetmark(DOH *obj); +/* Set the function for DohExit() to call instead of exit(). + * + * The registered function can perform clean up, etc and then should call + * exit(status) to end the process. Bear in mind that this can be called + * after malloc() has failed, so avoiding allocating additional memory in + * the registered function is a good idea. + * + * The registered function is unregistered by DohExit() before calling it to + * avoid the potential for infinite loops. + * + * Note: This is sort of like C's atexit(), only for DohExit(). However + * only one function can be registered (setting a new function overrides the + * previous one) and the registered function is passed the exit status and + * should itself call exit(). + */ +extern void DohSetExitHandler(void (*new_handler)(int)); +extern void DohExit(int status); + /* ----------------------------------------------------------------------------- * Strings. * ----------------------------------------------------------------------------- */ @@ -447,6 +467,8 @@ extern void DohMemoryDebug(void); #define Realloc DohRealloc #define Calloc DohCalloc #define Free DohFree +#define SetExitHandler DohSetExitHandler +#define Exit DohExit #endif #ifdef NIL diff --git a/Source/DOH/memory.c b/Source/DOH/memory.c index 6283947fa..dcba95b56 100644 --- a/Source/DOH/memory.c +++ b/Source/DOH/memory.c @@ -235,6 +235,26 @@ void DohMemoryDebug(void) { } +/* Function to call instead of exit(). */ +static void (*doh_exit_handler)(int) = NULL; + +void DohSetExitHandler(void (*new_handler)(int)) { + doh_exit_handler = new_handler; +} + +void DohExit(int status) { + if (doh_exit_handler) { + void (*handler)(int) = doh_exit_handler; + /* Unset the handler to avoid infinite loops if it tries to do something + * which calls DohExit() (e.g. calling Malloc() and that failing). + */ + doh_exit_handler = NULL; + handler(status); + } else { + exit(status); + } +} + static void allocation_failed(size_t n, size_t size) { /* Report and exit as directly as possible to try to avoid further issues due * to lack of memory. */ @@ -251,7 +271,7 @@ static void allocation_failed(size_t n, size_t size) { fprintf(stderr, "Failed to allocate %lu*%lu bytes\n", (unsigned long)n, (unsigned long)size); #endif } - exit(EXIT_FAILURE); + DohExit(EXIT_FAILURE); } void *DohMalloc(size_t size) { diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 531ce3669..38626420d 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -134,7 +134,7 @@ int CFFI::top(Node *n) { File *f_lisp = NewFile(lisp_filename, "w", SWIG_output_files()); if (!f_lisp) { FileErrorDisplay(lisp_filename); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } if (CPlusPlus || CWrap) { @@ -142,7 +142,7 @@ int CFFI::top(Node *n) { if (!f_begin) { Delete(f_lisp); Printf(stderr, "Unable to open %s for writing\n", cxx_filename); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } String *clos_filename = NewString(""); @@ -151,7 +151,7 @@ int CFFI::top(Node *n) { if (!f_clos) { Delete(f_lisp); Printf(stderr, "Unable to open %s for writing\n", cxx_filename); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } else { f_begin = NewString(""); @@ -217,7 +217,7 @@ int CFFI::classHandler(Node *n) { } else { Printf(stderr, "Don't know how to deal with %s kind of class yet.\n", kind); Printf(stderr, " (name: %s)\n", name); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); return SWIG_OK; } @@ -873,7 +873,7 @@ void CFFI::emit_struct_union(Node *n, bool un = false) { if (Strcmp(kind, "struct") != 0 && Strcmp(kind, "union") != 0) { Printf(stderr, "Don't know how to deal with %s kind of class yet.\n", kind); Printf(stderr, " (name: %s)\n", name); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } String *lisp_name = lispify_name(n, name, "'classname"); @@ -909,7 +909,7 @@ void CFFI::emit_struct_union(Node *n, bool un = false) { // nodeType(c), // Getattr(c, "name"), // Getattr(c, "type")); - // SWIG_exit(EXIT_FAILURE); + // Exit(EXIT_FAILURE); } else { SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"), Getattr(c, "type")); diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index edb79e13e..a94969f31 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -316,24 +316,24 @@ public: if (!outfile) { Printf(stderr, "Unable to determine outfile\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } if (directorsEnabled()) { if (!outfile_h) { Printf(stderr, "Unable to determine outfile_h\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } @@ -670,7 +670,7 @@ public: f_single_out = NewFile(filen, "w", SWIG_output_files()); if (!f_single_out) { FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); @@ -684,7 +684,7 @@ public: File *f = NewFile(filen, "w", SWIG_output_files()); if (!f) { FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); @@ -2122,12 +2122,12 @@ public: full_imclass_name = NewStringf("%s", imclass_name); if (Cmp(proxy_class_name, imclass_name) == 0) { Printf(stderr, "Class name cannot be equal to intermediary class name: %s\n", proxy_class_name); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } if (Cmp(proxy_class_name, module_class_name) == 0) { Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } else { if (namespce) { @@ -3660,7 +3660,7 @@ public: if (newdir_error) { Printf(stderr, "%s\n", newdir_error); Delete(newdir_error); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Printv(output_directory, nspace_subdirectory, SWIG_FILE_DELIMITER, 0); Delete(nspace_subdirectory); diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index b7283eac2..71264105d 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -378,24 +378,24 @@ public: if (!outfile) { Printf(stderr, "Unable to determine outfile\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } if (directorsEnabled()) { if (!outfile_h) { Printf(stderr, "Unable to determine outfile_h\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } @@ -518,7 +518,7 @@ public: File *im_d_file = NewFile(filen, "w", SWIG_output_files()); if (!im_d_file) { FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); @@ -549,7 +549,7 @@ public: File *proxy_d_file = NewFile(filen, "w", SWIG_output_files()); if (!proxy_d_file) { FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); @@ -583,7 +583,7 @@ public: File *file = NewFile(filename, "w", SWIG_output_files()); if (!file) { FileErrorDisplay(filename); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Delete(filename); @@ -863,7 +863,7 @@ public: File *class_file = NewFile(filename, "w", SWIG_output_files()); if (!class_file) { FileErrorDisplay(filename); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Append(filenames_list, Copy(filename)); Delete(filename); @@ -1335,7 +1335,7 @@ public: Delete(output_directory); if (!class_file) { FileErrorDisplay(filename); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Append(filenames_list, Copy(filename)); Delete(filename); @@ -3434,7 +3434,7 @@ private: class_file = NewFile(filename, "w", SWIG_output_files()); if (!class_file) { FileErrorDisplay(filename); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Append(filenames_list, Copy(filename)); Delete(filename); @@ -3756,7 +3756,7 @@ private: Swig_error(input_file, line_number, "Class name cannot be equal to intermediary D module name: %s\n", class_name); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } String *nspace = getNSpace(); @@ -3769,7 +3769,7 @@ private: Swig_error(input_file, line_number, "Class name cannot be the same as the root package it is in: %s\n", class_name); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Delete(dotless_package); } else { @@ -3778,7 +3778,7 @@ private: Swig_error(input_file, line_number, "Class name cannot be the same as the outermost namespace it is in: %s\n", class_name); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Delete(outer); } @@ -3790,7 +3790,7 @@ private: Swig_error(input_file, line_number, "Class name cannot be the same as the innermost namespace it is in: %s\n", class_name); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Delete(inner); } else { @@ -3798,7 +3798,7 @@ private: Swig_error(input_file, line_number, "Class name cannot be equal to proxy D module name: %s\n", class_name); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } } @@ -4498,7 +4498,7 @@ private: if (newdir_error) { Printf(stderr, "%s\n", newdir_error); Delete(newdir_error); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Printv(output_directory, nspace_subdirectory, SWIG_FILE_DELIMITER, 0); Delete(nspace_subdirectory); diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index f97e7ee20..0c039fcfc 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -337,7 +337,7 @@ private: if (saw_nocgo_flag) { Printf(stderr, "SWIG -go: -no-cgo option is no longer supported\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } if (gccgo_flag && !pkgpath_option && !prefix_option) { @@ -356,7 +356,7 @@ private: // for this test to simply be taken out. if (intgo_type_size == 0 && !display_help) { Printf(stderr, "SWIG -go: -intgosize option required but not specified\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } if (intgo_type_size == 32) { @@ -453,7 +453,7 @@ private: FILE *swig_input = Swig_open(swig_filename); if (swig_input == NULL) { FileErrorDisplay(swig_filename); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } String *swig_input_content = Swig_read_file(swig_input); siphash(&hash, Char(swig_input_content), Len(swig_input_content)); @@ -467,25 +467,25 @@ private: f_c_begin = NewFile(c_filename, "w", SWIG_output_files()); if (!f_c_begin) { FileErrorDisplay(c_filename); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } if (directorsEnabled()) { if (!c_filename_h) { Printf(stderr, "Unable to determine outfile_h\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_c_directors_h = NewFile(c_filename_h, "w", SWIG_output_files()); if (!f_c_directors_h) { FileErrorDisplay(c_filename_h); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } f_go_begin = NewFile(go_filename, "w", SWIG_output_files()); if (!f_go_begin) { FileErrorDisplay(go_filename); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_c_runtime = NewString(""); diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index 03e777cf4..e8b5975d2 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -132,7 +132,7 @@ public: if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); - SWIG_exit(EXIT_SUCCESS); + Exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-prefix") == 0) { if (argv[i + 1]) { prefix = NewString(argv[i + 1]); @@ -176,7 +176,7 @@ public: procdoc = NewFile(argv[i + 1], "w", SWIG_output_files()); if (!procdoc) { FileErrorDisplay(argv[i + 1]); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Swig_mark_arg(i); Swig_mark_arg(i + 1); @@ -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"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } @@ -298,7 +298,7 @@ public: f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); @@ -495,7 +495,7 @@ public: File *scmstubfile = NewFile(fname, "w", SWIG_output_files()); if (!scmstubfile) { FileErrorDisplay(fname); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Delete(fname); @@ -526,7 +526,7 @@ public: File *goopsfile = NewFile(fname, "w", SWIG_output_files()); if (!goopsfile) { FileErrorDisplay(fname); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Delete(fname); Swig_banner_target_lang(goopsfile, ";;;"); diff --git a/Source/Modules/interface.cxx b/Source/Modules/interface.cxx index fee6cd7da..3398fa428 100644 --- a/Source/Modules/interface.cxx +++ b/Source/Modules/interface.cxx @@ -90,7 +90,7 @@ static void collect_interface_base_classes(Node *n) { if (!GetFlag(base.item, "feature:ignore")) { if (!Getattr(base.item, "feature:interface")) { Swig_error(Getfile(n), Getline(n), "Base class '%s' of '%s' is not similarly marked as an interface.\n", SwigType_namestr(Getattr(base.item, "name")), SwigType_namestr(Getattr(n, "name"))); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } } @@ -114,7 +114,7 @@ static void process_interface_name(Node *n) { String *interface_name = Getattr(n, "feature:interface:name"); if (!Len(interface_name)) { Swig_error(Getfile(n), Getline(n), "The interface feature for '%s' is missing the name attribute.\n", SwigType_namestr(Getattr(n, "name"))); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } if (Strchr(interface_name, '%')) { String *name = NewStringf(interface_name, Getattr(n, "sym:name")); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 444fe02d1..87dd31b22 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -371,24 +371,24 @@ public: if (!outfile) { Printf(stderr, "Unable to determine outfile\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } if (directorsEnabled()) { if (!outfile_h) { Printf(stderr, "Unable to determine outfile_h\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } @@ -521,7 +521,7 @@ public: File *f_im = NewFile(filen, "w", SWIG_output_files()); if (!f_im) { FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); @@ -576,7 +576,7 @@ public: File *f_module = NewFile(filen, "w", SWIG_output_files()); if (!f_module) { FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); @@ -635,7 +635,7 @@ public: File *f_module = NewFile(filen, "w", SWIG_output_files()); if (!f_module) { FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); @@ -1343,7 +1343,7 @@ public: File *f_enum = NewFile(filen, "w", SWIG_output_files()); if (!f_enum) { FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); @@ -2215,12 +2215,12 @@ public: if (Cmp(proxy_class_name, imclass_name) == 0) { Printf(stderr, "Class name cannot be equal to intermediary class name: %s\n", proxy_class_name); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } if (Cmp(proxy_class_name, module_class_name) == 0) { Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } else { if (outerClassesPrefix) { @@ -2260,7 +2260,7 @@ public: f_proxy = NewFile(filen, "w", SWIG_output_files()); if (!f_proxy) { FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); @@ -2294,7 +2294,7 @@ public: f_interface = NewFile(filen, "w", SWIG_output_files()); if (!f_interface) { FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Append(filenames_list, filen); // file name ownership goes to the list emitBanner(f_interface); @@ -3497,7 +3497,7 @@ public: File *f_swigtype = NewFile(filen, "w", SWIG_output_files()); if (!f_swigtype) { FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Append(filenames_list, Copy(filen)); Delete(filen); @@ -3712,7 +3712,7 @@ public: if (newdir_error) { Printf(stderr, "%s\n", newdir_error); Delete(newdir_error); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Printv(output_directory, nspace_subdirectory, SWIG_FILE_DELIMITER, 0); Delete(nspace_subdirectory); diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx index 9775f96c4..604b43743 100644 --- a/Source/Modules/javascript.cxx +++ b/Source/Modules/javascript.cxx @@ -537,21 +537,21 @@ void JAVASCRIPT::main(int argc, char *argv[]) { if (strcmp(argv[i], "-v8") == 0) { if (engine != -1) { Printf(stderr, ERR_MSG_ONLY_ONE_ENGINE_PLEASE); - SWIG_exit(-1); + Exit(EXIT_FAILURE); } Swig_mark_arg(i); engine = JSEmitter::V8; } else if (strcmp(argv[i], "-jsc") == 0) { if (engine != -1) { Printf(stderr, ERR_MSG_ONLY_ONE_ENGINE_PLEASE); - SWIG_exit(-1); + Exit(EXIT_FAILURE); } Swig_mark_arg(i); engine = JSEmitter::JavascriptCore; } else if (strcmp(argv[i], "-node") == 0) { if (engine != -1) { Printf(stderr, ERR_MSG_ONLY_ONE_ENGINE_PLEASE); - SWIG_exit(-1); + Exit(EXIT_FAILURE); } Swig_mark_arg(i); engine = JSEmitter::NodeJS; @@ -595,7 +595,7 @@ void JAVASCRIPT::main(int argc, char *argv[]) { default: { Printf(stderr, "SWIG Javascript: Unknown engine. Please specify one of '-jsc', '-v8' or '-node'.\n"); - SWIG_exit(-1); + Exit(EXIT_FAILURE); break; } } @@ -666,7 +666,7 @@ Template JSEmitter::getTemplate(const String *name) { if (!templ) { Printf(stderr, "Could not find template %s\n.", name); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Template t(templ, name); @@ -1576,7 +1576,7 @@ void JSCEmitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Ma break; default: Printf(stderr, "Illegal MarshallingMode."); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } tm = emitInputTypemap(n, p, wrapper, arg); Delete(arg); @@ -1599,7 +1599,7 @@ int JSCEmitter::initialize(Node *n) { f_wrap_cpp = NewFile(outfile, "w", SWIG_output_files()); if (!f_wrap_cpp) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } /* Initialization of members */ @@ -1920,7 +1920,7 @@ int V8Emitter::initialize(Node *n) { f_wrap_cpp = NewFile(outfile, "w", SWIG_output_files()); if (!f_wrap_cpp) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_runtime = NewString(""); @@ -2214,7 +2214,7 @@ void V8Emitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Mar break; default: Printf(stderr, "Illegal MarshallingMode."); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } tm = emitInputTypemap(n, p, wrapper, arg); @@ -2370,7 +2370,7 @@ Template::Template(const String *code_) { if (!code_) { Printf(stdout, "Template code was null. Illegal input for template."); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } code = NewString(code_); templateName = NewString(""); @@ -2380,7 +2380,7 @@ Template::Template(const String *code_, const String *templateName_) { if (!code_) { Printf(stdout, "Template code was null. Illegal input for template."); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } code = NewString(code_); diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index f92c14cb2..18cf8a346 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -304,7 +304,7 @@ public: f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 1f7ff044a..a6a04eb5d 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -403,14 +403,14 @@ static void SWIG_dump_runtime() { outfile = lang->defaultExternalRuntimeFilename(); if (!outfile) { Printf(stderr, "*** Please provide a filename for the external runtime\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } runtime = NewFile(outfile, "w", SWIG_output_files()); if (!runtime) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Swig_banner(runtime); @@ -420,7 +420,7 @@ static void SWIG_dump_runtime() { if (!s) { Printf(stderr, "*** Unable to open 'swiglabels.swg'\n"); Delete(runtime); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Printf(runtime, "%s", s); Delete(s); @@ -429,7 +429,7 @@ static void SWIG_dump_runtime() { if (!s) { Printf(stderr, "*** Unable to open 'swigerrors.swg'\n"); Delete(runtime); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Printf(runtime, "%s", s); Delete(s); @@ -438,7 +438,7 @@ static void SWIG_dump_runtime() { if (!s) { Printf(stderr, "*** Unable to open 'swigrun.swg'\n"); Delete(runtime); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Printf(runtime, "%s", s); Delete(s); @@ -451,13 +451,13 @@ static void SWIG_dump_runtime() { if (!s) { Printf(stderr, "*** Unable to open 'runtime.swg'\n"); Delete(runtime); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Printf(runtime, "%s", s); Delete(s); Delete(runtime); - SWIG_exit(EXIT_SUCCESS); + Exit(EXIT_SUCCESS); } static void getoptions(int argc, char *argv[]) { @@ -531,7 +531,7 @@ static void getoptions(int argc, char *argv[]) { Printf(stdout, "%s\n", version); Delete(version); Swig_mark_arg(i); - SWIG_exit(EXIT_SUCCESS); + Exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-small") == 0) { Wrapper_compact_print_mode_set(1); Wrapper_virtual_elimination_mode_set(1); @@ -594,7 +594,7 @@ static void getoptions(int argc, char *argv[]) { Printf(stdout, "%s\n", SwigLib); if (SwigLibWinUnix) Printf(stdout, "%s\n", SwigLibWinUnix); - SWIG_exit(EXIT_SUCCESS); + Exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-o") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { @@ -647,7 +647,7 @@ static void getoptions(int argc, char *argv[]) { #endif ); fprintf(stdout, "\nPlease see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT); - SWIG_exit(EXIT_SUCCESS); + Exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-copyright") == 0) { fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version()); fprintf(stdout, "Copyright (c) 1995-1998\n"); @@ -656,7 +656,7 @@ static void getoptions(int argc, char *argv[]) { fprintf(stdout, "University of Chicago\n"); fprintf(stdout, "Copyright (c) 2005-2006\n"); fprintf(stdout, "Arizona Board of Regents (University of Arizona)\n"); - SWIG_exit(EXIT_SUCCESS); + Exit(EXIT_SUCCESS); } else if (strncmp(argv[i], "-l", 2) == 0) { // Add a new directory search path Append(libfiles, argv[i] + 2); @@ -880,9 +880,14 @@ static void getoptions(int argc, char *argv[]) { } } +static void SWIG_exit_handler(int status); + int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { char *c; + /* Set function for Exit() to call. */ + SetExitHandler(SWIG_exit_handler); + /* Initialize the SWIG core */ Swig_init(); @@ -969,7 +974,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { if (help) { Printf(stdout, "\nNote: 'swig - -help' displays options for a specific target language.\n\n"); - SWIG_exit(EXIT_SUCCESS); // Exit if we're in help mode + Exit(EXIT_SUCCESS); // Exit if we're in help mode } // Check all of the options to make sure we're cool. @@ -978,7 +983,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { if (CPlusPlus && cparse_cplusplusout) { Printf(stderr, "The -c++out option is for C input but C++ input has been requested via -c++\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } install_opts(argc, argv); @@ -1043,7 +1048,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { File *f_outfile = NewFile(outfile, "w", SWIG_output_files()); if (!f_outfile) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } else { if (Verbose) Printf(stdout, "'%s' checked out from the SWIG library.\n", outfile); @@ -1071,7 +1076,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { } else { Printf(stderr, "Unable to find file '%s'.\n", input_file); } - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } else { Swig_warning(WARN_DEPRECATED_INPUT_FILE, "SWIG", 1, "Use of the include path to find the input file is deprecated and will not work with ccache. Please include the path when specifying the input file.\n"); // so that behaviour is like c/c++ compilers } @@ -1080,7 +1085,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { if (!tlm) { Printf(stderr, "No target language specified.\n"); Printf(stderr, "Use 'swig -help' for more information.\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } if (!no_cpp) { @@ -1104,11 +1109,11 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { fclose(df); } if (Swig_error_count()) { - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } if (cpp_only) { Printf(stdout, "%s", cpps); - SWIG_exit(EXIT_SUCCESS); + Exit(EXIT_SUCCESS); } if (depend) { if (!no_cpp) { @@ -1130,14 +1135,14 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { f_dependencies_file = NewFile(dependencies_file, "w", SWIG_output_files()); if (!f_dependencies_file) { FileErrorDisplay(dependencies_file); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } else if (!depend_only) { String *filename = NewStringf("%s_wrap.%s", basename, depends_extension); f_dependencies_file = NewFile(filename, "w", SWIG_output_files()); if (!f_dependencies_file) { FileErrorDisplay(filename); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } else f_dependencies_file = stdout; @@ -1170,14 +1175,14 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { if (f_dependencies_file != stdout) Delete(f_dependencies_file); if (depend_only) - SWIG_exit(EXIT_SUCCESS); + Exit(EXIT_SUCCESS); Delete(inputfile_filename); Delete(basename); Delete(phony_targets); } else { Printf(stderr, "Cannot generate dependencies with -nopreprocess\n"); // Actually we could but it would be inefficient when just generating dependencies, as it would be done after Swig_cparse - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } Seek(cpps, 0, SEEK_SET); @@ -1282,13 +1287,13 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { if (top) { if (!Getattr(top, "name")) { Printf(stderr, "No module name specified using %%module or -module.\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } else { /* Set some filename information on the object */ String *infile = scanner_get_main_input_file(); if (!infile) { Printf(stderr, "Missing input file in preprocessed output.\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Setattr(top, "infile", infile); // Note: if nopreprocess then infile is the original input file, otherwise input_file Setattr(top, "inputfile", input_file); @@ -1362,7 +1367,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { if (!f_outfiles) { Printf(stderr, "Failed to write list of output files to the filename '%s' specified in CCACHE_OUTFILES environment variable - ", outfiles); FileErrorDisplay(outfiles); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } else { int i; for (i = 0; i < Len(all_output_files); i++) @@ -1384,22 +1389,22 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { error_count += Swig_error_count(); if (error_count != 0) - SWIG_exit(error_count); + Exit(EXIT_FAILURE); return 0; } /* ----------------------------------------------------------------------------- - * SWIG_exit() + * SWIG_exit_handler() * * Cleanup and either freeze or exit * ----------------------------------------------------------------------------- */ -void SWIG_exit(int exit_code) { +static void SWIG_exit_handler(int status) { while (freeze) { } - if (exit_code > 0) { + if (status > 0) { CloseAllOpenFiles(); /* Remove all generated files */ @@ -1413,5 +1418,5 @@ void SWIG_exit(int exit_code) { } } - exit(exit_code); + exit(status); } diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx index 3ff691662..8080b93c0 100644 --- a/Source/Modules/mzscheme.cxx +++ b/Source/Modules/mzscheme.cxx @@ -66,7 +66,7 @@ public: if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); - SWIG_exit(0); + Exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-prefix") == 0) { if (argv[i + 1]) { prefix = NewString(argv[i + 1]); @@ -130,7 +130,7 @@ public: f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index a36912ab7..2938c1f3b 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -99,10 +99,10 @@ public: if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); - SWIG_exit(0); + Exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-where") == 0) { PrintIncludeArg(); - SWIG_exit(0); + Exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-prefix") == 0) { if (argv[i + 1]) { prefix = NewString(argv[i + 1]); @@ -228,7 +228,7 @@ public: f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); @@ -311,12 +311,12 @@ public: String *mlfilen = NewStringf("%s%s", SWIG_output_directory(), mlfile); if ((f_mlout = NewFile(mlfilen, "w", SWIG_output_files())) == 0) { FileErrorDisplay(mlfilen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } String *mlifilen = NewStringf("%s%s", SWIG_output_directory(), mlifile); if ((f_mliout = NewFile(mlifilen, "w", SWIG_output_files())) == 0) { FileErrorDisplay(mlifilen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } emitBanner(f_mlout); emitBanner(f_mliout); diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 04b315eaf..9e5bd17a1 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -119,7 +119,7 @@ public: } else if (strcmp(argv[i], "-nocppcast") == 0) { Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); Swig_mark_arg(i); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } } @@ -167,7 +167,7 @@ public: f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_runtime = NewString(""); f_header = NewString(""); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 459d403bf..1f6476b6b 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -154,11 +154,11 @@ public: if (strcmp(argv[i], "-package") == 0) { Printv(stderr, "*** -package is no longer supported\n*** use the directive '%module A::B::C' in your interface file instead\n*** see the Perl section in the manual for details.\n", NIL); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } else if (strcmp(argv[i], "-interface") == 0) { Printv(stderr, "*** -interface is no longer supported\n*** use the directive '%module A::B::C' in your interface file instead\n*** see the Perl section in the manual for details.\n", NIL); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } else if (strcmp(argv[i], "-exportall") == 0) { export_all = 1; Swig_mark_arg(i); @@ -197,7 +197,7 @@ public: } else if (strcmp(argv[i], "-nocppcast") == 0) { Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); Swig_mark_arg(i); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } } @@ -276,7 +276,7 @@ public: f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); @@ -289,7 +289,7 @@ public: f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } @@ -407,7 +407,7 @@ public: String *filen = NewStringf("%s%s", SWIG_output_directory(), pmfile); if ((f_pm = NewFile(filen, "w", SWIG_output_files())) == 0) { FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Delete(filen); filen = NULL; diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 6862c214b..8d937e9b2 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -342,7 +342,7 @@ public: f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_runtime = NewStringEmpty(); @@ -366,7 +366,7 @@ public: f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); if (!f_runtime_h) { FileErrorDisplay(outfile_h); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } @@ -438,7 +438,7 @@ public: f_h = NewFile(filen, "w", SWIG_output_files()); if (!f_h) { FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Swig_banner(f_h); @@ -651,7 +651,7 @@ public: File *f_phpcode = NewFile(php_filename, "w", SWIG_output_files()); if (!f_phpcode) { FileErrorDisplay(php_filename); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } Printf(f_phpcode, "name, language_module->help); else Printf(stderr, "Target language option %s is no longer supported.\n", language_module->name); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } else if ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "--help") == 0)) { if (strcmp(argv[i], "--help") == 0) diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index d90d1d3b1..641dfc866 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -113,7 +113,7 @@ public: } else if (strcmp(argv[i], "-nocppcast") == 0) { Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); Swig_mark_arg(i); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } } @@ -138,7 +138,7 @@ public: f_begin = NewFile(outfile, "w", SWIG_output_files()); if (!f_begin) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_runtime = NewString(""); f_init = NewString(""); @@ -182,7 +182,7 @@ public: if ((f_shadow = NewFile(filen, "w", SWIG_output_files())) == 0) { FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } f_shadow_stubs = NewString(""); diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index d1a16b53a..d3f8dc196 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -969,7 +969,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); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } String *decl = Strcmp(nodeType(c), "using") == 0 ? NewString("------") : Getattr(c, "decl"); @@ -977,7 +977,7 @@ class TypePass:private Dispatcher { if (!Getattr(c, "sym:overloaded")) { Printf(stdout, "sym:overloaded error.....%p\n", c); Swig_print_node(c); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } c = Getattr(c, "sym:nextSibling"); } diff --git a/Source/Modules/xml.cxx b/Source/Modules/xml.cxx index 5f090561a..a4e2ed416 100644 --- a/Source/Modules/xml.cxx +++ b/Source/Modules/xml.cxx @@ -52,7 +52,7 @@ public: out = NewFile(outfile, "w", SWIG_output_files()); if (!out) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } continue; } @@ -89,7 +89,7 @@ public: out = NewFile(outfile, "w", SWIG_output_files()); if (!out) { FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } Printf(out, " \n"); @@ -310,7 +310,7 @@ void Swig_print_xml(DOH *obj, String *filename) { out = NewFile(filename, "w", SWIG_output_files()); if (!out) { FileErrorDisplay(filename); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } diff --git a/Source/Swig/getopt.c b/Source/Swig/getopt.c index 05edf6eed..9b4319cd9 100644 --- a/Source/Swig/getopt.c +++ b/Source/Swig/getopt.c @@ -83,11 +83,11 @@ void Swig_check_options(int check_input) { } if (error) { Printf(stderr, "Use 'swig -help' for available options.\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } if (check_input && marked[numargs - 1]) { Printf(stderr, "Must specify an input file. Use -help for available options.\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } @@ -100,5 +100,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"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 1b8a8f63d..0519b57c9 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -1162,7 +1162,7 @@ int Swig_scopename_check(const String *s) { String *Swig_string_command(String *s) { Swig_error("SWIG", Getline(s), "Command encoder no longer supported - use regex encoder instead.\n"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); return 0; } @@ -1309,7 +1309,7 @@ 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); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); return 0; } @@ -1435,7 +1435,7 @@ String *Swig_string_regex(String *s) { pcre2_get_error_message (pcre_errornum, pcre_error, sizeof pcre_error); Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n", pcre_error, Char(pattern), pcre_errorpos); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } match_data = pcre2_match_data_create_from_pattern (compiled_pat, NULL); rc = pcre2_match(compiled_pat, (PCRE2_SPTR8)input, PCRE2_ZERO_TERMINATED, 0, 0, match_data, NULL); @@ -1445,7 +1445,7 @@ String *Swig_string_regex(String *s) { } else if (rc != PCRE2_ERROR_NOMATCH) { Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" using \"%s\".\n", rc, Char(pattern), input); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } } @@ -1470,7 +1470,7 @@ 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"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); return 0; } diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index c9456637b..1599941b7 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1108,7 +1108,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); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } pcre2_match_data *match_data = 0; @@ -1124,7 +1124,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); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } return 1; @@ -1137,7 +1137,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"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); return 0; } diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 39d2c39a3..65f534a79 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"); - SWIG_exit(EXIT_FAILURE); + Exit(EXIT_FAILURE); } else { retract(s, 1); return SWIG_TOKEN_PERCENT; diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 76691269e..e9689afd9 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -439,8 +439,6 @@ 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 -- */ extern void SwigType_template_init(void);