]> granicus.if.org Git - graphviz/commitdiff
expr exccopen: only pass SFIO stream to callback
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 5 Aug 2022 01:41:06 +0000 (18:41 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 5 Aug 2022 01:41:06 +0000 (18:41 -0700)
This function invokes `dtwalk` passing the callback `global` to be called with
a state parameter it supplies. It was supplying `cc`, but the callback only uses
a single member of this struct. So we can simplify this code by just passing the
stream the callback writes to, `cc->ccdisc-text`, or equivalently `disc->text`.

lib/expr/excc.c

index 0f119e2b7f31325e35f718658ba714df14259c1a..9e40ba739df940a8b867d3a4ee98670b2b9d6dbb 100644 (file)
@@ -624,11 +624,11 @@ global(Dt_t* table, void* object, void* handle)
 {
        (void)table;
 
-       Excc_t* cc = handle;
+       Sfio_t *stream = handle;
        Exid_t* sym = object;
 
        if (sym->lex == DYNAMIC)
-               sfprintf(cc->ccdisc->text, "static %s   %s;\n", extype(sym->type), sym->name);
+               sfprintf(stream, "static %s     %s;\n", extype(sym->type), sym->name);
        return 0;
 }
 
@@ -657,7 +657,7 @@ exccopen(Expr_t* expr, Exccdisc_t* disc)
                if (*id)
                        snprintf(cc->id, strlen(id) + 2, "%s_", id);
                sfprintf(disc->text, "\n");
-               dtwalk(expr->symbols, global, cc);
+               dtwalk(expr->symbols, global, disc->text);
        }
        return cc;
 }