Introducing Malicious Code Reviews
paulbiggar.blogspot.com
paulbiggar.blogspot.com
Wikipedia mentions the pattern as well:
"The lex/flex family of generators uses a table-driven approach which is much less efficient than the directly coded approach. With the latter approach the generator produces an engine that directly jumps to follow-up states via goto statements. Tools like re2c and Quex have proven (e.g. article about re2c) to produce engines that are between two to three times faster than flex produced engines.[citation needed] It is in general difficult to hand-write analyzers that perform better than engines generated by these latter tools." (http://en.wikipedia.org/wiki/Lexical_analysis)
I understand that it may be dumb to refactor the lexer, but it gets less dumb if it's supported by hundreds of tests, and far more dumb if it's based on testing over time.
As to the presence of a bug, impossible to tell. Which is the point.
if ( .. )
{
for ( .. )
{
label:
...
}
}
else
{
if ( .. )
{
..
}
else
goto label;
..
}
The actual code is even worse than this as there's a second goto that jumps from the top for into one of else blocks at the bottom from where the control can go back to for via another goto ... I sort of can see how this code came about, but there is absolutely no excuse for checking in something this f*cked up.If they wanted to show off, they should've just used the coroutines :-)