Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lexer: fix top-level probe ending in wildcard ambiguity handling
The lexer contains code to determine whether foo*bar at the top level of a script is a wildcarded probe name or a variable declaration (which would need a semicolon or an = or something else too, but maybe the lexer hasn't got to it yet). Back in the Solaris days this used to be done by just blindly looking up the stuff before the * as a type and considering it not a type if it wasn't, but this forces loading of all CTF basically no matter what (even the hardwired definition of NULL forces it). I rejigged this code way back in 5a7483d in 2012 to stop it looking up quite so many types unnecessarily, but in the process broke the code that puts the parts of the token after the * back on the parser stack again. You need to be very unlucky for this to trigger anything, but more recent flex has started actually doing what it has long promised and made unput() *actually* corrupt yytext: put the two together and bugs jump out and you start getting garbage or repeated junk after the * in cases like int*x (seen in test/unittest/options/err.pspec-default.d). Getting it right is actually simpler than getting it wrong: we don't need to take a temporary copy of the yytext to avoid the problem of its getting corrupted if we use yyless(), which does not corrupt yytext, rather than unput(); doing this simplifies the code that preserves the content beyond the * as well. (The rest of the lexer is still using unput() everywhere and needs fixing later.) This does not fix err.pspec-default.d, but it's a prerequisite for a fix that works (so err.pspec-default.d will serve as a test for it). Signed-off-by: Nick Alcock <nick.alcock@oracle.com> Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
- Loading branch information