summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend_compile.c2
-rw-r--r--Zend/zend_compile.h4
-rw-r--r--Zend/zend_execute.c4
-rw-r--r--Zend/zend_execute_API.c15
-rw-r--r--Zend/zend_language_scanner.l13
-rw-r--r--sapi/phpdbg/phpdbg.h2
-rw-r--r--sapi/phpdbg/phpdbg_bp.c16
-rw-r--r--sapi/phpdbg/phpdbg_list.c8
-rw-r--r--sapi/phpdbg/phpdbg_prompt.c7
9 files changed, 27 insertions, 44 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 36715c7bb5..7eb2d79fe7 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -79,7 +79,7 @@ static inline uint32_t zend_alloc_cache_slot(void) {
}
ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type);
-ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, const char *filename);
+ZEND_API zend_op_array *(*zend_compile_string)(zend_string *source_string, const char *filename);
#ifndef ZTS
ZEND_API zend_compiler_globals compiler_globals;
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index e50f620ed4..505e625270 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -732,7 +732,7 @@ void zend_file_context_begin(zend_file_context *prev_context);
void zend_file_context_end(zend_file_context *prev_context);
extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type);
-extern ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, const char *filename);
+extern ZEND_API zend_op_array *(*zend_compile_string)(zend_string *source_string, const char *filename);
ZEND_API int ZEND_FASTCALL lex_scan(zval *zendlval, zend_parser_stack_elem *elem);
void startup_scanner(void);
@@ -792,7 +792,7 @@ ZEND_API void function_add_ref(zend_function *function);
struct _zend_arena;
ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type);
-ZEND_API zend_op_array *compile_string(zval *source_string, const char *filename);
+ZEND_API zend_op_array *compile_string(zend_string *source_string, const char *filename);
ZEND_API zend_op_array *compile_filename(int type, zval *filename);
ZEND_API zend_ast *zend_compile_string_to_ast(
zend_string *code, struct _zend_arena **ast_arena, const char *filename);
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 6e66ba72d6..2c07eae9eb 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -4217,7 +4217,9 @@ already_compiled:
break;
case ZEND_EVAL: {
char *eval_desc = zend_make_compiled_string_description("eval()'d code");
- new_op_array = zend_compile_string(inc_filename, eval_desc);
+ zend_string *code = zval_get_string(inc_filename);
+ new_op_array = zend_compile_string(code, eval_desc);
+ zend_string_release(code);
efree(eval_desc);
}
break;
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index b8c3f11974..f1bcc74a58 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -1143,26 +1143,23 @@ ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex) /* {{{ */
ZEND_API zend_result zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name) /* {{{ */
{
- zval pv;
zend_op_array *new_op_array;
uint32_t original_compiler_options;
zend_result retval;
+ zend_string *code_str;
if (retval_ptr) {
- ZVAL_NEW_STR(&pv, zend_string_alloc(str_len + sizeof("return ;")-1, 0));
- memcpy(Z_STRVAL(pv), "return ", sizeof("return ") - 1);
- memcpy(Z_STRVAL(pv) + sizeof("return ") - 1, str, str_len);
- Z_STRVAL(pv)[Z_STRLEN(pv) - 1] = ';';
- Z_STRVAL(pv)[Z_STRLEN(pv)] = '\0';
+ code_str = zend_string_concat3(
+ "return ", sizeof("return ")-1, str, str_len, ";", sizeof(";")-1);
} else {
- ZVAL_STRINGL(&pv, str, str_len);
+ code_str = zend_string_init(str, str_len, 0);
}
/*printf("Evaluating '%s'\n", pv.value.str.val);*/
original_compiler_options = CG(compiler_options);
CG(compiler_options) = ZEND_COMPILE_DEFAULT_FOR_EVAL;
- new_op_array = zend_compile_string(&pv, string_name);
+ new_op_array = zend_compile_string(code_str, string_name);
CG(compiler_options) = original_compiler_options;
if (new_op_array) {
@@ -1200,7 +1197,7 @@ ZEND_API zend_result zend_eval_stringl(const char *str, size_t str_len, zval *re
} else {
retval = FAILURE;
}
- zval_ptr_dtor_str(&pv);
+ zend_string_release(code_str);
return retval;
}
/* }}} */
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index 91f00e95d9..d1c5b85cf2 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -804,23 +804,18 @@ ZEND_API size_t zend_get_scanned_file_offset(void)
return offset;
}
-zend_op_array *compile_string(zval *source_string, const char *filename)
+zend_op_array *compile_string(zend_string *source_string, const char *filename)
{
zend_lex_state original_lex_state;
zend_op_array *op_array = NULL;
zval tmp;
- if (UNEXPECTED(Z_TYPE_P(source_string) != IS_STRING)) {
- ZVAL_STR(&tmp, zval_get_string_func(source_string));
- } else {
- ZVAL_COPY(&tmp, source_string);
- }
-
- if (Z_STRLEN(tmp)==0) {
- zval_ptr_dtor(&tmp);
+ if (ZSTR_LEN(source_string) == 0) {
return NULL;
}
+ ZVAL_STR_COPY(&tmp, source_string);
+
zend_save_lexical_state(&original_lex_state);
zend_prepare_string_for_scanning(&tmp, filename);
BEGIN(ST_IN_SCRIPTING);
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)) {