From 55014cfc28c3cdb57253455160df7b58837112d4 Mon Sep 17 00:00:00 2001 From: Emden Gansner Date: Fri, 16 Dec 2016 17:15:01 -0500 Subject: [PATCH] Fix a couple of lose ends where incorrect information is given in error messages. Make sure each call to agmemread resets the line number to 1 and the file name to NULL. If the input contains cpp line directive, another run of agmemread with errors would report them incorrectly. In addition, the gvNextInputGraph in common/input.s was not resetting the the file name in the case that the new FILE* happened to use the same memory as the previous FILE*. --- lib/cgraph/io.c | 7 ++++++- lib/common/input.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/cgraph/io.c b/lib/cgraph/io.c index 3910f44b4..34513deab 100644 --- a/lib/cgraph/io.c +++ b/lib/cgraph/io.c @@ -142,7 +142,12 @@ Agraph_t *agmemread(const char *cp) disc.mem = &AgMemDisc; disc.id = &AgIdDisc; - disc.io = &memIoDisc; + disc.io = &memIoDisc; + /* Null out filename and reset line number + * The name may have been set with a ppDirective, and + * we want to reset line_num. + */ + agsetfile(NULL); g = agread (&rdr, &disc); return g; } diff --git a/lib/common/input.c b/lib/common/input.c index cfb809bc9..98f193681 100644 --- a/lib/common/input.c +++ b/lib/common/input.c @@ -572,7 +572,7 @@ graph_t *gvNextInputGraph(GVC_t *gvc) } if (fp != stdin) fclose (fp); - fp = NULL; + oldfp = fp = NULL; gidx = 0; } return g; -- 2.40.0