Skip to content

Commit 3c95595

Browse files
committed
Added _xx_scanner_state.bufsiz
1 parent 3d435ba commit 3c95595

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

parser/base.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ void xx_parse_program(zval *return_value, char *program, size_t program_length,
9191
/**
9292
* Initialize the scanner state
9393
*/
94+
state->bufsiz = program_length;
9495
state->active_token = 0;
9596
state->cursor = program;
9697
state->start_length = 0;

parser/parser.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8634,6 +8634,7 @@ void xx_parse_program(zval *return_value, char *program, size_t program_length,
86348634
/**
86358635
* Initialize the scanner state
86368636
*/
8637+
state->bufsiz = program_length;
86378638
state->active_token = 0;
86388639
state->cursor = program;
86398640
state->start_length = 0;

parser/xx.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef PHP_ZEPHIR_XX_H
1010
#define PHP_ZEPHIR_XX_H 1
1111

12-
#include <Zend/zend_types.h> // zval
12+
#include <Zend/zend_types.h> // zval, size_t
1313
#include <Zend/zend_operators.h> // zend_atoi
1414
#include <stdlib.h> // getenv
1515
#include <stdio.h> // fprintf, stderr
@@ -43,6 +43,9 @@ typedef struct _xx_scanner_state {
4343
* This is the same as re2c's YYMARKER. */
4444
char *marker;
4545

46+
/* The maximum number of bytes that the buffer can hold. */
47+
size_t bufsiz;
48+
4649
int active_token;
4750
unsigned int start_length;
4851
int mode;
@@ -98,12 +101,12 @@ int xx_get_token(xx_scanner_state *state, xx_scanner_token *token);
98101
#undef YYDEBUG
99102
#endif
100103

101-
#define YYDEBUG(s, c) do { \
102-
char *tmp; \
103-
tmp = getenv("ZEPHIR_YYDEBUG"); \
104-
if (tmp && zend_atoi(tmp, 1)) { \
105-
fprintf(stderr, "State: %d char: %c\n", s, c); \
106-
} \
104+
#define YYDEBUG(s, c) do { \
105+
char *tmp; \
106+
tmp = getenv("ZEPHIR_YYDEBUG"); \
107+
if (tmp && zend_atoi(tmp, 1)) { \
108+
fprintf(stderr, "State: %d char: %c\n", s, c); \
109+
} \
107110
} while(0);
108111

109112
#endif // PHP_ZEPHIR_XX_H

0 commit comments

Comments
 (0)