]> granicus.if.org Git - graphviz/commitdiff
gvjobs_output_langname: return a C99 bool instead of boolean
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 28 Nov 2021 02:57:12 +0000 (18:57 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 5 Dec 2021 04:06:58 +0000 (20:06 -0800)
lib/common/input.c
lib/gvc/gvc.c
lib/gvc/gvcproc.h
lib/gvc/gvjobs.c
tclpkg/tcldot/tcldot-graphcmd.c

index fa151c3b929d899b43da3ea871df2905b852be6d..7c5abe5506e98a972cb1917b327d02c60e33f58b 100644 (file)
@@ -295,8 +295,7 @@ int dotneato_args_initialize(GVC_t * gvc, int argc, char **argv)
                    fprintf(stderr, "Missing argument for -T flag\n");
                    return (dotneato_usage(1));
                }
-               v = gvjobs_output_langname(gvc, val);
-               if (!v) {
+               if (!gvjobs_output_langname(gvc, val)) {
                    /* TODO: Detect empty results from gvplugin_list() and prompt to configure with '-c' */
                    char *fmts;
                    fprintf(stderr, "Format: \"%s\" not recognized.", val);
@@ -449,9 +448,7 @@ int dotneato_args_initialize(GVC_t * gvc, int argc, char **argv)
 
     /* if no -Txxx, then set default format */
     if (!gvc->jobs || !gvc->jobs->output_langname) {
-       v = gvjobs_output_langname(gvc, "dot");
-       if (!v) {
-//     assert(v);  /* "dot" should always be available as an output format */
+       if (!gvjobs_output_langname(gvc, "dot")) {
                fprintf(stderr,
                        "Unable to find even the default \"-Tdot\" renderer.  Has the config\nfile been generated by running \"dot -c\" with installer's privileges?\n");
                        return(2);
index c7386dea36fdb85c41dbeec619e5cc1e81bc2446..14cab191b94bd7c09e460afe36b46d56e420e41b 100644 (file)
@@ -17,6 +17,7 @@
 #include <gvc/gvcproc.h>
 #include <gvc/gvconfig.h>
 #include <gvc/gvio.h>
+#include <stdbool.h>
 #include <stdlib.h>
 
 GVC_t *gvContext(void)
@@ -87,9 +88,9 @@ int gvRender(GVC_t *gvc, graph_t *g, const char *format, FILE *out)
     g = g->root;
 
     /* create a job for the required format */
-    rc = gvjobs_output_langname(gvc, format);
+    bool r = gvjobs_output_langname(gvc, format);
     job = gvc->job;
-    if (!rc) {
+    if (!r) {
         agerr (AGERR, "Format: \"%s\" not recognized. Use one of:%s\n",
                 format, gvplugin_list(gvc, API_device, format));
         return -1;
@@ -119,9 +120,9 @@ int gvRenderFilename(GVC_t *gvc, graph_t *g, const char *format, const char *fil
     g = g->root;
 
     /* create a job for the required format */
-    rc = gvjobs_output_langname(gvc, format);
+    bool r = gvjobs_output_langname(gvc, format);
     job = gvc->job;
-    if (!rc) {
+    if (!r) {
        agerr(AGERR, "Format: \"%s\" not recognized. Use one of:%s\n",
                 format, gvplugin_list(gvc, API_device, format));
        return -1;
@@ -150,9 +151,9 @@ int gvRenderContext(GVC_t *gvc, graph_t *g, const char *format, void *context)
     g = g->root;
        
     /* create a job for the required format */
-    rc = gvjobs_output_langname(gvc, format);
+    bool r = gvjobs_output_langname(gvc, format);
     job = gvc->job;
-    if (!rc) {
+    if (!r) {
                agerr(AGERR, "Format: \"%s\" not recognized. Use one of:%s\n",
                          format, gvplugin_list(gvc, API_device, format));
                return -1;
@@ -184,9 +185,9 @@ int gvRenderData(GVC_t *gvc, graph_t *g, const char *format, char **result, unsi
     g = g->root;
 
     /* create a job for the required format */
-    rc = gvjobs_output_langname(gvc, format);
+    bool r = gvjobs_output_langname(gvc, format);
     job = gvc->job;
-    if (!rc) {
+    if (!r) {
        agerr(AGERR, "Format: \"%s\" not recognized. Use one of:%s\n",
                 format, gvplugin_list(gvc, API_device, format));
        return -1;
index a213adb9809651ab7c83ef41c1e579b61a290868..a267ad3b2f55ba1b629d839d16701eb830a9bc76 100644 (file)
@@ -39,7 +39,7 @@
 /* job */
 
     void gvjobs_output_filename(GVC_t * gvc, const char *name);
-    boolean gvjobs_output_langname(GVC_t * gvc, const char *name);
+    bool gvjobs_output_langname(GVC_t * gvc, const char *name);
     GVJ_t *gvjobs_first(GVC_t * gvc);
     GVJ_t *gvjobs_next(GVC_t * gvc);
     void gvjobs_delete(GVC_t * gvc);
index 91f0dc2e02e035fc83afd9d1179a251b0266093d..271c31dc668530359ee8b6800da99e626d798bbb 100644 (file)
@@ -16,6 +16,7 @@
 #include        <gvc/gvcjob.h>
 #include        <gvc/gvcint.h>
 #include        <gvc/gvcproc.h>
+#include        <stdbool.h>
 
 static GVJ_t *output_filename_job;
 static GVJ_t *output_langname_job;
@@ -58,7 +59,7 @@ void gvjobs_output_filename(GVC_t * gvc, const char *name)
 }
 
 /* -T switches */
-boolean gvjobs_output_langname(GVC_t * gvc, const char *name)
+bool gvjobs_output_langname(GVC_t * gvc, const char *name)
 {
     if (!gvc->jobs) {
        output_langname_job = gvc->job = gvc->jobs = zmalloc(sizeof(GVJ_t));
@@ -77,8 +78,8 @@ boolean gvjobs_output_langname(GVC_t * gvc, const char *name)
 
     /* load it now to check that it exists */
     if (gvplugin_load(gvc, API_device, name))
-       return TRUE;
-    return FALSE;
+       return true;
+    return false;
 }
 
 GVJ_t *gvjobs_first(GVC_t * gvc)
index 42a6cfb7e9b5324878e20c12a7dff01eba6b1daf..d902b201ada06277e9e2842dd71858f5fbdebfa1 100644 (file)
@@ -447,12 +447,7 @@ int graphcmd(ClientData clientData, Tcl_Interp * interp,
        }
 
        /* process lang first to create job */
-       if (argc < 4) {
-           i = gvjobs_output_langname(gvc, "dot");
-       } else {
-           i = gvjobs_output_langname(gvc, argv[3]);
-       }
-       if (!i) {
+       if (!gvjobs_output_langname(gvc, argc < 4 ? "dot" : argv[3])) {
            const char *s = gvplugin_list(gvc, API_render, argv[3]);
            Tcl_AppendResult(interp, "bad langname: \"", argv[3], "\". Use one of:", s, NULL);
            return TCL_ERROR;