Avoid inclusion of unistd.h in generated lexers

Because the file is not available on all platforms the inclusion comes
after the user options in order to disable including it.  But that means
the inclusion also follows after the defined scanner states, which are
generated as simple #defines to numbers.  If the included unistd.h e.g.
uses variables in function definitions with the same names this could
result in compilation errors.

Interactive mode has to be disabled too as it relies on isatty() from
unistd.h.  Since we don't use the scanners interactively, this is not a
problem and might even make the scanners a bit faster.

Fixes #2806.
This commit is contained in:
Tobias Brunner 2018-10-22 10:38:53 +02:00
parent 85431bf2e7
commit 97c4551ec8
2 changed files with 10 additions and 0 deletions

View File

@ -32,6 +32,11 @@ static void include_files(parser_helper_t *ctx);
/* do not declare unneeded functions */
%option noinput noyywrap
/* do not include unistd.h as it might conflict with our scanner states */
%option nounistd
/* due to that disable interactive mode, which requires isatty() */
%option never-interactive
/* don't use global variables, and interact properly with bison */
%option reentrant bison-bridge

View File

@ -33,6 +33,11 @@ static void include_files(parser_helper_t *ctx);
/* do not declare unneeded functions */
%option noinput noyywrap
/* do not include unistd.h as it might conflict with our scanner states */
%option nounistd
/* due to that disable interactive mode, which requires isatty() */
%option never-interactive
/* don't use global variables, and interact properly with bison */
%option reentrant bison-bridge