[Libguestfs] [PATCH 2/3] builder: show the file name in errors of the index parser
Pino Toscano
ptoscano at redhat.com
Thu Mar 20 08:23:52 UTC 2014
On Wednesday 19 March 2014 22:16:47 Richard W.M. Jones wrote:
> On Wed, Mar 19, 2014 at 05:53:10PM +0100, Pino Toscano wrote:
> > ---
> >
> > builder/index-parse.y | 4 +++-
> > builder/index-parser-c.c | 1 +
> > builder/index-struct.h | 1 +
> > 3 files changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/builder/index-parse.y b/builder/index-parse.y
> > index dee2aec..9c75f71 100644
> > --- a/builder/index-parse.y
> > +++ b/builder/index-parse.y
> >
> > @@ -143,7 +143,9 @@ emptylines:
> > void
> > yyerror (YYLTYPE * yylloc, yyscan_t scanner, struct parse_context
> > *context, const char *msg) {
> >
> > - fprintf (stderr, "syntax error at line %d: %s\n",
> > + fprintf (stderr, "%s%ssyntax error at line %d: %s\n",
> > + context->input_file ? context->input_file : "",
> > + context->input_file ? ": " : "",
> >
> > yylloc->first_line, msg);
> >
> > }
> >
> > diff --git a/builder/index-parser-c.c b/builder/index-parser-c.c
> > index 7aeb6d0..8cae7b8 100644
> > --- a/builder/index-parser-c.c
> > +++ b/builder/index-parser-c.c
> > @@ -56,6 +56,7 @@ virt_builder_parse_index (value filenamev)
> >
> > FILE *in;
> >
> > parse_context_init (&context);
> >
> > + context.input_file = String_val (filenamev);
> >
> > in = fopen (String_val (filenamev), "r");
> > if (in == NULL)
> >
> > diff --git a/builder/index-struct.h b/builder/index-struct.h
> > index 9480526..7d4b8e0 100644
> > --- a/builder/index-struct.h
> > +++ b/builder/index-struct.h
> > @@ -43,6 +43,7 @@ struct parse_context {
> >
> > * compatibility with virt-builder 1.24.
> > */
> >
> > int seen_comments;
> >
> > + const char *input_file;
> >
> > };
> >
> > /* Initialize the content of a parse_context. */
>
> ACK. When you commit this, can you add (RHBZ#xxxxx) to the subject
> line? It will ensure the bugs-in-changelog.sh script picks up the bug
> for the release notes.
Theoretically I'm not done with #1077817 yet, so should I put it
regardless, or just as a "Related to #..." in the commit text?
--
Pino Toscano
More information about the Libguestfs
mailing list