]> granicus.if.org Git - graphviz/commitdiff
rec_apply: take 'preorder' parameter as a C99 bool for clarity
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 10 Aug 2021 02:01:34 +0000 (19:01 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 13 Aug 2021 14:50:45 +0000 (07:50 -0700)
lib/cgraph/apply.c

index 122a8743cf684f840afc1449c6f96e6a03b10b4a..8804d33550e57204fb8622f30e5a2e51be9ad0e1 100644 (file)
@@ -9,6 +9,7 @@
  *************************************************************************/
 
 #include       <cgraph/cghdr.h>
+#include       <stdbool.h>
 
 /* The following functions take a graph and a template (node/edge/graph)
  * and return the object representing the template within the local graph.
@@ -38,8 +39,7 @@ static Agobj_t *subgraph_search(Agraph_t * sub, Agobj_t * g)
  * if obj is a graph, then it and its subgs are visited.
  */
 static void rec_apply(Agraph_t * g, Agobj_t * obj, agobjfn_t fn, void *arg,
-                     agobjsearchfn_t objsearch, int preorder)
-{
+                      agobjsearchfn_t objsearch, bool preorder) {
     Agraph_t *sub;
     Agobj_t *subobj;
 
@@ -49,7 +49,7 @@ static void rec_apply(Agraph_t * g, Agobj_t * obj, agobjfn_t fn, void *arg,
        if ((subobj = objsearch(sub, obj)))
            rec_apply(sub, subobj, fn, arg, objsearch, preorder);
     }
-    if (NOT(preorder))
+    if (!preorder)
        fn(g, obj, arg);
 }
 
@@ -76,7 +76,7 @@ int agapply(Agraph_t * g, Agobj_t * obj, agobjfn_t fn, void *arg,
        break;
     }
     if ((subobj = objsearch(g, obj))) {
-       rec_apply(g, subobj, fn, arg, objsearch, preorder);
+       rec_apply(g, subobj, fn, arg, objsearch, preorder != 0);
        return SUCCESS;
     } else
        return FAILURE;