summaryrefslogtreecommitdiff
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
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.
-rw-r--r--src/c99-flex.skl37
-rw-r--r--src/cpp-flex.skl23
-rw-r--r--src/go-flex.skl37
3 files changed, 40 insertions, 57 deletions
diff --git a/src/c99-flex.skl b/src/c99-flex.skl
index 18af12b..317c038 100644
--- a/src/c99-flex.skl
+++ b/src/c99-flex.skl
@@ -2020,29 +2020,6 @@ m4_ifdef( [[<M4_YY_BISON_LLOC>]],
m4_ifdef([[YY_USER_INIT]], [[YY_USER_INIT]])
-m4_ifdef( [[M4_MODE_USES_REJECT]],
-[[
- /* Create the reject buffer large enough to save one state per allowed character. */
- if ( yyscanner->yy_state_buf == NULL ) {
- if( yy_current_buffer(yyscanner) == NULL ) {
- yyscanner->yy_state_buf = (yy_state_type *)yyalloc((YY_STATE_BUF_SIZE * sizeof(yy_state_type)), yyscanner);
- }
- else {
- yyscanner->yy_state_buf = (yy_state_type *)yyalloc(((yy_current_buffer(yyscanner)->yy_buf_size + YY_STATE_BUF_EXTRA_SPACE) * sizeof(yy_state_type)), yyscanner);
- }
- }
-
- if ( yyscanner->yy_state_buf == NULL ) {
- yypanic( "out of dynamic memory in yylex()", yyscanner );
- }
- else if ( yy_current_buffer(yyscanner) == NULL ) {
- yyscanner->yy_state_buf_max = YY_STATE_BUF_SIZE;
- }
- else {
- yyscanner->yy_state_buf_max = (yy_current_buffer(yyscanner)->yy_buf_size + YY_STATE_BUF_EXTRA_SPACE);
- }
-]])
-
if ( yyscanner->yy_start == 0 ) {
yyscanner->yy_start = 1; /* first start state */
}
@@ -2057,6 +2034,20 @@ m4_ifdef( [[M4_MODE_USES_REJECT]],
yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top] =
yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner);
}
+
+m4_ifdef( [[M4_MODE_USES_REJECT]],
+[[
+ /* Create the reject buffer large enough to save one state per allowed character.
+ * If the reject buffer already exists, keep using it.
+ */
+ if ( yyscanner->yy_state_buf == NULL ) {
+ yyscanner->yy_state_buf = (yy_state_type *)yyalloc(((yy_current_buffer(yyscanner)->yy_buf_size + YY_STATE_BUF_EXTRA_SPACE) * sizeof(yy_state_type)), yyscanner);
+ if ( yyscanner->yy_state_buf == NULL ) {
+ yypanic( "out of dynamic memory in yylex()", yyscanner );
+ }
+ yyscanner->yy_state_buf_max = (yy_current_buffer(yyscanner)->yy_buf_size + YY_STATE_BUF_EXTRA_SPACE);
+ }
+]])
yy_load_buffer_state( yyscanner );
}
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 );
}
diff --git a/src/go-flex.skl b/src/go-flex.skl
index f05bb51..53f0b90 100644
--- a/src/go-flex.skl
+++ b/src/go-flex.skl
@@ -1871,29 +1871,6 @@ m4_ifdef([[<M4_YY_BISON_LLOC>]],
m4_ifdef([[YY_USER_INIT]], [[YY_USER_INIT]])
-m4_ifdef([[M4_MODE_USES_REJECT]],
-[[
- /* Create the reject buffer large enough to save one state per allowed character. */
- if (yyscanner->yyStateBuf == NULL) {
- if (yy_current_buffer(yyscanner) == NULL) {
- yyscanner->yyStateBuf = (yyStateType *)yyalloc((YY_STATE_BUF_SIZE * sizeof(yyStateType)), yyscanner);
- }
- else {
- yyscanner->yyStateBuf = (yyStateType *)yyalloc((yy_current_buffer(yyscanner)->yyInputBufSize + YY_STATE_BUF_EXTRA_SPACE) * sizeof(yyStateType), yyscanner);
- }
- }
-
- if ( yyscanner->yyStateBuf == NULL ) {
- yypanic( "out of dynamic memory in yylex()", yyscanner );
- }
- else if ( yy_current_buffer(yyscanner) == NULL ) {
- yyscanner->yyStateBufMax = YY_STATE_BUF_SIZE;
- }
- else {
- yyscanner->yyStateBufMax = (yy_current_buffer(yyscanner)->yyInputBufSize + YY_STATE_BUF_EXTRA_SPACE);
- }
-]])
-
if (yyscanner->yyStart == 0) {
yyscanner->yyStart = 1; /* first start state */
}
@@ -1909,6 +1886,20 @@ m4_ifdef([[M4_MODE_USES_REJECT]],
yy_create_buffer(yyscanner->yyin, flexInputBufferSize, yyscanner);
}
+m4_ifdef([[M4_MODE_USES_REJECT]],
+[[
+ /* Create the reject buffer large enough to save one state per allowed character.
+ * If the reject buffer already exists, keep using it.
+ */
+ if (yyscanner->yyStateBuf == NULL) {
+ yyscanner->yyStateBuf = (yyStateType *)yyalloc((yy_current_buffer(yyscanner)->yyInputBufSize + YY_STATE_BUF_EXTRA_SPACE) * sizeof(yyStateType), yyscanner);
+ if ( yyscanner->yyStateBuf == NULL ) {
+ yypanic( "out of dynamic memory in yylex()", yyscanner );
+ }
+ yyscanner->yyStateBufMax = (yy_current_buffer(yyscanner)->yyInputBufSize + YY_STATE_BUF_EXTRA_SPACE);
+ }
+]])
+
yy_load_buffer_state(yyscanner);
}