From: erg Date: Thu, 6 Sep 2007 20:16:19 +0000 (+0000) Subject: "Fix" bug 1189. Basically, allowing multiple references to subgraphs X-Git-Tag: LAST_LIBGRAPH~32^2~5290 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7dd6aee78774cd18f9bb31c348a41a4cab19eadd;p=graphviz "Fix" bug 1189. Basically, allowing multiple references to subgraphs is dangerous, since it leads to cycles in the subgraph graph. Trying to support this would be a headache, so we are moving to forbidding this in DOT. At present, we give a severe warning. --- diff --git a/lib/graph/lexer.c b/lib/graph/lexer.c index f86afd158..2e3c76a09 100644 --- a/lib/graph/lexer.c +++ b/lib/graph/lexer.c @@ -33,7 +33,7 @@ static int LineBufSize; static uchar In_comment; static uchar Comment_start; static uchar Start_html_string; -static int Line_number; +int Line_number; static char *InputFile; static gets_f Lexer_gets; @@ -45,6 +45,11 @@ void agreadline(int n) Line_number = n - 1; } +int aglinenumber () +{ + return Line_number; +} + /* (Re)set file: */ void agsetfile(char *f) diff --git a/lib/graph/libgraph.h b/lib/graph/libgraph.h index 609a80612..5d411f1e0 100644 --- a/lib/graph/libgraph.h +++ b/lib/graph/libgraph.h @@ -167,6 +167,7 @@ extern "C" { void agpushproto(Agraph_t *); char *agstrdup_html(char *s); int agtoken(char *); + int aglinenumber (); void agwredge(Agraph_t *, FILE *, Agedge_t *, int); void agwrnode(Agraph_t *, FILE *, Agnode_t *, int, int); extern Dtdisc_t agNamedisc, agNodedisc, agOutdisc, agIndisc, diff --git a/lib/graph/parser.y b/lib/graph/parser.y index 40d0fdf3c..0f9ebcbbe 100644 --- a/lib/graph/parser.y +++ b/lib/graph/parser.y @@ -34,6 +34,14 @@ static objstack_t *SP; static Agraph_t *Gstack[32]; static int GSP; +static void subgraph_warn () +{ + agerr (AGWARN, "The use of \"subgraph %s\", line %d, without a body is deprecated.\n", + G->name, aglinenumber()); + agerr (AGPREV, "This may cause unexpected behavior or crash the program.\n"); + agerr (AGPREV, "Please use a single definition of the subgraph within the context of its parent graph \"%s\"\n", Gstack[GSP-2]->name); +} + static void push_subg(Agraph_t *g) { G = Gstack[GSP++] = g; @@ -452,7 +460,7 @@ edgeRHS : T_edgeop node_id {mid_edgestmt($2);} subg_stmt : subg_hdr '{' stmt_list '}'%prec '{' {$$ = pop_gobj();} | T_subgraph '{' { anonsubg(); } stmt_list '}' {$$ = pop_gobj();} | '{' { anonsubg(); } stmt_list '}' {$$ = pop_gobj();} - | subg_hdr %prec T_subgraph {$$ = pop_gobj();} + | subg_hdr %prec T_subgraph {subgraph_warn(); $$ = pop_gobj();} ; subg_hdr : T_subgraph symbol