Bjorn Ketelaars <bket@openbsd.org> wrote:
> On Sat 27/02/2021 18:18, Christian Weisgerber wrote:
> > Bjorn Ketelaars:
> >
> > > +--- src/parser-cw.c.orig
> > > ++++ src/parser-cw.c
> > > +@@ -32,8 +32,8 @@
> > > + #include "program-cw.h"
> > > + #include "options.h"
> > > +
> > > +- int current_line;
> > > +- struct cw_line *root_line;
> > > ++ extern int current_line;
> > > ++ extern struct cw_line *root_line;
> >
> > Hmm. There are two parsers, parser-cw.y and parser-rc.y, and each
> > has variables current_line and root_line. Should those be static
> > instead?
>
> I overlooked the second parser, good catch. I think you are right that
> we need to make current_line and root_line static, thus limiting the
> visibility of things within the same file.
Sometimes these can be static.
Other times, they should have unique names.
The mistake is to assume a common was desirable sharing. Sometimes the
sharing is incidental and erroneous.
This would actually have been a bug, if these parsers were nested.
No comments:
Post a Comment