From 97c4551ec884fe149a16a3f9c88bd25c397247ad Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Mon, 22 Oct 2018 10:38:53 +0200 Subject: [PATCH] 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. --- src/libstrongswan/settings/settings_lexer.l | 5 +++++ src/starter/parser/lexer.l | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/libstrongswan/settings/settings_lexer.l b/src/libstrongswan/settings/settings_lexer.l index 19ab8d7b28..e8c2b9884b 100644 --- a/src/libstrongswan/settings/settings_lexer.l +++ b/src/libstrongswan/settings/settings_lexer.l @@ -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 diff --git a/src/starter/parser/lexer.l b/src/starter/parser/lexer.l index fb23a0f931..b81d6ce74d 100644 --- a/src/starter/parser/lexer.l +++ b/src/starter/parser/lexer.l @@ -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 -- 2.47.3