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
commit0dd7c6307e7613961df26b46a24fea2f8a85b0cf (patch)
tree98f2f4b3df646be3a5e2795eb21fe52dfdad42b9
parent10a9dd2304c8187b5e4ec958633580ca35d3bf2b (diff)
downloadtxr-0dd7c6307e7613961df26b46a24fea2f8a85b0cf.tar.gz
txr-0dd7c6307e7613961df26b46a24fea2f8a85b0cf.tar.bz2
txr-0dd7c6307e7613961df26b46a24fea2f8a85b0cf.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 [+\-]