From 7882778fe605e67e9c44a84f30e5f2c0902b157a Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 9 Oct 2022 19:57:56 -0700 Subject: [PATCH] gxl2gv: dedupe 'openFile' implementation I am not sure why this was not done as part of 7d5fcee02fe8a046c2ed8801426c1a1afda3f80b. --- cmd/tools/cvtgxl.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/cmd/tools/cvtgxl.c b/cmd/tools/cvtgxl.c index 2ce7d3485..dbe7a30d8 100644 --- a/cmd/tools/cvtgxl.c +++ b/cmd/tools/cvtgxl.c @@ -28,6 +28,7 @@ #include "convert.h" #include #include +#include "openFile.h" typedef enum { Unset, ToGV, ToGXL } mode; @@ -62,19 +63,6 @@ static FILE *getFile(void) } #endif -static FILE *openFile(const char *name) -{ - FILE *fp; - - fp = fopen(name, "w"); - if (!fp) { - fprintf(stderr, "%s: could not open file %s for writing\n", CmdName, name); - perror(name); - graphviz_exit(1); - } - return fp; -} - static const char *use = "Usage: %s [-gd?] [-o] []\n\ -g : convert to GXL\n\ -d : convert to GV\n\ @@ -151,7 +139,7 @@ static void initargs(int argc, char **argv) case 'o': if (outFile != NULL) fclose(outFile); - outFile = openFile(optarg); + outFile = openFile(CmdName, optarg, "w"); break; case ':': fprintf(stderr, "%s: option -%c missing argument\n", CmdName, optopt); -- 2.40.0