summaryrefslogtreecommitdiff
path: root/src/cpp-flex.skl
diff options
context:
space:
mode:
authorJoseph Langley <mightyjo@gmail.com>2021-07-02 18:46:52 -0400
committerJoseph Langley <mightyjo@gmail.com>2021-07-02 18:46:52 -0400
commit79da5dfa0fb837f97b1f1d71377a83efa90c8081 (patch)
treead4af33ba7b87cd646d28b09bd9d1f3b729b079b /src/cpp-flex.skl
parent8100144eb4e2b5e82476a958ab9690ebccb54ee6 (diff)
downloadflex-git-79da5dfa0fb837f97b1f1d71377a83efa90c8081.tar.gz
fix(skel): Init state buffer correctly
State buffer initialization in cpp-flex.skl got lost during a rebase. Added it back in from c99-flex.skl and made improvements suggested by smcpeak.
Diffstat (limited to 'src/cpp-flex.skl')
-rw-r--r--src/cpp-flex.skl23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl
index fe9344f..10738ba 100644
--- a/src/cpp-flex.skl
+++ b/src/cpp-flex.skl
@@ -1880,17 +1880,6 @@ m4_ifdef( [[<M4_YY_BISON_LLOC>]],
YY_USER_INIT;
#endif
-m4_ifdef( [[M4_MODE_USES_REJECT]],
-[[
- /* Create the reject buffer large enough to save one state per allowed character. */
- if ( ! YY_G(yy_state_buf) ) {
- YY_G(yy_state_buf) = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE M4_YY_CALL_LAST_ARG);
- }
- if ( ! YY_G(yy_state_buf) ) {
- YY_FATAL_ERROR( "out of dynamic memory in yylex()" );
- }
-]])
-
if ( ! YY_G(yy_start) ) {
YY_G(yy_start) = 1; /* first start state */
}
@@ -1915,6 +1904,18 @@ m4_ifdef([[M4_MODE_CXX_ONLY]], [[
YY_CURRENT_BUFFER_LVALUE =
yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG);
}
+
+m4_ifdef( [[M4_MODE_USES_REJECT]],
+[[
+ /* Create the reject buffer large enough to save one state per allowed character. */
+ if ( ! YY_G(yy_state_buf) ) {
+ YY_G(yy_state_buf) = (yy_state_type *)yyalloc( ((YY_CURRENT_BUFFER_LVALUE->yy_buf_size + YY_STATE_BUF_EXTRA_SPACE) * sizeof(yy_state_type)) M4_YY_CALL_LAST_ARG);
+ if ( ! YY_G(yy_state_buf) ) {
+ YY_FATAL_ERROR( "out of dynamic memory in yylex()" );
+ }
+ YY_G(yy_state_buf_max) = (YY_CURRENT_BUFFER_LVALUE->yy_buf_size + YY_STATE_BUF_EXTRA_SPACE);
+ }
+]])
yy_load_buffer_state( M4_YY_CALL_ONLY_ARG );
}