summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-08-06 23:31:33 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-08-06 23:31:33 -0700
commitc870cb387621f6f6cf12c312133a18473d5e785f (patch)
tree98f2f4b3df646be3a5e2795eb21fe52dfdad42b9
parent7e1b36e8985f2dd88646049661080eac065d36f9 (diff)
downloadtxr-c870cb387621f6f6cf12c312133a18473d5e785f.tar.gz
txr-c870cb387621f6f6cf12c312133a18473d5e785f.tar.bz2
txr-c870cb387621f6f6cf12c312133a18473d5e785f.zip
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 <unistd.h> inclusion. Define isatty as a macro that returns zero. Add the batch option to the scanner.
-rw-r--r--parser.l9
1 files 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 <wchar.h>
#include <signal.h>
#include "config.h"
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#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 [+\-]