From 975bb564319aa4f4204c48aba265757ba207a80f Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 31 Dec 2014 14:48:13 +0100 Subject: [PATCH] flex: don't trust YY_USER_INIT Reported by Bernd Edligner and others. * src/scan-gram.l: here. --- THANKS | 1 + src/scan-gram.l | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/THANKS b/THANKS index 1b1ff716..4559a901 100644 --- a/THANKS +++ b/THANKS @@ -16,6 +16,7 @@ Art Haas ahaas@neosoft.com Baron Schwartz baron@sequent.org Ben Pfaff blp@cs.stanford.edu Benoit Perrot benoit.perrot@epita.fr +Bernd Edligner bernd.edlinger@hotmail.de Bernd Kiefer kiefer@dfki.de Bert Deknuydt Bert.Deknuydt@esat.kuleuven.ac.be Bill Allombert Bill.Allombert@math.u-bordeaux1.fr diff --git a/src/scan-gram.l b/src/scan-gram.l index abc8a892..d0b81a8b 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -45,9 +45,6 @@ #define YY_DECL GRAM_LEX_DECL -#define YY_USER_INIT \ - code_start = scanner_cursor = loc->start; \ - /* Location of scanner cursor. */ static boundary scanner_cursor; @@ -166,6 +163,15 @@ eqopt ([[:space:]]*=)? /* Where containing comment or string or character literal started, when applicable. */ boundary token_start PACIFY_CC (= scanner_cursor); + + /* We cannot trust YY_USER_INIT, whose semantics changes over time + (it moved in Flex 2.5.38). */ + static bool first = true; + if (first) + { + scanner_cursor = loc->start; + first = false; + } %} -- 2.47.2