summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-08-07 23:47:07 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-08-07 23:47:07 -0700
commit850d2ff91a9f705c559ad17964afe7fd8796cd27 (patch)
treee6ab4866998839da416927051806af0f311f9c07
parent3736361f915a7df8ed3ffc9a52b47e7af6bc280b (diff)
downloadtxr-850d2ff91a9f705c559ad17964afe7fd8796cd27.tar.gz
txr-850d2ff91a9f705c559ad17964afe7fd8796cd27.tar.bz2
txr-850d2ff91a9f705c559ad17964afe7fd8796cd27.zip
scanner: backport isatty hack to Flex 2.5.x.
* parser.l (VER, FLEX_VER): New macros. (isatty): Define the macro differently for Flex 2.5.36 and older, to counteract the skeleton's "extern int isatty(int)" declaration. This involves a dummy global variable. (no_isatty): New dummy global, only under Flex 2.5.36 and older.
-rw-r--r--parser.l19
1 files changed, 18 insertions, 1 deletions
diff --git a/parser.l b/parser.l
index 8bcb53ba..7c8b3842 100644
--- a/parser.l
+++ b/parser.l
@@ -46,11 +46,28 @@
#include "parser.h"
#include "txr.h"
+#define VER(MAJ, MIN, SUB) ((MAJ) * 100000 + (MIN) * 1000 + SUB)
+
+#define FLEX_VER VER(YY_FLEX_MAJOR_VERSION, \
+ YY_FLEX_MINOR_VERSION, \
+ YY_FLEX_SUBMINOR_VERSION)
+
#define YY_NO_UNISTD_H
-/* Defeat flex's calls to isatty, which happene even in batch mode */
+/* Defeat flex's calls to isatty, which happens even in batch mode */
+
#undef isatty
+
+/*
+ * Until 2.5.36, the Flex skeleton contained "extern int isatty(int)",
+ * requiring special handling.
+ */
+#if FLEX_VER <= VER(2, 5, 36)
+#define isatty(x) no_isatty
+int no_isatty = 0;
+#else
#define isatty(x) 0
+#endif
#define YY_INPUT(buf, result, max_size) \
do { \