From be27e7d0f0934a1741c360ecfac989ff6ea607a0 Mon Sep 17 00:00:00 2001 From: Magnus Jacobsson Date: Sun, 16 Jan 2022 16:46:41 +0100 Subject: [PATCH] replace all instances of exit() with graphviz_exit() Partial fix for https://gitlab.com/graphviz/graphviz/-/issues/2178. --- cmd/dot/dot.c | 5 +++-- cmd/dotty/mswin32/dotty.c | 10 ++++++---- cmd/edgepaint/edgepaintmain.c | 5 +++-- cmd/gvmap/cluster.c | 4 ++-- cmd/gvmap/gvmap.c | 4 ++-- cmd/lefty/gfxview.c | 3 ++- cmd/lefty/lefty.c | 7 ++++--- cmd/lefty/ws/gtk/gview.c | 5 +++-- cmd/lefty/ws/mswin32/gcommon.c | 12 +++++++----- cmd/lefty/ws/x11/gview.c | 5 +++-- cmd/lneato/mswin32/lneato.c | 10 ++++++---- cmd/smyrna/gltemplate.c | 3 ++- cmd/smyrna/glutrender.c | 6 ++++-- cmd/smyrna/main.c | 5 +++-- cmd/smyrna/viewport.c | 9 +++++---- cmd/tools/acyclic.c | 10 ++++++---- cmd/tools/bcomps.c | 5 +++-- cmd/tools/ccomps.c | 9 +++++---- cmd/tools/cvtgxl.c | 13 +++++++------ cmd/tools/dijkstra.c | 5 +++-- cmd/tools/gc.c | 10 ++++++---- cmd/tools/gml2gv.c | 8 +++++--- cmd/tools/graphml2gv.c | 17 +++++++++-------- cmd/tools/gv2gml.c | 9 +++++---- cmd/tools/gvcolor.c | 9 +++++---- cmd/tools/gvgen.c | 8 +++++--- cmd/tools/gvpack.c | 17 +++++++++-------- cmd/tools/gxl2gv.c | 15 ++++++++------- cmd/tools/mm2gv.c | 6 +++--- cmd/tools/nop.c | 5 +++-- cmd/tools/sccmap.c | 5 +++-- cmd/tools/tred.c | 7 ++++--- cmd/tools/unflatten.c | 5 +++-- contrib/diffimg/diffimg.c | 22 ++++++++++++---------- contrib/prune/prune.c | 25 +++++++++++++------------ doc/libgraph/sccmap.c | 5 +++-- lib/ast/error.c | 3 ++- lib/cgraph/sprint.c | 3 ++- lib/common/input.c | 13 +++++++------ lib/common/memory.c | 9 +++++---- lib/common/xml.c | 3 ++- lib/dotgen/mincross.c | 3 ++- lib/expr/excc.c | 3 ++- lib/expr/exerror.c | 3 ++- lib/expr/exeval.c | 5 +++-- lib/fdpgen/dbg.c | 3 ++- lib/gvc/gvconfig.c | 3 ++- lib/gvc/gvdevice.c | 19 ++++++++++--------- lib/gvpr/compile.c | 3 ++- lib/gvpr/gvpr.c | 3 ++- lib/label/nrtmain.c | 13 +++++++------ lib/neatogen/legal.c | 3 ++- lib/ortho/ortho.c | 3 ++- lib/sfdpgen/post_process.c | 5 +++-- lib/sparse/DotIO.c | 2 +- lib/sparse/SparseMatrix.c | 2 +- lib/sparse/general.h | 1 + plugin/glitz/gvdevice_glitz.c | 3 ++- plugin/xlib/gvdevice_xlib.c | 3 ++- rtest/cdiff.c | 8 +++++--- tclpkg/tclpathplan/find_ints.c | 4 +++- tclpkg/tclpathplan/intersect.c | 3 ++- 62 files changed, 251 insertions(+), 183 deletions(-) diff --git a/cmd/dot/dot.c b/cmd/dot/dot.c index 030c23085..6781f1cf5 100644 --- a/cmd/dot/dot.c +++ b/cmd/dot/dot.c @@ -15,6 +15,7 @@ #include "config.h" #include +#include #include #include @@ -40,7 +41,7 @@ static void intr(int s) gvRenderJobs(Gvc, G); /* Note that we don't call gvFinalize() so that we don't start event-driven * devices like -Tgtk or -Txlib */ - exit (gvFreeContext(Gvc)); + graphviz_exit(gvFreeContext(Gvc)); } #ifndef NO_FPERR @@ -48,7 +49,7 @@ static void fperr(int s) { fprintf(stderr, "caught SIGFPE %d\n", s); /* signal (s, SIG_DFL); raise (s); */ - exit(1); + graphviz_exit(1); } #endif #endif diff --git a/cmd/dotty/mswin32/dotty.c b/cmd/dotty/mswin32/dotty.c index fec5799fa..0366885fb 100644 --- a/cmd/dotty/mswin32/dotty.c +++ b/cmd/dotty/mswin32/dotty.c @@ -19,6 +19,8 @@ #include #include +#include + static char *shellpath; static char *buildpath (char *); @@ -50,16 +52,16 @@ int APIENTRY WinMain ( if (!shellpath || !(path = buildpath ("lefty"))) { if (!GetModuleFileName (hInstance, cmd, 256) || !(s = strrchr (cmd, '\\'))) - exit (1); + graphviz_exit(1); *s = 0; shellpath = &cmd[0]; if (!(path = buildpath ("lefty"))) - exit (1); + graphviz_exit(1); } argv = CommandLineToArgvW(lpCmdLine, &argc); if (argc == 1 && strcmp(argv[0], "-?") == 0) { fprintf(stderr, "usage: dotty [-V] [-lm (sync|async)] [-el (0|1)] \n"); - exit(0); + graphviz_exit(0); } if (lpCmdLine[0] == 0) snprintf(cmd, sizeof(cmd), "%s -e \"load('dotty.lefty');%sdotty.init();" @@ -82,7 +84,7 @@ int APIENTRY WinMain ( &si, // Pointer to STARTUPINFO structure. &pi // Pointer to PROCESS_INFORMATION structure. ); - exit (0); + graphviz_exit(0); } #define PATHDEL '\\' diff --git a/cmd/edgepaint/edgepaintmain.c b/cmd/edgepaint/edgepaintmain.c index 279052fe7..c6fa23065 100644 --- a/cmd/edgepaint/edgepaintmain.c +++ b/cmd/edgepaint/edgepaintmain.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -50,7 +51,7 @@ static FILE *openFile(const char *name, const char* cmd) fp = fopen(name, "w"); if (!fp) { fprintf(stderr, "%s: could not open file %s for writing\n", cmd, name); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } return fp; } @@ -70,7 +71,7 @@ static void usage (char* cmd, int eval){ fprintf(stderr, " parallel but is on the opposite ends of the shared point (around 180 degree).\n"); fprintf(stderr, " -v : verbose\n"); fprintf(stderr, " -o fname : write output to file fname (stdout)\n"); - exit(eval); + graphviz_exit(eval); } /* checkG: diff --git a/cmd/gvmap/cluster.c b/cmd/gvmap/cluster.c index dd1f519f9..f9573d29a 100644 --- a/cmd/gvmap/cluster.c +++ b/cmd/gvmap/cluster.c @@ -61,7 +61,7 @@ static void usage(char* cmd, int eval) { fprintf(stderr, "Usage: %s graphfile\n", cmd); fputs (usestr, stderr); - exit(eval); + graphviz_exit(eval); } static FILE *openFile(const char *name, const char* cmd) @@ -71,7 +71,7 @@ static FILE *openFile(const char *name, const char* cmd) fp = fopen(name, "w"); if (!fp) { fprintf(stderr, "%s: could not open file %s for writing\n", cmd, name); - exit(-1); + graphviz_exit(-1); } return fp; } diff --git a/cmd/gvmap/gvmap.c b/cmd/gvmap/gvmap.c index 1cf66ff6b..f206ff0d2 100644 --- a/cmd/gvmap/gvmap.c +++ b/cmd/gvmap/gvmap.c @@ -125,7 +125,7 @@ static void usage(char* cmd, int eval) { fprintf(stderr, "Usage: %s graphfile\n", cmd); fputs (usestr, stderr); - exit(eval); + graphviz_exit(eval); } static FILE *openFile(const char *name, const char* cmd) @@ -135,7 +135,7 @@ static FILE *openFile(const char *name, const char* cmd) fp = fopen(name, "w"); if (!fp) { fprintf(stderr, "%s: could not open file %s for writing\n", cmd, name); - exit(-1); + graphviz_exit(-1); } return (fp); } diff --git a/cmd/lefty/gfxview.c b/cmd/lefty/gfxview.c index 932e70a89..eaef13046 100644 --- a/cmd/lefty/gfxview.c +++ b/cmd/lefty/gfxview.c @@ -10,6 +10,7 @@ /* Lefteris Koutsofios - AT&T Labs Research */ +#include #include "common.h" #include "g.h" #include "mem.h" @@ -234,7 +235,7 @@ void GFXviewcb (Gevent_t *evp) { fn = "closeview"; if (!wo || !(fo = Tfinds (wo, fn)) || Tgettype (fo) != T_CODE) if (!(fo = Tfinds (root, fn)) || Tgettype (fo) != T_CODE) - exit (0); + graphviz_exit(0); fm = Mpushmark (fo); to = Ttable (2); Mpushmark (to); diff --git a/cmd/lefty/lefty.c b/cmd/lefty/lefty.c index a1a6cc69e..56d8d551e 100644 --- a/cmd/lefty/lefty.c +++ b/cmd/lefty/lefty.c @@ -15,6 +15,7 @@ #define LEFTYVERSION "10 Mar 2005" #include "builddate.h" +#include #include "common.h" #include "g.h" #include "code.h" @@ -304,7 +305,7 @@ eop: term (); #endif printusage (); - exit (0); + graphviz_exit(0); } #endif @@ -409,7 +410,7 @@ static void usage(int eval) { fprintf (stderr, "Usage: lefty [options] [file]\n"); fputs (usestr, stderr); - exit (eval); + graphviz_exit(eval); } static void processstr (char *buf) { @@ -475,7 +476,7 @@ static void processargs (int argc, char *argv[]) { fclose(fp); if ((fp = fopen (argv[0], "r")) == NULL) { fprintf (stderr, "cannot open input file: %s\n", argv[0]); - exit(2); + graphviz_exit(2); } } argv++, argc--; diff --git a/cmd/lefty/ws/gtk/gview.c b/cmd/lefty/ws/gtk/gview.c index 514494ff0..f0ea35ce4 100644 --- a/cmd/lefty/ws/gtk/gview.c +++ b/cmd/lefty/ws/gtk/gview.c @@ -9,6 +9,7 @@ *************************************************************************/ +#include #include "common.h" #include "g.h" #include "gcommon.h" @@ -182,12 +183,12 @@ void Gwmdelaction(GtkWidget * w, GdkEvent * evp, char **app, widget = findwidget((unsigned long) w, G_VIEWWIDGET); if (!widget) - exit(0); + graphviz_exit(0); gev.type = 0, gev.code = 0, gev.data = 0; gev.wi = widget - &Gwidgets[0]; if (WVU->func) (*WVU->func) (&gev); else - exit(0); + graphviz_exit(0); } diff --git a/cmd/lefty/ws/mswin32/gcommon.c b/cmd/lefty/ws/mswin32/gcommon.c index bfbde0845..e63ccf0dd 100644 --- a/cmd/lefty/ws/mswin32/gcommon.c +++ b/cmd/lefty/ws/mswin32/gcommon.c @@ -11,6 +11,8 @@ /* Lefteris Koutsofios - AT&T Labs Research */ #include + +#include #include "common.h" #include "g.h" #include "gcommon.h" @@ -188,7 +190,7 @@ int Gprocessevents (int waitflag, int mode) { switch (waitflag) { case TRUE: if (!GetMessage(&msg, (HWND) NULL, (UINT) NULL, (UINT) NULL)) - exit (msg.wParam); + graphviz_exit(msg.wParam); TranslateMessage(&msg); DispatchMessage(&msg); if (mode == G_ONEEVENT) @@ -198,7 +200,7 @@ int Gprocessevents (int waitflag, int mode) { case FALSE: while (PeekMessage(&msg, (HWND) 0, (UINT) 0, (UINT) 0, PM_REMOVE)) { if (msg.message == WM_QUIT) - exit (msg.wParam); + graphviz_exit(msg.wParam); TranslateMessage(&msg); DispatchMessage(&msg); if (mode == G_ONEEVENT) @@ -233,17 +235,17 @@ LRESULT CALLBACK LeftyWndProc ( break; case WM_CLOSE: if (!widget) - exit (0); + graphviz_exit(0); if (WVU->closing) DestroyWindow (hwnd); if (Gnocallbacks) - exit (0); + graphviz_exit(0); gev.type = 0, gev.code = 0, gev.data = 0; gev.wi = widget - &Gwidgets[0]; if (WVU->func) (*WVU->func) (&gev); else - exit (0); + graphviz_exit(0); break; case WM_PALETTECHANGED: palettechanged = (HWND) wparam; diff --git a/cmd/lefty/ws/x11/gview.c b/cmd/lefty/ws/x11/gview.c index 7725d904a..acec8237f 100644 --- a/cmd/lefty/ws/x11/gview.c +++ b/cmd/lefty/ws/x11/gview.c @@ -10,6 +10,7 @@ /* Lefteris Koutsofios - AT&T Labs Research */ +#include #include "common.h" #include "g.h" #include "gcommon.h" @@ -234,11 +235,11 @@ void Gwmdelaction (Widget w, XEvent *evp, char **app, unsigned int *anp) { widget = findwidget ((unsigned long) w, G_VIEWWIDGET); if (!widget) - exit (0); + graphviz_exit(0); gev.type = 0, gev.code = 0, gev.data = 0; gev.wi = widget - &Gwidgets[0]; if (WVU->func) (*WVU->func) (&gev); else - exit (0); + graphviz_exit(0); } diff --git a/cmd/lneato/mswin32/lneato.c b/cmd/lneato/mswin32/lneato.c index 25f0e046b..2e222455e 100644 --- a/cmd/lneato/mswin32/lneato.c +++ b/cmd/lneato/mswin32/lneato.c @@ -19,6 +19,8 @@ #include #include +#include + static char *shellpath; static char *buildpath (char *); @@ -37,16 +39,16 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, if (!shellpath || !(path = buildpath ("lefty"))) { if (!GetModuleFileName (hInstance, cmd, 256) || !(s = strrchr (cmd, '\\'))) - exit (1); + graphviz_exit(1); *s = 0; shellpath = &cmd[0]; if (!(path = buildpath ("lefty"))) - exit (1); + graphviz_exit(1); } argv = CommandLineToArgvW(pCmdLine, &argc); if (argc == 1 && wcscmp(argv[0], L"-?") == 0) { fprintf(stderr, "usage: lneato [-V] [-lm (sync|async)] [-el (0|1)] \n"); - exit(0); + graphviz_exit(0); } if (pCmdLine[0] == 0) snprintf(cmd, sizeof(cmd), "%s -e \"load('dotty.lefty');" @@ -57,7 +59,7 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, pCmdLine); handle = WinExec (cmd, SW_SHOW); - exit (0); + graphviz_exit(0); } #define PATHDEL '\\' diff --git a/cmd/smyrna/gltemplate.c b/cmd/smyrna/gltemplate.c index a7fa339dc..90108092d 100644 --- a/cmd/smyrna/gltemplate.c +++ b/cmd/smyrna/gltemplate.c @@ -13,6 +13,7 @@ #include "gui.h" #include "viewport.h" #include "gltemplate.h" +#include #include #include "glexpose.h" #include "glmotion.h" @@ -427,7 +428,7 @@ GdkGLConfig *configure_gl(void) GDK_GL_MODE_DEPTH); if (glconfig == NULL) { g_print("*** No appropriate OpenGL-capable visual found.\n"); - exit(1); + graphviz_exit(1); } } diff --git a/cmd/smyrna/glutrender.c b/cmd/smyrna/glutrender.c index 300bee3ed..66c423b37 100644 --- a/cmd/smyrna/glutrender.c +++ b/cmd/smyrna/glutrender.c @@ -8,6 +8,8 @@ * Contributors: Details at https://graphviz.org *************************************************************************/ +#include + #include "glutrender.h" #include "viewport.h" #include "arcball.h" @@ -153,7 +155,7 @@ static void cb_drag(int X, int Y) static void cb_keyboard(unsigned char key, int x, int y) { if (key==27) /*ESC*/ - exit (1); + graphviz_exit(1); if(key=='3') switch2D3D(NULL, 0, 0,glMouseLeftButton); if(key=='c') @@ -210,7 +212,7 @@ static int cb_game_mode(char* optArg) else { printf("smyrna cannot initialize requested screen resolution and rate!\n"); - exit(-1); + graphviz_exit(-1); } diff --git a/cmd/smyrna/main.c b/cmd/smyrna/main.c index b85f8f012..600838698 100644 --- a/cmd/smyrna/main.c +++ b/cmd/smyrna/main.c @@ -25,6 +25,7 @@ #include "support.h" #include "menucallbacks.h" #include "gltemplate.h" +#include #include #include "gvprpipe.h" #include "frmobjectui.h" @@ -79,7 +80,7 @@ static char *useString = "Usage: smyrna [-v?] \n\ static void usage(int v) { fputs(useString, stdout); - exit(v); + graphviz_exit(v); } static char *Info[] = { @@ -108,7 +109,7 @@ static char *parseArgs(int argc, char *argv[], ViewInfo * view) case 'V': fprintf(stderr, "%s version %s (%s)\n", Info[0], Info[1], Info[2]); - exit (0); + graphviz_exit(0); break; case '?': if (optopt == '\0') diff --git a/cmd/smyrna/viewport.c b/cmd/smyrna/viewport.c index ae246171a..065b33dad 100644 --- a/cmd/smyrna/viewport.c +++ b/cmd/smyrna/viewport.c @@ -30,6 +30,7 @@ #include "arcball.h" #include "hotkeymap.h" #include "topviewfuncs.h" +#include #include @@ -267,7 +268,7 @@ void init_viewport(ViewInfo * view) fprintf(stderr, "default attributes template graph file \"%s\" not found\n", view->template_file); - exit(-1); + graphviz_exit(-1); } view->systemGraphs.def_attrs = agread(input_file, NULL); fclose (input_file); @@ -276,21 +277,21 @@ void init_viewport(ViewInfo * view) fprintf(stderr, "could not load default attributes template graph file \"%s\"\n", view->template_file); - exit(-1); + graphviz_exit(-1); } if (!path) path = smyrnaPath("attr_widgets.dot"); input_file2 = fopen(path, "rb"); if (!input_file2) { fprintf(stderr, "default attributes template graph file \"%s\" not found\n",smyrnaPath("attr_widgets.dot")); - exit(-1); + graphviz_exit(-1); } view->systemGraphs.attrs_widgets = agread(input_file2, NULL); fclose (input_file2); if (!(view->systemGraphs.attrs_widgets )) { fprintf(stderr,"could not load default attribute widgets graph file \"%s\"\n",smyrnaPath("attr_widgets.dot")); - exit(-1); + graphviz_exit(-1); } //init graphs view->g = NULL; //no graph, gl screen should check it diff --git a/cmd/tools/acyclic.c b/cmd/tools/acyclic.c index 903804bf9..a38933add 100644 --- a/cmd/tools/acyclic.c +++ b/cmd/tools/acyclic.c @@ -24,6 +24,8 @@ #include #include +#include + typedef struct { Agrec_t h; int mark; @@ -106,7 +108,7 @@ static char *useString = "Usage: %s [-nv?] [-o outfile] \n\ static void usage(int v) { fprintf(stderr, useString, cmd); - exit(v); + graphviz_exit(v); } static FILE *openFile(const char *name, const char *mode) @@ -122,7 +124,7 @@ static FILE *openFile(const char *name, const char *mode) modestr = "writing"; fprintf(stderr, "%s: could not open file %s for %s\n", cmd, name, modestr); - exit(-1); + graphviz_exit(-1); } return (fp); } @@ -200,7 +202,7 @@ int main(int argc, char *argv[]) if (Verbose) fprintf(stderr, "Graph \"%s\" is undirected\n", graphName(g)); } - exit(rv); + graphviz_exit(rv); } else - exit(-1); + graphviz_exit(-1); } diff --git a/cmd/tools/bcomps.c b/cmd/tools/bcomps.c index 857959c5d..bab9b6c4a 100644 --- a/cmd/tools/bcomps.c +++ b/cmd/tools/bcomps.c @@ -24,6 +24,7 @@ #include #include +#include typedef struct { Agrec_t h; @@ -153,7 +154,7 @@ static void gwrite(Agraph_t * g, int ng, int nb) if (!outf) { fprintf(stderr, "Could not open %s for writing\n", name); perror("bcomps"); - exit(1); + graphviz_exit(1); } agwrite(g, outf); fclose(outf); @@ -305,7 +306,7 @@ If no files are specified, stdin is used\n"; static void usage(int v) { printf("%s",useString); - exit(v); + graphviz_exit(v); } static void split(char *name) diff --git a/cmd/tools/ccomps.c b/cmd/tools/ccomps.c index 80a9a4ff7..014385874 100644 --- a/cmd/tools/ccomps.c +++ b/cmd/tools/ccomps.c @@ -23,12 +23,13 @@ #include #include #include +#include static void *xmalloc(size_t size) { void *p = malloc(size); if (UNLIKELY(size > 0 && p == NULL)) { fprintf(stderr, "ccomps: out of memory\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } return p; } @@ -37,7 +38,7 @@ static void *xcalloc(size_t count, size_t size) { void *p = calloc(count, size); if (UNLIKELY(count > 0 && size > 0 && p == NULL)) { fprintf(stderr, "ccomps: out of memory\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } return p; } @@ -46,7 +47,7 @@ static void *xrealloc(void *ptr, size_t size) { void *p = realloc(ptr, size); if (UNLIKELY(size > 0 && p == NULL)) { fprintf(stderr, "ccomps: out of memory\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } return p; } @@ -129,7 +130,7 @@ If no files are specified, stdin is used\n"; static void usage(int v) { printf("%s",useString); - exit(v); + graphviz_exit(v); } static void split(char *name) diff --git a/cmd/tools/cvtgxl.c b/cmd/tools/cvtgxl.c index 06598eceb..1fea650d5 100644 --- a/cmd/tools/cvtgxl.c +++ b/cmd/tools/cvtgxl.c @@ -21,6 +21,7 @@ #include #include "convert.h" +#include #include typedef enum { Unset, ToGV, ToGXL } mode; @@ -64,7 +65,7 @@ static FILE *openFile(const char *name) if (!fp) { fprintf(stderr, "%s: could not open file %s for writing\n", CmdName, name); perror(name); - exit(1); + graphviz_exit(1); } return fp; } @@ -78,7 +79,7 @@ static const char *use = "Usage: %s [-gd?] [-o] []\n\ static void usage(int v) { fprintf(stderr, use, CmdName); - exit(v); + graphviz_exit(v); } static char *cmdName(char *path) @@ -156,12 +157,12 @@ static void initargs(int argc, char **argv) else { fprintf(stderr, "%s: option -%c unrecognized\n", CmdName, optopt); - exit(1); + graphviz_exit(1); } break; default: fprintf(stderr, "cvtgxl: unexpected error\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } } @@ -213,9 +214,9 @@ int main(int argc, char **argv) #else fputs("cvtgxl: not configured for conversion from GXL to GV\n", stderr); - exit(1); + graphviz_exit(1); #endif } - exit(0); + graphviz_exit(0); } diff --git a/cmd/tools/dijkstra.c b/cmd/tools/dijkstra.c index fe63cfc2b..3da01a16c 100644 --- a/cmd/tools/dijkstra.c +++ b/cmd/tools/dijkstra.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -225,7 +226,7 @@ If no files are specified, stdin is used\n"; static void usage(int v) { printf("%s",useString); - exit(v); + graphviz_exit(v); } static void init(int argc, char *argv[]) @@ -307,5 +308,5 @@ int main(int argc, char **argv) } free(Nodes); free(Files); - exit(code); + graphviz_exit(code); } diff --git a/cmd/tools/gc.c b/cmd/tools/gc.c index 792fb4ae5..2c9e6594e 100644 --- a/cmd/tools/gc.c +++ b/cmd/tools/gc.c @@ -27,6 +27,8 @@ #include #include +#include + typedef struct { Agrec_t h; int dfs_mark; @@ -79,7 +81,7 @@ If no files are specified, stdin is used\n"; static void usage(int v) { printf("%s",useString); - exit(v); + graphviz_exit(v); } static void init(int argc, char *argv[]) @@ -131,7 +133,7 @@ static void init(int argc, char *argv[]) break; default: fprintf(stderr, "gc: unexpected error\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } } argv += optind; @@ -182,14 +184,14 @@ static void push(Agnode_t * np) blk_t *bp = NEW(blk_t); if (bp == 0) { fprintf(stderr, "gc: Out of memory\n"); - exit(1); + graphviz_exit(1); } bp->prev = Stk.curblk; bp->next = NULL; bp->data = N_NEW(BIGBUF, Agnode_t *); if (bp->data == 0) { fprintf(stderr, "gc: Out of memory\n"); - exit(1); + graphviz_exit(1); } bp->endp = bp->data + BIGBUF; Stk.curblk->next = bp; diff --git a/cmd/tools/gml2gv.c b/cmd/tools/gml2gv.c index 3ee0c4065..14d30cb42 100644 --- a/cmd/tools/gml2gv.c +++ b/cmd/tools/gml2gv.c @@ -19,6 +19,8 @@ #include +#include + #define N_NEW(n,t) calloc((n),sizeof(t)) static int Verbose; @@ -60,7 +62,7 @@ static FILE *openFile(const char *name) fprintf(stderr, "%s: could not open file %s for writing\n", CmdName, name); perror(name); - exit(1); + graphviz_exit(1); } return fp; } @@ -76,7 +78,7 @@ If no files are specified, stdin is used\n"; static void usage(int v) { printf(useString, CmdName); - exit(v); + graphviz_exit(v); } static char *cmdName(char *path) @@ -176,6 +178,6 @@ int main(int argc, char **argv) fflush(outFile); } } - exit(rv); + graphviz_exit(rv); } diff --git a/cmd/tools/graphml2gv.c b/cmd/tools/graphml2gv.c index a0505a7e3..dfbc4ee36 100644 --- a/cmd/tools/graphml2gv.c +++ b/cmd/tools/graphml2gv.c @@ -11,6 +11,7 @@ #include "convert.h" #include +#include #include #ifdef HAVE_EXPAT #include @@ -71,7 +72,7 @@ static void popString(slist ** stk) slist *sp = *stk; if (!sp) { fprintf(stderr, "PANIC: graphml2gv: empty element stack\n"); - exit(1); + graphviz_exit(1); } *stk = sp->next; free(sp); @@ -81,7 +82,7 @@ static char *topString(slist * stk) { if (!stk) { fprintf(stderr, "PANIC: graphml2gv: empty element stack\n"); - exit(1); + graphviz_exit(1); } return stk->buf; } @@ -209,7 +210,7 @@ static void push_subg(Agraph_t * g) if (GSP == STACK_DEPTH) { fprintf(stderr, "graphml2gv: Too many (> %d) nestings of subgraphs\n", STACK_DEPTH); - exit(1); + graphviz_exit(1); } else if (GSP == 0) root = g; G = Gstack[GSP++] = g; @@ -220,7 +221,7 @@ static Agraph_t *pop_subg(void) Agraph_t *g; if (GSP == 0) { fprintf(stderr, "graphml2gv: Gstack underflow in graph parser\n"); - exit(1); + graphviz_exit(1); } g = Gstack[--GSP]; if (GSP > 0) @@ -665,7 +666,7 @@ static FILE *openFile(const char *name) if (!fp) { fprintf(stderr, "%s: could not open file %s for writing\n", CmdName, name); perror(name); - exit(1); + graphviz_exit(1); } return fp; } @@ -679,7 +680,7 @@ static const char *use = "Usage: %s [-gd?] [-o] []\n\ static void usage(int v) { fprintf(stderr, use, CmdName); - exit(v); + graphviz_exit(v); } static char *cmdName(char *path) @@ -778,9 +779,9 @@ int main(int argc, char **argv) fflush(outFile); } } - exit(rv); + graphviz_exit(rv); #else fputs("cvtgxl: not configured for conversion from GXL to GV\n", stderr); - exit(1); + graphviz_exit(1); #endif } diff --git a/cmd/tools/gv2gml.c b/cmd/tools/gv2gml.c index c490087e4..a3bf85abf 100644 --- a/cmd/tools/gv2gml.c +++ b/cmd/tools/gv2gml.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -190,7 +191,7 @@ arrowEnd (char* s0, char* pfx, int* fp, double* xp, double* yp) s = readPoint (s, xp, yp); if (s == NULL) { fprintf (stderr, "Illegal spline end: %s\n", s0); - exit (1); + graphviz_exit(1); } *fp = 1; return s; @@ -673,7 +674,7 @@ static FILE *openFile(const char *name) fprintf(stderr, "%s: could not open file %s for writing\n", CmdName, name); perror(name); - exit(1); + graphviz_exit(1); } return fp; } @@ -687,7 +688,7 @@ If no files are specified, stdin is used\n"; static void usage(int v) { printf(useString, CmdName); - exit(v); + graphviz_exit(v); } static char *cmdName(char *cmd) @@ -765,5 +766,5 @@ int main(int argc, char **argv) gv_to_gml(G, outFile); fflush(outFile); } - exit(rv); + graphviz_exit(rv); } diff --git a/cmd/tools/gvcolor.c b/cmd/tools/gvcolor.c index 771300f6f..5e1e1e696 100644 --- a/cmd/tools/gvcolor.c +++ b/cmd/tools/gvcolor.c @@ -21,6 +21,7 @@ #include #include +#include #include typedef struct Agnodeinfo_t { Agrec_t h; @@ -78,7 +79,7 @@ If no files are specified, stdin is used\n"; static void usage(int v) { printf("%s",useString); - exit(v); + graphviz_exit(v); } static void init(int argc, char *argv[]) @@ -99,7 +100,7 @@ static void init(int argc, char *argv[]) break; default: fprintf(stderr, "gvcolor: unexpected error\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } } argv += optind; @@ -121,7 +122,7 @@ static void color(Agraph_t * g) if (agattr(g, AGNODE, "pos", 0) == NULL) { fprintf(stderr, "graph must be run through 'dot' before 'gvcolor'\n"); - exit(1); + graphviz_exit(1); } aginit(g, AGNODE, "nodeinfo", sizeof(Agnodeinfo_t), TRUE); if (agattr(g, AGNODE, "style", 0) == NULL) @@ -253,5 +254,5 @@ int main(int argc, char **argv) agclose(g); } - exit(0); + graphviz_exit(0); } diff --git a/cmd/tools/gvgen.c b/cmd/tools/gvgen.c index 74ef9302a..ced1e935c 100644 --- a/cmd/tools/gvgen.c +++ b/cmd/tools/gvgen.c @@ -25,6 +25,8 @@ #include #include "graph_generator.h" +#include + typedef enum { unknown, grid, circle, complete, completeb, path, tree, torus, cylinder, mobius, randomg, randomt, ball, sierpinski, hypercube, star, wheel, trimesh @@ -54,7 +56,7 @@ static FILE *openFile(const char *name) fp = fopen(name, "w"); if (!fp) { fprintf(stderr, "%s: could not open file %s for writing\n", cmd, name); - exit(1); + graphviz_exit(1); } return fp; } @@ -92,7 +94,7 @@ static char *Usage = "Usage: %s [-dv?] [options]\n\ static void usage(int v) { fprintf(v ? stderr : stdout, Usage, cmd); - exit(v); + graphviz_exit(v); } static void errexit(int opt) { @@ -543,5 +545,5 @@ int main(int argc, char *argv[]) } fprintf(opts.outfile, "}\n"); - exit(0); + graphviz_exit(0); } diff --git a/cmd/tools/gvpack.c b/cmd/tools/gvpack.c index 5ee21a08a..ac8a54c93 100644 --- a/cmd/tools/gvpack.c +++ b/cmd/tools/gvpack.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -94,7 +95,7 @@ If no files are specified, stdin is used\n"; static void usage(int v) { printf("%s",useString); - exit(v); + graphviz_exit(v); } static FILE *openFile(const char *name) @@ -104,7 +105,7 @@ static FILE *openFile(const char *name) fp = fopen(name, "w"); if (!fp) { fprintf(stderr, "gvpack: could not open file %s for writing\n", name); - exit(1); + graphviz_exit(1); } return (fp); } @@ -298,7 +299,7 @@ static void init_graph(Agraph_t *g, bool fill, GVC_t *gvc) { if (d != 2) { fprintf(stderr, "Error: graph %s has dim = %d (!= 2)\n", agnameof(g), d); - exit(1); + graphviz_exit(1); } Ndim = GD_ndim(g) = 2; init_node_edge(g); @@ -311,7 +312,7 @@ static void init_graph(Agraph_t *g, bool fill, GVC_t *gvc) { else if (ret > 0) fprintf(stderr, "gvpack does not support backgrounds as found in graph %s\n", agnameof(g)); - exit(1); + graphviz_exit(1); } if (Concentrate) { /* check for edges without pos info */ for (n = agfstnode(g); n; n = agnxtnode(g, n)) { @@ -781,7 +782,7 @@ static Agraph_t **readGraphs(int *cp, GVC_t* gvc) else if (kind.directed != g->desc.directed) { fprintf(stderr, "Error: all graphs must be directed or undirected\n"); - exit(1); + graphviz_exit(1); } else if (!agisstrict(g)) kind = g->desc; init_graph(g, doPack, gvc); @@ -859,13 +860,13 @@ int main(int argc, char *argv[]) gvc = gvContextPlugins(lt_preloaded_symbols, DEMAND_LOADING); gs = readGraphs(&cnt, gvc); if (cnt == 0) - exit(0); + graphviz_exit(0); /* pack graphs */ if (doPack) { if (packGraphs(cnt, gs, 0, &pinfo)) { fprintf(stderr, "gvpack: packing of graphs failed.\n"); - exit(1); + graphviz_exit(1); } } @@ -879,5 +880,5 @@ int main(int argc, char *argv[]) attach_attrs(g); } agwrite(g, outfp); - exit(0); + graphviz_exit(0); } diff --git a/cmd/tools/gxl2gv.c b/cmd/tools/gxl2gv.c index b1936977b..f0a8faa74 100644 --- a/cmd/tools/gxl2gv.c +++ b/cmd/tools/gxl2gv.c @@ -11,6 +11,7 @@ #include #include "convert.h" #include +#include #ifdef HAVE_EXPAT #include #include @@ -56,7 +57,7 @@ static void *gcalloc(size_t nmemb, size_t size) char *rv = calloc(nmemb, size); if (rv == NULL) { fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } return rv; } @@ -78,7 +79,7 @@ static void popString(slist ** stk) slist *sp = *stk; if (!sp) { fprintf(stderr, "PANIC: gxl2gv: empty element stack\n"); - exit(1); + graphviz_exit(1); } *stk = sp->next; free(sp); @@ -88,7 +89,7 @@ static char *topString(slist * stk) { if (!stk) { fprintf(stderr, "PANIC: gxl2gv: empty element stack\n"); - exit(1); + graphviz_exit(1); } return stk->buf; } @@ -224,7 +225,7 @@ static void push_subg(Agraph_t * g) if (GSP == STACK_DEPTH) { fprintf(stderr, "gxl2gv: Too many (> %d) nestings of subgraphs\n", STACK_DEPTH); - exit(1); + graphviz_exit(1); } else if (GSP == 0) root = g; G = Gstack[GSP++] = g; @@ -235,7 +236,7 @@ static Agraph_t *pop_subg(void) Agraph_t *g; if (GSP == 0) { fprintf(stderr, "gxl2gv: Gstack underflow in graph parser\n"); - exit(1); + graphviz_exit(1); } g = Gstack[--GSP]; if (GSP > 0) @@ -709,7 +710,7 @@ Agraph_t *gxl_to_gv(FILE * gxlFile) if (udata == NULL) { fprintf(stderr, "out of memory\n"); - exit(1); + graphviz_exit(1); } XML_SetUserData(parser, udata); @@ -729,7 +730,7 @@ Agraph_t *gxl_to_gv(FILE * gxlFile) "%s at line %lu\n", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser)); - exit(1); + graphviz_exit(1); } } while (!done); XML_ParserFree(parser); diff --git a/cmd/tools/mm2gv.c b/cmd/tools/mm2gv.c index 1385f875e..dab5fafdd 100644 --- a/cmd/tools/mm2gv.c +++ b/cmd/tools/mm2gv.c @@ -214,7 +214,7 @@ static char* useString = "Usage: %s [-uvcl] [-o file] matrix_market_filename\n\ static void usage(int eval) { fprintf(stderr, useString, cmd); - exit(eval); + graphviz_exit(eval); } static FILE *openF(char *fname, char *mode) @@ -223,7 +223,7 @@ static FILE *openF(char *fname, char *mode) if (!f) { fprintf(stderr, "Could not open %s for %s\n", fname, ((*mode == 'r') ? "reading" : "writing")); - exit(1); + graphviz_exit(1); } return f; } @@ -325,7 +325,7 @@ int main(int argc, char *argv[]) if (!A) { fprintf(stderr, "cannot import from file %s\n", pv.infile); - exit(1); + graphviz_exit(1); } if (pv.undirected) { diff --git a/cmd/tools/nop.c b/cmd/tools/nop.c index f14450aac..6c902c931 100644 --- a/cmd/tools/nop.c +++ b/cmd/tools/nop.c @@ -11,6 +11,7 @@ #include "config.h" #include +#include #include #include #include @@ -32,7 +33,7 @@ If no files are specified, stdin is used\n"; static void usage(int v) { printf("%s",useString); - exit(v); + graphviz_exit(v); } static void init(int argc, char *argv[]) @@ -56,7 +57,7 @@ static void init(int argc, char *argv[]) break; default: fprintf(stderr, "nop: unexpected error\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } } argv += optind; diff --git a/cmd/tools/sccmap.c b/cmd/tools/sccmap.c index e6a1fb8cc..707235c3d 100644 --- a/cmd/tools/sccmap.c +++ b/cmd/tools/sccmap.c @@ -29,6 +29,7 @@ #include #endif #include +#include #include #include @@ -289,7 +290,7 @@ static FILE *openFile(const char *name) fp = fopen(name, "w"); if (!fp) { fprintf(stderr, "gvpack: could not open file %s for writing\n", name); - exit(1); + graphviz_exit(1); } return (fp); } @@ -306,7 +307,7 @@ If no files are specified, stdin is used\n"; static void usage(int v) { printf(useString, CmdName); - exit(v); + graphviz_exit(v); } static void scanArgs(int argc, char **argv) diff --git a/cmd/tools/tred.c b/cmd/tools/tred.c index 26a97c5fc..2e4e51495 100644 --- a/cmd/tools/tred.c +++ b/cmd/tools/tred.c @@ -20,6 +20,7 @@ #include "config.h" #include +#include #include #include #include @@ -87,14 +88,14 @@ static void push(estack_t* sp, Agedge_t * ep, nodeinfo_t* ninfo) blk_t *bp = NEW(blk_t); if (bp == 0) { fprintf(stderr, "%s: Out of memory\n", CmdName); - exit(1); + graphviz_exit(1); } bp->prev = sp->Stk.curblk; bp->next = NULL; bp->data = N_NEW(BIGBUF, Agedge_t *); if (bp->data == 0) { fprintf(stderr, "%s: Out of memory\n", CmdName); - exit(1); + graphviz_exit(1); } bp->endp = bp->data + BIGBUF; sp->Stk.curblk->next = bp; @@ -237,7 +238,7 @@ If no files are specified, stdin is used\n"; static void usage(int v) { printf(useString, CmdName); - exit(v); + graphviz_exit(v); } static void init(int argc, char *argv[]) diff --git a/cmd/tools/unflatten.c b/cmd/tools/unflatten.c index e3e9be61f..6c57283a4 100644 --- a/cmd/tools/unflatten.c +++ b/cmd/tools/unflatten.c @@ -23,6 +23,7 @@ #include #endif #include +#include #include #include @@ -142,7 +143,7 @@ static char *useString = static void usage(int v) { fprintf(stderr, useString, cmd); - exit(v); + graphviz_exit(v); } static FILE *openFile(const char *name) @@ -152,7 +153,7 @@ static FILE *openFile(const char *name) fp = fopen(name, "w"); if (!fp) { fprintf(stderr, "%s: could not open file %s for writing\n", cmd, name); - exit(-1); + graphviz_exit(-1); } return fp; } diff --git a/contrib/diffimg/diffimg.c b/contrib/diffimg/diffimg.c index 5b4d6acdc..5d2d30f7c 100644 --- a/contrib/diffimg/diffimg.c +++ b/contrib/diffimg/diffimg.c @@ -39,6 +39,8 @@ #include #include +#include + static char *pstopng="gs -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=- -q -"; static gdImagePtr imageLoad (char *filename) @@ -52,12 +54,12 @@ static gdImagePtr imageLoad (char *filename) ext = strrchr(filename, '.'); if (!ext) { fprintf(stderr, "Filename \"%s\" has no file extension.\n", filename); - exit(EX_USAGE); + graphviz_exit(EX_USAGE); } rc = stat(filename, &statbuf); if (rc) { fprintf(stderr, "Failed to stat \"%s\"\n", filename); - exit(EX_NOINPUT); + graphviz_exit(EX_NOINPUT); } if (strcasecmp(ext, ".ps") == 0) { ext = ".png"; @@ -78,14 +80,14 @@ static gdImagePtr imageLoad (char *filename) free(tmp); if (!f) { fprintf(stderr, "Failed to open converted \"%s%s\"\n", filename, ext); - exit(EX_NOINPUT); + graphviz_exit(EX_NOINPUT); } } else { f = fopen(filename, "rb"); if (!f) { fprintf(stderr, "Failed to open \"%s\"\n", filename); - exit(EX_NOINPUT); + graphviz_exit(EX_NOINPUT); } } im = 0; @@ -94,7 +96,7 @@ static gdImagePtr imageLoad (char *filename) im = gdImageCreateFromPng(f); #else fprintf(stderr, "PNG support is not available\n"); - exit(EX_UNAVAILABLE); + graphviz_exit(EX_UNAVAILABLE); #endif } else if (strcasecmp(ext, ".gif") == 0) { @@ -102,7 +104,7 @@ static gdImagePtr imageLoad (char *filename) im = gdImageCreateFromGif(f); #else fprintf(stderr, "GIF support is not available\n"); - exit(EX_UNAVAILABLE); + graphviz_exit(EX_UNAVAILABLE); #endif } else if (strcasecmp(ext, ".jpg") == 0) { @@ -110,13 +112,13 @@ static gdImagePtr imageLoad (char *filename) im = gdImageCreateFromJpeg(f); #else fprintf(stderr, "JPEG support is not available\n"); - exit(EX_UNAVAILABLE); + graphviz_exit(EX_UNAVAILABLE); #endif } fclose(f); if (!im) { fprintf(stderr, "Loading image from file \"%s\" failed!\n", filename); - exit(EX_DATAERR); + graphviz_exit(EX_DATAERR); } return im; } @@ -152,11 +154,11 @@ int main(int argc, char **argv) if (argc == 2 && strcmp(argv[1], "-?") == 0) { fprintf(stderr, "Usage: diffimg image1 image2 [outimage]\n"); - exit(0); + graphviz_exit(0); } if (argc < 3) { fprintf(stderr, "Usage: diffimg image1 image2 [outimage]\n"); - exit(EX_USAGE); + graphviz_exit(EX_USAGE); } A = imageLoad(argv[1]); B = imageLoad(argv[2]); diff --git a/contrib/prune/prune.c b/contrib/prune/prune.c index ddf7896aa..159969b26 100644 --- a/contrib/prune/prune.c +++ b/contrib/prune/prune.c @@ -21,6 +21,7 @@ #include #include "cgraph.h" +#include "exit.h" #include "ingraphs.h" #include "generic_list.h" @@ -103,7 +104,7 @@ int main(int argc, char **argv) case 'h': { help_message(progname); - exit(EXIT_SUCCESS); + graphviz_exit(EXIT_SUCCESS); break; } case 'v': @@ -114,19 +115,19 @@ int main(int argc, char **argv) case '?': if (optopt == '?') { help_message(progname); - exit(EXIT_SUCCESS); + graphviz_exit(EXIT_SUCCESS); } else if (isprint(optopt)) { fprintf(stderr, "Unknown option `-%c'.\n", optopt); } else { fprintf(stderr, "Unknown option character `\\x%X'.\n", optopt); } - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); break; default: help_message(progname); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); break; } } @@ -143,7 +144,7 @@ int main(int argc, char **argv) if (agisdirected(graph) == 0) { fprintf(stderr, "*** Error: Graph is undirected! Pruning works only with directed graphs!\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } /* attach node data for marking to all nodes */ @@ -185,7 +186,7 @@ int main(int argc, char **argv) if (attr == NULL) { fprintf(stderr, "Couldn't create attribute: %s\n", ((strattr_t *) attr_list->data[j])->n); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } agxset(node, attr, ((strattr_t *) attr_list->data[j])->v); @@ -197,7 +198,7 @@ int main(int argc, char **argv) } free(attr_list); free(node_list); - exit(EXIT_SUCCESS); + graphviz_exit(EXIT_SUCCESS); } int remove_child(Agraph_t * graph, Agnode_t * node) @@ -263,14 +264,14 @@ generic_list_t *addattr(generic_list_t * l, char *a) sp = malloc(sizeof(strattr_t)); if (sp == NULL) { perror("[addattr()->malloc()]"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } /* Split argument spec. at first '=' */ p = strchr(a, '='); if (p == NULL) { fprintf(stderr, "Invalid argument specification: %s\n", a); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } *(p++) = '\0'; @@ -278,14 +279,14 @@ generic_list_t *addattr(generic_list_t * l, char *a) sp->n = strdup(a); if (sp->n == NULL) { perror("[addattr()->strdup()]"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } /* pointer to argument value */ sp->v = strdup(p); if (sp->v == NULL) { perror("[addattr()->strdup()]"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } return add_to_generic_list(l, (gl_data) sp); @@ -299,7 +300,7 @@ generic_list_t *addnode(generic_list_t * l, char *n) sp = strdup(n); if (sp == NULL) { perror("[addnode()->strdup()]"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } return add_to_generic_list(l, (gl_data) sp); diff --git a/doc/libgraph/sccmap.c b/doc/libgraph/sccmap.c index 0d33f723f..4c2bba84d 100644 --- a/doc/libgraph/sccmap.c +++ b/doc/libgraph/sccmap.c @@ -16,6 +16,7 @@ #include #endif #include "cgraph.h" +#include "exit.h" #include "ingraphs.h" #include @@ -259,7 +260,7 @@ static FILE *openFile(const char *name) fp = fopen(name, "w"); if (!fp) { fprintf(stderr, "gvpack: could not open file %s for writing\n", name); - exit(1); + graphviz_exit(1); } return (fp); } @@ -276,7 +277,7 @@ If no files are specified, stdin is used\n"; static void usage(int v) { printf(useString, CmdName); - exit(v); + graphviz_exit(v); } static void scanArgs(int argc, char **argv) diff --git a/lib/ast/error.c b/lib/ast/error.c index d3259c52d..81e04573e 100644 --- a/lib/ast/error.c +++ b/lib/ast/error.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -82,7 +83,7 @@ void errorv(const char *id, int level, const char *s, va_list ap) sfprintf(sfstderr, "\n%s", strerror(errno)); sfprintf(sfstderr, "\n"); if (level >= ERROR_FATAL) - exit(level - ERROR_FATAL + 1); + graphviz_exit(level - ERROR_FATAL + 1); } void error(int level, const char *s, ...) diff --git a/lib/cgraph/sprint.c b/lib/cgraph/sprint.c index 6f9476d85..316bebd01 100644 --- a/lib/cgraph/sprint.c +++ b/lib/cgraph/sprint.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -59,7 +60,7 @@ char *NONNULL gv_sprint_or_exit(const char *NONNULL format, ...) { if (s == NULL) { fprintf(stderr, "gv_sprint failed\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } return s; diff --git a/lib/common/input.c b/lib/common/input.c index 38289f27c..dd0e04baa 100644 --- a/lib/common/input.c +++ b/lib/common/input.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -91,7 +92,7 @@ int dotneato_usage(int exval) fputs(configItems, outs); if (GvExitOnUsage && (exval >= 0)) - exit(exval); + graphviz_exit(exval); return (exval+1); } @@ -248,7 +249,7 @@ int dotneato_args_initialize(GVC_t * gvc, int argc, char **argv) /* must happen before trying to select any plugins */ if (gvc->common.config) { gvconfig(gvc, gvc->common.config); - exit (0); + graphviz_exit(0); } /* feed the globals */ @@ -307,7 +308,7 @@ int dotneato_args_initialize(GVC_t * gvc, int argc, char **argv) /* Q: Should 'dot -c' be suggested generally or only when val = "dot"? */ fprintf(stderr, " No formats found.\nPerhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n"); } - if (GvExitOnUsage) exit(1); + if (GvExitOnUsage) graphviz_exit(1); return(2); } break; @@ -335,7 +336,7 @@ int dotneato_args_initialize(GVC_t * gvc, int argc, char **argv) fprintf(stderr, " No layouts found.\nPerhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n"); } } - if (GvExitOnUsage) exit(1); + if (GvExitOnUsage) graphviz_exit(1); return(2); } Kflag = 1; @@ -347,7 +348,7 @@ int dotneato_args_initialize(GVC_t * gvc, int argc, char **argv) fprintf(stderr, "%s - %s version %s (%s)\n", gvc->common.cmdname, gvc->common.info[0], gvc->common.info[1], gvc->common.info[2]); - if (GvExitOnUsage) exit(0); + if (GvExitOnUsage) graphviz_exit(0); return (1); break; case 'l': @@ -442,7 +443,7 @@ int dotneato_args_initialize(GVC_t * gvc, int argc, char **argv) } } - if (GvExitOnUsage) exit(1); + if (GvExitOnUsage) graphviz_exit(1); return(2); } } diff --git a/lib/common/memory.c b/lib/common/memory.c index 6071a769e..e75d51724 100644 --- a/lib/common/memory.c +++ b/lib/common/memory.c @@ -10,6 +10,7 @@ #include "config.h" +#include #include #include #include @@ -28,7 +29,7 @@ void *zrealloc(void *ptr, size_t size, size_t elt, size_t osize) void *p = realloc(ptr, size * elt); if (UNLIKELY(p == NULL && size)) { fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } if (osize < size) memset((char *) p + (osize * elt), '\0', (size - osize) * elt); @@ -40,7 +41,7 @@ void *gcalloc(size_t nmemb, size_t size) char *rv = calloc(nmemb, size); if (UNLIKELY(nmemb > 0 && size > 0 && rv == NULL)) { fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } return rv; } @@ -53,7 +54,7 @@ void *gmalloc(size_t nbytes) rv = malloc(nbytes); if (UNLIKELY(rv == NULL)) { fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } return rv; } @@ -63,7 +64,7 @@ void *grealloc(void *ptr, size_t size) void *p = realloc(ptr, size); if (UNLIKELY(p == NULL && size)) { fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } return p; } diff --git a/lib/common/xml.c b/lib/common/xml.c index 000d7471c..d4103fc09 100644 --- a/lib/common/xml.c +++ b/lib/common/xml.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -119,7 +120,7 @@ static int xml_core(char previous, const char **current, xml_flags_t flags, // TODO: a better strategy than aborting on malformed data if (is_invalid) { fprintf(stderr, "Error during conversion to \"UTF-8\". Quiting.\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } // Decode the character. Refer again to the above table to understand this diff --git a/lib/dotgen/mincross.c b/lib/dotgen/mincross.c index 32609344c..ae4d373da 100644 --- a/lib/dotgen/mincross.c +++ b/lib/dotgen/mincross.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -1870,7 +1871,7 @@ void virtual_weight(edge_t * e) assert(t >= 0); if (INT_MAX / t < ED_weight(e)) { agerr(AGERR, "overflow when calculating virtual weight of edge\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } ED_weight(e) *= t; diff --git a/lib/expr/excc.c b/lib/expr/excc.c index df67259c0..0f119e2b7 100644 --- a/lib/expr/excc.c +++ b/lib/expr/excc.c @@ -21,6 +21,7 @@ int tmp; /* temp var index */ \ Exccdisc_t* ccdisc; /* excc() discipline */ +#include #include #include #include @@ -224,7 +225,7 @@ gen(Excc_t* cc, Exnode_t* expr) sfprintf(cc->ccdisc->text, "%s", expr->data.variable.symbol->name); return; case EXIT: - sfprintf(cc->ccdisc->text, "exit("); + sfprintf(cc->ccdisc->text, "exit("); gen(cc, x); sfprintf(cc->ccdisc->text, ");\n"); return; diff --git a/lib/expr/exerror.c b/lib/expr/exerror.c index c63ae4acf..4b720ce87 100644 --- a/lib/expr/exerror.c +++ b/lib/expr/exerror.c @@ -16,6 +16,7 @@ */ #include +#include #include #include #include @@ -74,7 +75,7 @@ exerror(const char* format, ...) free(s); } else if (expr.program->disc->flags & EX_FATAL) - exit(1); + graphviz_exit(1); } void diff --git a/lib/expr/exeval.c b/lib/expr/exeval.c index 0af282ee2..71476e695 100644 --- a/lib/expr/exeval.c +++ b/lib/expr/exeval.c @@ -21,6 +21,7 @@ #define _BLD_sfio 1 #endif +#include #include #include #include @@ -1240,7 +1241,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env) if (ex->disc->exitf) (*ex->disc->exitf) (ex, env, (int)v.integer); else - exit((int)v.integer); + graphviz_exit((int)v.integer); /*NOTREACHED*/ v.integer = -1; return v; @@ -1483,7 +1484,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env) Sfio_t *buffer = sfstropen(); if (buffer == NULL) { fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } print(ex, expr, env, buffer); v.string = exstash(buffer, ex->ve); diff --git a/lib/fdpgen/dbg.c b/lib/fdpgen/dbg.c index 3677ab90c..3ae15c5e9 100644 --- a/lib/fdpgen/dbg.c +++ b/lib/fdpgen/dbg.c @@ -18,6 +18,7 @@ #define FDP_PRIVATE +#include #include #include #include @@ -182,7 +183,7 @@ void dumpG(graph_t * g, char *fname, int expMode) fp = fopen(fname, "w"); if (!fp) { fprintf(stderr, "Couldn not open %s \n", fname); - exit(1); + graphviz_exit(1); } outputGraph(g, fp, expMode); fclose(fp); diff --git a/lib/gvc/gvconfig.c b/lib/gvc/gvconfig.c index 4773a60c3..04f395575 100644 --- a/lib/gvc/gvconfig.c +++ b/lib/gvc/gvconfig.c @@ -14,6 +14,7 @@ #define _GNU_SOURCE 1 #endif +#include #include #include @@ -490,7 +491,7 @@ static void config_rescan(GVC_t *gvc, char *config_path) f = fopen(config_path,"w"); if (!f) { agerr(AGERR,"failed to open %s for write.\n", config_path); - exit(1); + graphviz_exit(1); } fprintf(f, "# This file was generated by \"dot -c\" at time of install.\n\n"); diff --git a/lib/gvc/gvdevice.c b/lib/gvc/gvdevice.c index e9ec37ee7..ba922b636 100644 --- a/lib/gvc/gvdevice.c +++ b/lib/gvc/gvdevice.c @@ -46,6 +46,7 @@ static uint64_t crc; #endif /* HAVE_LIBZ */ #include +#include #include #include #include @@ -68,7 +69,7 @@ static size_t gvwrite_no_z(GVJ_t * job, const void *s, size_t len) { job->output_data = realloc(job->output_data, job->output_data_allocated); if (!job->output_data) { (job->common->errorfn) ("memory allocation failure\n"); - exit(1); + graphviz_exit(1); } } memcpy(job->output_data + job->output_data_position, s, len); @@ -211,7 +212,7 @@ size_t gvwrite (GVJ_t * job, const char *s, size_t len) df = realloc(df, dfallocated); if (! df) { (job->common->errorfn) ("memory allocation failure\n"); - exit(1); + graphviz_exit(1); } } @@ -225,14 +226,14 @@ size_t gvwrite (GVJ_t * job, const char *s, size_t len) int r = deflate(z, Z_NO_FLUSH); if (r != Z_OK) { (job->common->errorfn) ("deflation problem %d\n", r); - exit(1); + graphviz_exit(1); } if ((olen = z->next_out - df)) { ret = gvwrite_no_z(job, df, olen); if (ret != olen) { (job->common->errorfn) ("gvwrite_no_z problem %d\n", ret); - exit(1); + graphviz_exit(1); } } } @@ -240,14 +241,14 @@ size_t gvwrite (GVJ_t * job, const char *s, size_t len) #else NOTUSED(olen); (job->common->errorfn) ("No libz support.\n"); - exit(1); + graphviz_exit(1); #endif } else { /* uncompressed write */ ret = gvwrite_no_z (job, s, len); if (ret != len) { (job->common->errorfn) ("gvwrite_no_z problem %d\n", len); - exit(1); + graphviz_exit(1); } } return len; @@ -356,14 +357,14 @@ void gvdevice_finalize(GVJ_t * job) } if (ret != Z_STREAM_END) { (job->common->errorfn) ("deflation finish problem %d cnt=%d\n", ret, cnt); - exit(1); + graphviz_exit(1); } gvwrite_no_z(job, df, z->next_out - df); ret = deflateEnd(z); if (ret != Z_OK) { (job->common->errorfn) ("deflation end problem %d\n", ret); - exit(1); + graphviz_exit(1); } out[0] = (unsigned char)crc; out[1] = (unsigned char)(crc >> 8); @@ -376,7 +377,7 @@ void gvdevice_finalize(GVJ_t * job) gvwrite_no_z(job, out, sizeof(out)); #else (job->common->errorfn) ("No libz support\n"); - exit(1); + graphviz_exit(1); #endif } diff --git a/lib/gvpr/compile.c b/lib/gvpr/compile.c index 11d3701fb..f2237a346 100644 --- a/lib/gvpr/compile.c +++ b/lib/gvpr/compile.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -205,7 +206,7 @@ static char *symName(Expr_t * ex, int op) int bytes = vsnprintf(NULL, 0, "", op); if (bytes < 0) { fprintf(stderr, "%s: vsnprintf failure\n", __func__); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } // construct a managed buffer to store this name diff --git a/lib/gvpr/gvpr.c b/lib/gvpr/gvpr.c index d9d4f7c1f..d99fa521f 100644 --- a/lib/gvpr/gvpr.c +++ b/lib/gvpr/gvpr.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -908,7 +909,7 @@ gverrorf (Expr_t *handle, Exdisc_t *discipline, int level, const char *fmt, ...) if (level >= ERROR_ERROR) { Gpr_t *state = (Gpr_t*)(discipline->user); if (state->flags & GV_USE_EXIT) - exit(1); + graphviz_exit(1); else if (state->flags & GV_USE_JUMP) longjmp (jbuf, 1); } diff --git a/lib/label/nrtmain.c b/lib/label/nrtmain.c index f1c2eeda9..6ec8d8738 100644 --- a/lib/label/nrtmain.c +++ b/lib/label/nrtmain.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -105,14 +106,14 @@ int doxlabel(opts_t * opts) if (!(gp = agread(opts->inf))) { fprintf(stderr, "%s: %s not a dot file\n", progname, opts->infname); - exit(1); + graphviz_exit(1); } fclose(opts->inf); fprintf(stderr, "laying out %s\n", opts->lay); if (gvLayout(opts->gvc, gp, opts->lay)) { fprintf(stderr, "%s: layout %s failed\n", progname, opts->lay); - exit(1); + graphviz_exit(1); } fprintf(stderr, "attach labels\n"); @@ -236,7 +237,7 @@ static FILE *openFile(const char *name, const char *mode) modestr = "writing"; fprintf(stderr, "%s: could not open file %s for %s -- %s\n", progname, name, modestr, strerror(errno)); - exit(1); + graphviz_exit(1); } return (fp); } @@ -266,7 +267,7 @@ static void init(int argc, char *argv[], opts_t * opts) else { fprintf(stderr, "%s: unknown layout %s\n", progname, optarg); - exit(1); + graphviz_exit(1); } break; case 'T': @@ -276,7 +277,7 @@ static void init(int argc, char *argv[], opts_t * opts) else { fprintf(stderr, "%s: unknown format %s\n", progname, optarg); - exit(1); + graphviz_exit(1); } break; case 'v': @@ -291,7 +292,7 @@ static void init(int argc, char *argv[], opts_t * opts) break; default: usage(progname); - exit(1); + graphviz_exit(1); } } diff --git a/lib/neatogen/legal.c b/lib/neatogen/legal.c index 8cd663add..34a2522fc 100644 --- a/lib/neatogen/legal.c +++ b/lib/neatogen/legal.c @@ -9,6 +9,7 @@ *************************************************************************/ #include +#include #include #include @@ -263,7 +264,7 @@ static int find_intersection(vertex *l, #ifdef RECORD_INTERSECTS if (input->ninters >= MAXINTS) { agerr(AGERR, "using too many intersections\n"); - exit(1); + graphviz_exit(1); } ilist[input->ninters].firstv = l; diff --git a/lib/ortho/ortho.c b/lib/ortho/ortho.c index 7eb4cd548..4d4e71daa 100644 --- a/lib/ortho/ortho.c +++ b/lib/ortho/ortho.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -1439,7 +1440,7 @@ coordOf (cell* cp, snode* np) } else { agerr (AGERR, "Node not adjacent to cell -- Aborting\n"); - exit(EXIT_FAILURE); + graphviz_exit(EXIT_FAILURE); } return p; } diff --git a/lib/sfdpgen/post_process.c b/lib/sfdpgen/post_process.c index be2777fd8..fc6784ab5 100644 --- a/lib/sfdpgen/post_process.c +++ b/lib/sfdpgen/post_process.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -197,7 +198,7 @@ StressMajorizationSmoother StressMajorizationSmoother2_new(SparseMatrix A, int d } else { fprintf(stderr,"ideal_dist_scheme value wrong"); assert(0); - exit(1); + graphviz_exit(1); } /* @@ -239,7 +240,7 @@ StressMajorizationSmoother StressMajorizationSmoother2_new(SparseMatrix A, int d } else { fprintf(stderr,"ideal_dist_scheme value wrong"); assert(0); - exit(1); + graphviz_exit(1); } jw[nz] = ja[l]; diff --git a/lib/sparse/DotIO.c b/lib/sparse/DotIO.c index 94fe1d0d0..284586013 100644 --- a/lib/sparse/DotIO.c +++ b/lib/sparse/DotIO.c @@ -102,7 +102,7 @@ SparseMatrix_import_dot (Agraph_t* g, int dim, double **label_sizes, double **x, nedges = agnedges (g); if (format != FORMAT_CSR && format != FORMAT_COORD) { fprintf (stderr, "Format %d not supported\n", format); - exit (1); + graphviz_exit(1); } /* Assign node ids */ diff --git a/lib/sparse/SparseMatrix.c b/lib/sparse/SparseMatrix.c index 4f4d51859..a76fbb617 100644 --- a/lib/sparse/SparseMatrix.c +++ b/lib/sparse/SparseMatrix.c @@ -2612,7 +2612,7 @@ SparseMatrix SparseMatrix_distance_matrix_khops(int khops, SparseMatrix D0, int fprintf(stderr,"{%d,%d}=%f,",94,list[j],dist[list[j]]); } fprintf(stderr,"\n"); - exit(1); + graphviz_exit(1); */ diff --git a/lib/sparse/general.h b/lib/sparse/general.h index f481e33e7..37be67e80 100644 --- a/lib/sparse/general.h +++ b/lib/sparse/general.h @@ -21,6 +21,7 @@ */ #ifndef STANDALONE #include "cgraph.h" +#include "exit.h" #include "globals.h" #include "logic.h" #include "arith.h" diff --git a/plugin/glitz/gvdevice_glitz.c b/plugin/glitz/gvdevice_glitz.c index 0de8db49f..c3e344fed 100644 --- a/plugin/glitz/gvdevice_glitz.c +++ b/plugin/glitz/gvdevice_glitz.c @@ -33,6 +33,7 @@ #endif #include +#include #include #include @@ -102,7 +103,7 @@ static void handle_client_message(GVJ_t * job, XClientMessageEvent * cmev) window = (window_t *)job->window; if (cmev->format == 32 && (Atom) cmev->data.l[0] == window->wm_delete_window_atom) - exit(0); + graphviz_exit(0); } static bool handle_keypress(GVJ_t *job, XKeyEvent *kev) diff --git a/plugin/xlib/gvdevice_xlib.c b/plugin/xlib/gvdevice_xlib.c index 8d8b19813..e2423a151 100644 --- a/plugin/xlib/gvdevice_xlib.c +++ b/plugin/xlib/gvdevice_xlib.c @@ -36,6 +36,7 @@ #include #endif +#include #include #include @@ -89,7 +90,7 @@ static void handle_client_message(GVJ_t * job, XClientMessageEvent * cmev) window = job->window; if (cmev->format == 32 && (Atom) cmev->data.l[0] == window->wm_delete_window_atom) - exit(0); + graphviz_exit(0); } static bool handle_keypress(GVJ_t *job, XKeyEvent *kev) diff --git a/rtest/cdiff.c b/rtest/cdiff.c index 96d4cc606..9743e5edf 100644 --- a/rtest/cdiff.c +++ b/rtest/cdiff.c @@ -17,6 +17,8 @@ #include #include +#include + static int openF(char *fname) { int fd = open(fname, O_RDONLY); @@ -24,7 +26,7 @@ static int openF(char *fname) if (fd < 0) { fprintf(stderr, "Could not open %s for reading: %s\n\n", fname, strerror(errno)); - exit(1); + graphviz_exit(1); } return fd; } @@ -51,7 +53,7 @@ main(int argc, char *argv[]) if (argc != 3) { fprintf(stderr, "Usage: %s \n", argv[0]); - exit(1); + graphviz_exit(1); } f1 = openF(argv[1]); @@ -92,6 +94,6 @@ main(int argc, char *argv[]) } else xval = 0; - exit(xval); + graphviz_exit(xval); } diff --git a/tclpkg/tclpathplan/find_ints.c b/tclpkg/tclpathplan/find_ints.c index 0a739eaa7..c001ebac4 100644 --- a/tclpkg/tclpathplan/find_ints.c +++ b/tclpkg/tclpathplan/find_ints.c @@ -12,6 +12,8 @@ #include #include +#include + void find_intersection(struct vertex *l, struct vertex *m, struct intersection ilist[], struct data *input); static int gt(const void *a, const void *b); @@ -73,7 +75,7 @@ void find_ints(struct vertex vertex_list[], if ((tempa = templ->active) == NULL) { fprintf(stderr, "\n***ERROR***\n trying to delete a non line\n"); - exit(1); + graphviz_exit(1); } if (all.number == 1) all.final = all.first = NULL; /* delete the line */ diff --git a/tclpkg/tclpathplan/intersect.c b/tclpkg/tclpathplan/intersect.c index d72f4d091..d58faa32d 100644 --- a/tclpkg/tclpathplan/intersect.c +++ b/tclpkg/tclpathplan/intersect.c @@ -9,6 +9,7 @@ *************************************************************************/ #include +#include #include #include #include "simple.h" @@ -181,7 +182,7 @@ void find_intersection(struct vertex *l, if (input->ninters >= MAXINTS) { fprintf(stderr, "\n**ERROR**\n using too many intersections\n"); - exit(1); + graphviz_exit(1); } ilist[input->ninters].firstv = l; -- 2.40.0