From: erg Date: Wed, 8 Sep 2010 18:54:26 +0000 (+0000) Subject: Make sure each run of gvpr creates a $T file with a unique name. X-Git-Tag: LAST_LIBGRAPH~32^2~1201 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e723a8168c743a70f680198495154094cfc9f58;p=graphviz Make sure each run of gvpr creates a $T file with a unique name. --- diff --git a/lib/gvpr/gprstate.c b/lib/gvpr/gprstate.c index 90e75c1ad..4601305c2 100644 --- a/lib/gvpr/gprstate.c +++ b/lib/gvpr/gprstate.c @@ -29,6 +29,8 @@ #include #include +static int name_used; + int validTVT(int c) { return ((TV_flat <= c) && (c <= TV_prepostrev)); @@ -55,6 +57,7 @@ Gpr_t *openGPRState(gpr_info* info) } state->tvt = TV_flat; + state->name_used = name_used; state->tvroot = 0; state->tvedge = 0; state->outFile = info->outFile; @@ -131,6 +134,7 @@ void addBindings (Gpr_t* state, gvprbinding* bindings) void closeGPRState(Gpr_t* state) { if (!state) return; + name_used = state->name_used; if (state->tmp) sfclose (state->tmp); free (state->dp); diff --git a/lib/gvpr/gvpr.c b/lib/gvpr/gvpr.c index 0b29f6a96..e588183a3 100644 --- a/lib/gvpr/gvpr.c +++ b/lib/gvpr/gvpr.c @@ -710,6 +710,12 @@ static int traverse(Gpr_t * state, Expr_t* prog, comp_block * bp, int cleanup) } else target = state->tgtname; state->name_used++; + /* make sure target subgraph does not exist */ + while (agsubg (state->curgraph, target, 0)) { + state->name_used++; + sfprintf(state->tmp, "%s%d", state->tgtname, state->name_used); + target = sfstruse(state->tmp); + } state->target = openSubg(state->curgraph, target); } if (!state->outgraph)