diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-09-07 11:42:21 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-09-07 11:42:21 +0200 |
commit | f5dbebd82e642b1d1af462b486fc392ecff2c67a (patch) | |
tree | 59c9eba8521db0a339f6f6479777b5ee893a2e92 /sapi | |
parent | 85b5dc4711f6ce8b979ed60e3b60cf93225be32a (diff) | |
download | php-git-f5dbebd82e642b1d1af462b486fc392ecff2c67a.tar.gz |
Accept zend_string instead of zval in zend_compile_string
Diffstat (limited to 'sapi')
-rw-r--r-- | sapi/phpdbg/phpdbg.h | 2 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_bp.c | 16 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_list.c | 8 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_prompt.c | 7 |
4 files changed, 11 insertions, 22 deletions
diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h index 5405155833..e5db725336 100644 --- a/sapi/phpdbg/phpdbg.h +++ b/sapi/phpdbg/phpdbg.h @@ -275,7 +275,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) zend_op_array *(*compile_file)(zend_file_handle *file_handle, int type); zend_op_array *(*init_compile_file)(zend_file_handle *file_handle, int type); - zend_op_array *(*compile_string)(zval *source_string, const char *filename); + zend_op_array *(*compile_string)(zend_string *source_string, const char *filename); HashTable file_sources; FILE *oplog; /* opline log */ diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c index a29d4442fb..db3d1cf0c4 100644 --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@ -828,7 +828,7 @@ static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, co { phpdbg_breakcond_t new_break; uint32_t cops = CG(compiler_options); - zval pv; + zend_string *bp_code; switch (param->type) { case STR_PARAM: @@ -877,16 +877,10 @@ static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, co new_break.code = estrndup(expr, expr_len); new_break.code_len = expr_len; - Z_STR(pv) = zend_string_alloc(expr_len + sizeof("return ;") - 1, 0); - memcpy(Z_STRVAL(pv), "return ", sizeof("return ") - 1); - memcpy(Z_STRVAL(pv) + sizeof("return ") - 1, expr, expr_len); - Z_STRVAL(pv)[Z_STRLEN(pv) - 1] = ';'; - Z_STRVAL(pv)[Z_STRLEN(pv)] = '\0'; - Z_TYPE_INFO(pv) = IS_STRING; - - new_break.ops = zend_compile_string(&pv, "Conditional Breakpoint Code"); - - zval_ptr_dtor_str(&pv); + bp_code = zend_string_concat3( + "return ", sizeof("return ")-1, expr, expr_len, ";", sizeof(";")-1); + new_break.ops = zend_compile_string(bp_code, "Conditional Breakpoint Code"); + zend_string_release(bp_code); if (new_break.ops) { brake = zend_hash_index_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], hash, &new_break, sizeof(phpdbg_breakcond_t)); diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c index d9b2fa00d5..0967e22f65 100644 --- a/sapi/phpdbg/phpdbg_list.c +++ b/sapi/phpdbg/phpdbg_list.c @@ -316,7 +316,7 @@ zend_op_array *phpdbg_init_compile_file(zend_file_handle *file, int type) { return op_array; } -zend_op_array *phpdbg_compile_string(zval *source_string, const char *filename) { +zend_op_array *phpdbg_compile_string(zend_string *source_string, const char *filename) { zend_string *fake_name; zend_op_array *op_array; phpdbg_file_source *dataptr; @@ -327,9 +327,9 @@ zend_op_array *phpdbg_compile_string(zval *source_string, const char *filename) return PHPDBG_G(compile_string)(source_string, filename); } - dataptr = emalloc(sizeof(phpdbg_file_source) + sizeof(uint32_t) * Z_STRLEN_P(source_string)); - dataptr->buf = estrndup(Z_STRVAL_P(source_string), Z_STRLEN_P(source_string)); - dataptr->len = Z_STRLEN_P(source_string); + dataptr = emalloc(sizeof(phpdbg_file_source) + sizeof(uint32_t) * ZSTR_LEN(source_string)); + dataptr->buf = estrndup(ZSTR_VAL(source_string), ZSTR_LEN(source_string)); + dataptr->len = ZSTR_LEN(source_string); dataptr->line[0] = 0; for (line = 0, bufptr = dataptr->buf - 1, endptr = dataptr->buf + dataptr->len; ++bufptr < endptr;) { if (*bufptr == '\n') { diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 9f8fdd820c..39ef7d8768 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -519,12 +519,7 @@ exec_code: } /* }}} */ int phpdbg_compile_stdin(zend_string *code) { - zval zv; - - ZVAL_STR(&zv, code); - - PHPDBG_G(ops) = zend_compile_string(&zv, "Standard input code"); - + PHPDBG_G(ops) = zend_compile_string(code, "Standard input code"); zend_string_release(code); if (EG(exception)) { |