Skip to content

Commit 2d662f3

Browse files
MaxKellermannGirgias
authored andcommittedJan 4, 2023
Zend/zend_ini_scanner: parse const strings
1 parent 5e9b335 commit 2d662f3

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed
 

‎Zend/zend_globals.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,11 @@ struct _zend_ini_scanner_globals {
297297
zend_file_handle *yy_out;
298298

299299
unsigned int yy_leng;
300-
unsigned char *yy_start;
301-
unsigned char *yy_text;
302-
unsigned char *yy_cursor;
303-
unsigned char *yy_marker;
304-
unsigned char *yy_limit;
300+
const unsigned char *yy_start;
301+
const unsigned char *yy_text;
302+
const unsigned char *yy_cursor;
303+
const unsigned char *yy_marker;
304+
const unsigned char *yy_limit;
305305
int yy_state;
306306
zend_stack state_stack;
307307

‎Zend/zend_ini.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ END_EXTERN_C()
233233
typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg);
234234
BEGIN_EXTERN_C()
235235
ZEND_API int zend_parse_ini_file(zend_file_handle *fh, bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg);
236-
ZEND_API int zend_parse_ini_string(char *str, bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg);
236+
ZEND_API int zend_parse_ini_string(const char *str, bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg);
237237
END_EXTERN_C()
238238

239239
/* INI entries */

‎Zend/zend_ini_parser.y

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ ZEND_API zend_result zend_parse_ini_file(zend_file_handle *fh, bool unbuffered_e
238238
/* }}} */
239239

240240
/* {{{ zend_parse_ini_string() */
241-
ZEND_API zend_result zend_parse_ini_string(char *str, bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg)
241+
ZEND_API zend_result zend_parse_ini_string(const char *str, bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg)
242242
{
243243
int retval;
244244
zend_ini_parser_param ini_parser_param;

‎Zend/zend_ini_scanner.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ BEGIN_EXTERN_C()
2929
ZEND_COLD int zend_ini_scanner_get_lineno(void);
3030
ZEND_COLD const char *zend_ini_scanner_get_filename(void);
3131
zend_result zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode);
32-
zend_result zend_ini_prepare_string_for_scanning(char *str, int scanner_mode);
32+
zend_result zend_ini_prepare_string_for_scanning(const char *str, int scanner_mode);
3333
int ini_lex(zval *ini_lval);
3434
void shutdown_ini_scanner(void);
3535
END_EXTERN_C()

‎Zend/zend_ini_scanner.l

+8-8
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
/* emulate flex constructs */
5656
#define BEGIN(state) YYSETCONDITION(STATE(state))
5757
#define YYSTATE YYGETCONDITION()
58-
#define yytext ((char*)SCNG(yy_text))
58+
#define yytext ((const char*)SCNG(yy_text))
5959
#define yyleng SCNG(yy_leng)
60-
#define yyless(x) do { YYCURSOR = (unsigned char*)yytext + x; \
60+
#define yyless(x) do { YYCURSOR = (const unsigned char*)yytext + x; \
6161
yyleng = (unsigned int)x; } while(0)
6262

6363
/* #define yymore() goto yymore_restart */
@@ -208,9 +208,9 @@ static void yy_pop_state(void)
208208
zend_stack_del_top(&SCNG(state_stack));
209209
}
210210

211-
static void yy_scan_buffer(char *str, unsigned int len)
211+
static void yy_scan_buffer(const char *str, unsigned int len)
212212
{
213-
YYCURSOR = (YYCTYPE*)str;
213+
YYCURSOR = (const YYCTYPE*)str;
214214
SCNG(yy_start) = YYCURSOR;
215215
YYLIMIT = YYCURSOR + len;
216216
}
@@ -288,7 +288,7 @@ zend_result zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mo
288288
/* }}} */
289289

290290
/* {{{ zend_ini_prepare_string_for_scanning() */
291-
zend_result zend_ini_prepare_string_for_scanning(char *str, int scanner_mode)
291+
zend_result zend_ini_prepare_string_for_scanning(const char *str, int scanner_mode)
292292
{
293293
int len = (int)strlen(str);
294294

@@ -303,7 +303,7 @@ zend_result zend_ini_prepare_string_for_scanning(char *str, int scanner_mode)
303303
/* }}} */
304304

305305
/* {{{ zend_ini_escape_string() */
306-
static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_type)
306+
static void zend_ini_escape_string(zval *lval, const char *str, int len, char quote_type)
307307
{
308308
char *s, *t;
309309
char *end;
@@ -493,7 +493,7 @@ SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\\"{ANY_CHAR})|{LITERAL_DOLLAR})
493493
}
494494

495495
<ST_RAW>{RAW_VALUE_CHARS} { /* Raw value, only used when SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW. */
496-
unsigned char *sc = NULL;
496+
const unsigned char *sc = NULL;
497497
EAT_LEADING_WHITESPACE();
498498
while (YYCURSOR < YYLIMIT) {
499499
switch (*YYCURSOR) {
@@ -591,7 +591,7 @@ end_raw_value_chars:
591591
return 0;
592592
}
593593

594-
unsigned char *s = SCNG(yy_text);
594+
const unsigned char *s = SCNG(yy_text);
595595

596596
while (s < YYLIMIT) {
597597
switch (*s++) {

0 commit comments

Comments
 (0)
Please sign in to comment.