lex: reset yy_at_bol in yyless() if yyleng is non-zero.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

lex: reset yy_at_bol in yyless() if yyleng is non-zero.

Todd C. Miller-3
Fixes a bug where calling yyless() to unput all the chars before a
newline would not reset the beginning of line marker.  Otherwise,
flex won't match rules that start with a caret (^) after calling
yyless() in thise case.  AT&T lex behaves correctly.

Upstream PR: https://github.com/westes/flex/pull/452

 - todd

Index: usr.bin/lex/flex.skl
===================================================================
RCS file: /cvs/src/usr.bin/lex/flex.skl,v
retrieving revision 1.16
diff -u -p -u -r1.16 flex.skl
--- usr.bin/lex/flex.skl 2 May 2017 19:16:19 -0000 1.16
+++ usr.bin/lex/flex.skl 4 Aug 2020 16:01:22 -0000
@@ -532,6 +532,9 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
  YY_RESTORE_YY_MORE_OFFSET \
  YY_G(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
  YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+ if ( yyleng > 0 ) \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
+    (yytext[yyleng - 1] == '\n'); \
  } \
  while ( 0 )
 ]])