From 6e9674beb04885fe92e85413cd3537c4c1cfd77c Mon Sep 17 00:00:00 2001 From: erg Date: Mon, 4 Feb 2008 22:47:45 +0000 Subject: [PATCH] Fix (ac)graph scanner to only set the graph type at top level. --- lib/agraph/scan.l | 6 +++--- lib/cgraph/scan.l | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) 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('-'); -- 2.50.1