From 0dd7c6307e7613961df26b46a24fea2f8a85b0cf Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 6 Aug 2020 23:31:33 -0700 Subject: scanner: use batch mode; nuke isatty calls. The flex-generated scanner wastefully calls isatty(0) whenever it is initialized, even though we don't read from a stdio stream. Even (read "abc") will call isatty(0), which is unacceptable. Moreover, this happens even if Flex is told to operate in batch mode rather than interactive. With the following change, the isatty calls are gone. Let's switch Flex to batch mode, too. * parser.l: Remove inclusion. Define isatty as a macro that returns zero. Add the batch option to the scanner. --- parser.l | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/parser.l b/parser.l index 9d2ecd4f..8bcb53ba 100644 --- a/parser.l +++ b/parser.l @@ -35,9 +35,6 @@ #include #include #include "config.h" -#if HAVE_UNISTD_H -#include -#endif #include "lib.h" #include "gc.h" #include "stream.h" @@ -51,6 +48,10 @@ #define YY_NO_UNISTD_H +/* Defeat flex's calls to isatty, which happene even in batch mode */ +#undef isatty +#define isatty(x) 0 + #define YY_INPUT(buf, result, max_size) \ do { \ val self = lit("parser"); \ @@ -233,7 +234,7 @@ static wchar_t *unicode_ident(scanner_t *scn, const char *lex) %} -%option stack noinput reentrant bison-bridge extra-type="parser_t *" +%option stack noinput reentrant bison-bridge extra-type="parser_t *" batch TOK [a-zA-Z0-9_]+ SGN [+\-] -- cgit v1.2.3