From: erg Date: Mon, 4 Feb 2008 22:47:45 +0000 (+0000) Subject: Fix (ac)graph scanner to only set the graph type at top level. X-Git-Tag: LAST_LIBGRAPH~32^2~4768 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e9674beb04885fe92e85413cd3537c4c1cfd77c;p=graphviz Fix (ac)graph scanner to only set the graph type at top level. --- diff --git a/lib/agraph/scan.l b/lib/agraph/scan.l index e17e49368..8a8b6f9f2 100644 --- a/lib/agraph/scan.l +++ b/lib/agraph/scan.l @@ -44,7 +44,7 @@ void agsetfile(char* f) { InputFile = f; line_num = 1; } * requires pushing back whatever was previously read. * There probably is a right way of doing this. */ -void aglexinit(Agdisc_t *disc, void *ifile) { Disc = disc; Ifile = ifile;} +void aglexinit(Agdisc_t *disc, void *ifile) { Disc = disc; Ifile = ifile; graphType = 0;} #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ @@ -175,8 +175,8 @@ ID ({NAME}|{NUMBER}) [\000-\040\177] /* ignore whitespace */ "node" return(T_node); /* see tokens in agcanonstr */ "edge" return(T_edge); -"graph" graphType = T_graph; return(T_graph); -"digraph" graphType = T_digraph; return(T_digraph); +"graph" if (!graphType) graphType = T_graph; return(T_graph); +"digraph" if (!graphType) graphType = T_digraph; return(T_digraph); "strict" return(T_strict); "subgraph" return(T_subgraph); "->" if (graphType == T_digraph) return(T_edgeop); else return ('-'); diff --git a/lib/cgraph/scan.l b/lib/cgraph/scan.l index 895872783..93185a27d 100644 --- a/lib/cgraph/scan.l +++ b/lib/cgraph/scan.l @@ -40,7 +40,7 @@ void agsetfile(char* f) { InputFile = f; line_num = 1; } * requires pushing back whatever was previously read. * There probably is a right way of doing this. */ -void aglexinit(Agdisc_t *disc, void *ifile) { Disc = disc; Ifile = ifile;} +void aglexinit(Agdisc_t *disc, void *ifile) { Disc = disc; Ifile = ifile; graphType = 0;} #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ @@ -171,8 +171,8 @@ ID ({NAME}|{NUMBER}) [ \t\r] /* ignore whitespace */ "node" return(T_node); /* see tokens in agcanonstr */ "edge" return(T_edge); -"graph" graphType = T_graph; return(T_graph); -"digraph" graphType = T_digraph; return(T_digraph); +"graph" if (!graphType) graphType = T_graph; return(T_graph); +"digraph" if (!graphType) graphType = T_digraph; return(T_digraph); "strict" return(T_strict); "subgraph" return(T_subgraph); "->" if (graphType == T_digraph) return(T_edgeop); else return('-');