[RFC 0/8] Beginning to remove globals from parser-defs.h

Sergio Durigan Junior
2012-01-15T18:49:11Z

Hello,

I have been working on this during my weekends, and I would like to know
what you guys think about this set of patches.

While I was working on another patch, I started to dive into the current
expression parsing mechanism, and it really bothered me all those
globals. So, as a pet project, I decided to start removing them.
Initially I tried to remove them all, and create a big structure which
would hold the parsing state and be passed to parser-specific functions.
Unfortunately, this task proved to be non-sense because of its size and
increasing complexity, so I decided to tackle the problem using another
way: baby steps, as Tom would say.

These 8 patches basically contain adaptations on every .y file, as well
as on the *-lang.h ones, and on parser-defs.h/parse.c files. The idea
now is to make three fields non-global: `expout', `expout_size' and
`expout_ptr'. There are still some (lots of?) other global variables
there, which I didn't touch yet. Maybe some day I will have
time/patience for that...

I decided to split the patches because the whole diff file contains more
than 7 thousand lines. However, I did not bother to make those patches
compile independently! So if you want to test, you'll have to apply
them all (order should not matter).

I hope you like the result. It is still far from ideal, but I believe
it is a good step towards this "non-globalization" thing.

Comments, as usual, are welcome. The patch has been regtested on an
x86_64 and i686 Fedora 15, without regressions.

Thank you,

Sergio.

P.S.: I still haven't written the ChangeLog's, I wanted to know your
opinion about it first.