summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend.c35
-rw-r--r--Zend/zend.h4
-rw-r--r--Zend/zend_API.c7
-rw-r--r--Zend/zend_compile.c15
-rw-r--r--Zend/zend_operators.c90
-rw-r--r--Zend/zend_operators.h1
-rw-r--r--Zend/zend_variables.c6
-rw-r--r--Zend/zend_variables.h2
-rw-r--r--Zend/zend_vm_def.h4
-rw-r--r--Zend/zend_vm_execute.h18
-rw-r--r--ext/reflection/php_reflection.c31
-rw-r--r--ext/standard/formatted_print.c18
-rw-r--r--ext/standard/string.c28
-rw-r--r--ext/standard/type.c13
-rw-r--r--sapi/phpdbg/phpdbg_info.c2
15 files changed, 89 insertions, 185 deletions
diff --git a/Zend/zend.c b/Zend/zend.c
index 4e12a79059..4d14c8a887 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -309,34 +309,23 @@ again:
}
/* }}} */
-ZEND_API int zend_print_zval(zval *expr, int indent) /* {{{ */
+ZEND_API int zend_print_zval(zval *expr, int indent TSRMLS_DC) /* {{{ */
{
- return zend_print_zval_ex(zend_write, expr, indent);
+ return zend_print_zval_ex(zend_write, expr, indent TSRMLS_CC);
}
/* }}} */
-ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent) /* {{{ */
+ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC) /* {{{ */
{
- zval expr_copy;
- int use_copy;
- int ret;
+ zend_string *str = zval_get_string(expr TSRMLS_CC);
+ int len = str->len;
- zend_make_printable_zval(expr, &expr_copy, &use_copy);
- if (use_copy) {
- expr = &expr_copy;
+ if (len != 0) {
+ write_func(str->val, len);
}
- if (Z_STRLEN_P(expr) == 0) { /* optimize away empty strings */
- if (use_copy) {
- zval_dtor(expr);
- }
- return 0;
- }
- write_func(Z_STRVAL_P(expr), Z_STRLEN_P(expr));
- ret = Z_STRLEN_P(expr);
- if (use_copy) {
- zval_dtor(expr);
- }
- return ret;
+
+ STR_RELEASE(str);
+ return len;
}
/* }}} */
@@ -386,7 +375,7 @@ ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC) /* {{{ */
break;
}
default:
- zend_print_variable(expr);
+ zend_print_variable(expr TSRMLS_CC);
break;
}
}
@@ -447,7 +436,7 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int
break;
}
default:
- zend_print_zval_ex(write_func, expr, indent);
+ zend_print_zval_ex(write_func, expr, indent TSRMLS_CC);
break;
}
}
diff --git a/Zend/zend.h b/Zend/zend.h
index c81c223a7f..3aae759dde 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -555,8 +555,8 @@ END_EXTERN_C()
BEGIN_EXTERN_C()
ZEND_API char *get_zend_version(void);
ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy);
-ZEND_API int zend_print_zval(zval *expr, int indent);
-ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent);
+ZEND_API int zend_print_zval(zval *expr, int indent TSRMLS_DC);
+ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC);
ZEND_API void zend_print_zval_r(zval *expr, int indent TSRMLS_DC);
ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC);
ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC);
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 7d394bfe13..6cf6cb2157 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -3289,12 +3289,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
default:
if (callable_name) {
- zval expr_copy;
- int use_copy;
-
- zend_make_printable_zval(callable, &expr_copy, &use_copy);
- *callable_name = STR_COPY(Z_STR(expr_copy));
- zval_dtor(&expr_copy);
+ *callable_name = zval_get_string(callable);
}
if (error) zend_spprintf(error, 0, "no array or string given");
return 0;
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 1077180df1..a6032cd109 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -3478,8 +3478,7 @@ static char * zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{
}
}
if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2_type != IS_UNUSED) {
- zval zv, zv_copy;
- int use_copy;
+ zval zv;
ZVAL_DUP(&zv, precv->op2.zv);
zval_update_constant_ex(&zv, (void*)1, fptr->common.scope TSRMLS_CC);
@@ -3509,13 +3508,11 @@ static char * zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{
memcpy(offset, "Array", 5);
offset += 5;
} else {
- zend_make_printable_zval(&zv, &zv_copy, &use_copy);
- REALLOC_BUF_IF_EXCEED(buf, offset, length, Z_STRLEN(zv_copy));
- memcpy(offset, Z_STRVAL(zv_copy), Z_STRLEN(zv_copy));
- offset += Z_STRLEN(zv_copy);
- if (use_copy) {
- zval_dtor(&zv_copy);
- }
+ zend_string *str = zval_get_string(&zv);
+ REALLOC_BUF_IF_EXCEED(buf, offset, length, str->len);
+ memcpy(offset, str->val, str->len);
+ offset += str->len;
+ STR_RELEASE(str);
}
zval_ptr_dtor(&zv);
}
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 0d45adf3af..3b596bb6c0 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -875,7 +875,7 @@ ZEND_API double zval_get_double(zval *op TSRMLS_DC) /* {{{ */
{
zval tmp;
ZVAL_DUP(&tmp, op);
- convert_object_to_type(op, IS_DOUBLE, convert_to_double);
+ convert_object_to_type(&tmp, IS_DOUBLE, convert_to_double);
if (Z_TYPE(tmp) == IS_DOUBLE) {
return Z_DVAL(tmp);
@@ -901,7 +901,7 @@ ZEND_API zend_string *zval_get_string(zval *op TSRMLS_DC) /* {{{ */
case IS_STRING:
return STR_COPY(Z_STR_P(op));
case IS_BOOL:
- if (Z_LVAL_P(op)) {
+ if (Z_BVAL_P(op)) {
return STR_INIT("1", 1, 0);
} else {
return STR_EMPTY_ALLOC();
@@ -932,17 +932,27 @@ ZEND_API zend_string *zval_get_string(zval *op TSRMLS_DC) /* {{{ */
return STR_INIT("Array", sizeof("Array")-1, 0);
case IS_OBJECT: {
zval tmp;
- ZVAL_DUP(&tmp, op);
- convert_object_to_type(op, IS_STRING, convert_to_string);
-
- if (Z_TYPE(tmp) == IS_STRING) {
- return Z_STR(tmp);
- } else {
- zend_error(E_NOTICE, "Object of class %s to string conversion", Z_OBJCE_P(op)->name->val);
- zval_dtor(&tmp);
- return STR_INIT("Object", sizeof("Object")-1, 0);
+ //???if (zend_std_cast_object_tostring(op, &tmp, IS_STRING TSRMLS_CC) == SUCCESS) {
+ //??? return Z_STR(tmp);
+ //???}
+ if (Z_OBJ_HT_P(op)->cast_object) {
+ if (Z_OBJ_HT_P(op)->cast_object(op, &tmp, IS_STRING TSRMLS_CC) == SUCCESS) {
+ return Z_STR(tmp);
+ }
+ } else if (Z_OBJ_HT_P(op)->get) {
+ zval *z = Z_OBJ_HT_P(op)->get(op, &tmp TSRMLS_CC);
+ if (Z_TYPE_P(z) != IS_OBJECT) {
+ zend_string *str = zval_get_string(z TSRMLS_CC);
+ zval_ptr_dtor(z);
+ return str;
+ }
+ zval_ptr_dtor(z);
}
+ zend_error(EG(exception) ? E_ERROR : E_RECOVERABLE_ERROR, "Object of class %s could not be converted to string", Z_OBJCE_P(op)->name->val);
+ return STR_EMPTY_ALLOC();
}
+ case IS_REFERENCE:
+ return zval_get_string(Z_REFVAL_P(op));
default:
//??? original code returns bool(0)
return STR_EMPTY_ALLOC();
@@ -1547,35 +1557,17 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{
ZEND_API int string_compare_function_ex(zval *result, zval *op1, zval *op2, zend_bool case_insensitive TSRMLS_DC) /* {{{ */
{
- zval op1_copy, op2_copy;
- int use_copy1 = 0, use_copy2 = 0;
-
- if (Z_TYPE_P(op1) != IS_STRING) {
- zend_make_printable_zval(op1, &op1_copy, &use_copy1);
- }
- if (Z_TYPE_P(op2) != IS_STRING) {
- zend_make_printable_zval(op2, &op2_copy, &use_copy2);
- }
-
- if (use_copy1) {
- op1 = &op1_copy;
- }
- if (use_copy2) {
- op2 = &op2_copy;
- }
+ zend_string *str1 = zval_get_string(op1 TSRMLS_CC),
+ *str2 = zval_get_string(op2 TSRMLS_CC);
if (case_insensitive) {
- ZVAL_LONG(result, zend_binary_zval_strcasecmp(op1, op2));
+ ZVAL_LONG(result, zend_binary_strcasecmp_l(str1->val, str1->len, str2->val, str1->len));
} else {
- ZVAL_LONG(result, zend_binary_zval_strcmp(op1, op2));
+ ZVAL_LONG(result, zend_binary_strcmp(str1->val, str1->len, str2->val, str2->len));
}
- if (use_copy1) {
- zval_dtor(op1);
- }
- if (use_copy2) {
- zval_dtor(op2);
- }
+ STR_RELEASE(str1);
+ STR_RELEASE(str2);
return SUCCESS;
}
/* }}} */
@@ -1595,31 +1587,13 @@ ZEND_API int string_case_compare_function(zval *result, zval *op1, zval *op2 TSR
#if HAVE_STRCOLL
ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
- zval op1_copy, op2_copy;
- int use_copy1 = 0, use_copy2 = 0;
-
- if (Z_TYPE_P(op1) != IS_STRING) {
- zend_make_printable_zval(op1, &op1_copy, &use_copy1);
- }
- if (Z_TYPE_P(op2) != IS_STRING) {
- zend_make_printable_zval(op2, &op2_copy, &use_copy2);
- }
-
- if (use_copy1) {
- op1 = &op1_copy;
- }
- if (use_copy2) {
- op2 = &op2_copy;
- }
+ zend_string *str1 = zval_get_string(op1 TSRMLS_CC),
+ *str2 = zval_get_string(op2 TSRMLS_CC);
- ZVAL_LONG(result, strcoll(Z_STRVAL_P(op1), Z_STRVAL_P(op2)));
+ ZVAL_LONG(result, strcoll(str1->val, str2->val));
- if (use_copy1) {
- zval_dtor(op1);
- }
- if (use_copy2) {
- zval_dtor(op2);
- }
+ STR_RELEASE(str1);
+ STR_RELEASE(str2);
return SUCCESS;
}
/* }}} */
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index c062cd5e19..9df4a68933 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -370,6 +370,7 @@ ZEND_API int zend_binary_strcmp(const char *s1, uint len1, const char *s2, uint
ZEND_API int zend_binary_strncmp(const char *s1, uint len1, const char *s2, uint len2, uint length);
ZEND_API int zend_binary_strcasecmp(const char *s1, uint len1, const char *s2, uint len2);
ZEND_API int zend_binary_strncasecmp(const char *s1, uint len1, const char *s2, uint len2, uint length);
+ZEND_API int zend_binary_strcasecmp_l(const char *s1, uint len1, const char *s2, uint len2);
ZEND_API int zend_binary_strncasecmp_l(const char *s1, uint len1, const char *s2, uint len2, uint length);
ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2);
diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c
index 32fb706982..5557c7beea 100644
--- a/Zend/zend_variables.c
+++ b/Zend/zend_variables.c
@@ -270,16 +270,14 @@ ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC)
}
-ZEND_API int zend_print_variable(zval *var)
+ZEND_API int zend_print_variable(zval *var TSRMLS_DC)
{
- return zend_print_zval(var, 0);
+ return zend_print_zval(var, 0 TSRMLS_CC);
}
ZEND_API void _zval_dtor_wrapper(zval *zvalue)
{
- TSRMLS_FETCH();
-
zval_dtor(zvalue);
}
diff --git a/Zend/zend_variables.h b/Zend/zend_variables.h
index 686c57ecf2..b85ef435ca 100644
--- a/Zend/zend_variables.h
+++ b/Zend/zend_variables.h
@@ -64,7 +64,7 @@ static zend_always_inline void _zval_opt_copy_ctor(zval *zvalue ZEND_FILE_LINE_D
ZEND_API int zval_copy_static_var(zval *p TSRMLS_DC, int num_args, va_list args, zend_hash_key *key);
-ZEND_API int zend_print_variable(zval *var);
+ZEND_API int zend_print_variable(zval *var TSRMLS_DC);
ZEND_API void _zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC);
ZEND_API void _zval_internal_dtor_for_ptr(zval *zvalue ZEND_FILE_LINE_DC);
ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC);
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 3c39e3c6c1..8f2c37601c 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -1092,7 +1092,7 @@ ZEND_VM_HANDLER(40, ZEND_ECHO, CONST|TMP|VAR|CV, ANY)
SAVE_OPLINE();
z = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
- zend_print_variable(z);
+ zend_print_variable(z TSRMLS_CC);
FREE_OP1();
CHECK_EXCEPTION();
@@ -4664,7 +4664,7 @@ ZEND_VM_HANDLER(79, ZEND_EXIT, CONST|TMP|VAR|UNUSED|CV, ANY)
if (Z_TYPE_P(ptr) == IS_LONG) {
EG(exit_status) = Z_LVAL_P(ptr);
} else {
- zend_print_variable(ptr);
+ zend_print_variable(ptr TSRMLS_CC);
}
FREE_OP1();
}
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index e60451e72f..0dc6eda1a7 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -2337,7 +2337,7 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
SAVE_OPLINE();
z = opline->op1.zv;
- zend_print_variable(z);
+ zend_print_variable(z TSRMLS_CC);
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
@@ -3135,7 +3135,7 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
if (Z_TYPE_P(ptr) == IS_LONG) {
EG(exit_status) = Z_LVAL_P(ptr);
} else {
- zend_print_variable(ptr);
+ zend_print_variable(ptr TSRMLS_CC);
}
}
@@ -7298,7 +7298,7 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
SAVE_OPLINE();
z = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
- zend_print_variable(z);
+ zend_print_variable(z TSRMLS_CC);
zval_dtor(free_op1.var);
CHECK_EXCEPTION();
@@ -8084,7 +8084,7 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
if (Z_TYPE_P(ptr) == IS_LONG) {
EG(exit_status) = Z_LVAL_P(ptr);
} else {
- zend_print_variable(ptr);
+ zend_print_variable(ptr TSRMLS_CC);
}
zval_dtor(free_op1.var);
}
@@ -12195,7 +12195,7 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
SAVE_OPLINE();
z = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
- zend_print_variable(z);
+ zend_print_variable(z TSRMLS_CC);
zval_ptr_dtor_nogc(free_op1.var);
CHECK_EXCEPTION();
@@ -13242,7 +13242,7 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
if (Z_TYPE_P(ptr) == IS_LONG) {
EG(exit_status) = Z_LVAL_P(ptr);
} else {
- zend_print_variable(ptr);
+ zend_print_variable(ptr TSRMLS_CC);
}
zval_ptr_dtor_nogc(free_op1.var);
}
@@ -23011,7 +23011,7 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS
if (Z_TYPE_P(ptr) == IS_LONG) {
EG(exit_status) = Z_LVAL_P(ptr);
} else {
- zend_print_variable(ptr);
+ zend_print_variable(ptr TSRMLS_CC);
}
}
@@ -28752,7 +28752,7 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
SAVE_OPLINE();
z = _get_zval_ptr_cv_deref_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC);
- zend_print_variable(z);
+ zend_print_variable(z TSRMLS_CC);
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
@@ -29632,7 +29632,7 @@ static int ZEND_FASTCALL ZEND_EXIT_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
if (Z_TYPE_P(ptr) == IS_LONG) {
EG(exit_status) = Z_LVAL_P(ptr);
} else {
- zend_print_variable(ptr);
+ zend_print_variable(ptr TSRMLS_CC);
}
}
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 0ef31460bd..b78311868a 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -655,23 +655,13 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
/* {{{ _const_string */
static void _const_string(string *str, char *name, zval *value, char *indent TSRMLS_DC)
{
- char *type;
- zval value_copy;
- int use_copy;
-
- type = zend_zval_type_name(value);
-
- zend_make_printable_zval(value, &value_copy, &use_copy);
- if (use_copy) {
- value = &value_copy;
- }
+ char *type = zend_zval_type_name(value);
+ zend_string *value_str = zval_get_string(value TSRMLS_CC);
string_printf(str, "%s Constant [ %s %s ] { %s }\n",
- indent, type, name, Z_STRVAL_P(value));
+ indent, type, name, value_str->val);
- if (use_copy) {
- zval_dtor(value);
- }
+ STR_RELEASE(value_str);
}
/* }}} */
@@ -728,8 +718,7 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg
if (fptr->type == ZEND_USER_FUNCTION && offset >= required) {
zend_op *precv = _get_recv_op((zend_op_array*)fptr, offset);
if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2_type != IS_UNUSED) {
- zval zv, zv_copy;
- int use_copy;
+ zval zv;
string_write(str, " = ", sizeof(" = ")-1);
ZVAL_DUP(&zv, precv->op2.zv);
zval_update_constant_ex(&zv, (void*)1, fptr->common.scope TSRMLS_CC);
@@ -751,11 +740,9 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg
} else if (Z_TYPE(zv) == IS_ARRAY) {
string_write(str, "Array", sizeof("Array")-1);
} else {
- zend_make_printable_zval(&zv, &zv_copy, &use_copy);
- string_write(str, Z_STRVAL(zv_copy), Z_STRLEN(zv_copy));
- if (use_copy) {
- zval_dtor(&zv_copy);
- }
+ zend_string *zv_str = zval_get_string(&zv);
+ string_write(str, zv_str->val, zv_str->len);
+ STR_RELEASE(zv_str);
}
zval_ptr_dtor(&zv);
}
@@ -1529,7 +1516,7 @@ ZEND_METHOD(reflection, export)
ZVAL_COPY_VALUE(return_value, &retval);
} else {
/* No need for _r variant, return of __toString should always be a string */
- zend_print_zval(&retval, 0);
+ zend_print_zval(&retval, 0 TSRMLS_CC);
zend_printf("\n");
zval_ptr_dtor(&retval);
}
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c
index 622fbfbb3f..b08b06fac5 100644
--- a/ext/standard/formatted_print.c
+++ b/ext/standard/formatted_print.c
@@ -559,24 +559,14 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC)
switch (format[inpos]) {
case 's': {
- zval *var, var_copy;
- int use_copy;
-
- zend_make_printable_zval(&tmp, &var_copy, &use_copy);
- if (use_copy) {
- var = &var_copy;
- } else {
- var = &tmp;
- }
+ zend_string *str = zval_get_string(&tmp TSRMLS_CC);
php_sprintf_appendstring(&result, &outpos,
- Z_STRVAL_P(var),
+ str->val,
width, precision, padding,
alignment,
- Z_STRLEN_P(var),
+ str->len,
0, expprec, 0);
- if (use_copy) {
- zval_dtor(&var_copy);
- }
+ STR_RELEASE(str);
break;
}
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 6f699e22c4..fe6d30f18a 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -4956,31 +4956,13 @@ static void php_strnatcmp(INTERNAL_FUNCTION_PARAMETERS, int fold_case)
PHPAPI int string_natural_compare_function_ex(zval *result, zval *op1, zval *op2, zend_bool case_insensitive TSRMLS_DC) /* {{{ */
{
- zval op1_copy, op2_copy;
- int use_copy1 = 0, use_copy2 = 0;
+ zend_string *str1 = zval_get_string(op1 TSRMLS_CC),
+ *str2 = zval_get_string(op2 TSRMLS_CC);
- if (Z_TYPE_P(op1) != IS_STRING) {
- zend_make_printable_zval(op1, &op1_copy, &use_copy1);
- }
- if (Z_TYPE_P(op2) != IS_STRING) {
- zend_make_printable_zval(op2, &op2_copy, &use_copy2);
- }
-
- if (use_copy1) {
- op1 = &op1_copy;
- }
- if (use_copy2) {
- op2 = &op2_copy;
- }
-
- ZVAL_LONG(result, strnatcmp_ex(Z_STRVAL_P(op1), Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2), case_insensitive));
+ ZVAL_LONG(result, strnatcmp_ex(str1->val, str1->len, str2->val, str2->len, case_insensitive));
- if (use_copy1) {
- zval_dtor(op1);
- }
- if (use_copy2) {
- zval_dtor(op2);
- }
+ STR_RELEASE(str1);
+ STR_RELEASE(str2);
return SUCCESS;
}
/* }}} */
diff --git a/ext/standard/type.c b/ext/standard/type.c
index c4fdbc87e3..1e3572c22f 100644
--- a/ext/standard/type.c
+++ b/ext/standard/type.c
@@ -195,21 +195,12 @@ PHP_FUNCTION(boolval)
Get the string value of a variable */
PHP_FUNCTION(strval)
{
- zval *num, *tmp;
- zval expr_copy;
- int use_copy;
-
+ zval *num;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &num) == FAILURE) {
return;
}
- zend_make_printable_zval(num, &expr_copy, &use_copy);
- if (use_copy) {
- tmp = &expr_copy;
- RETVAL_ZVAL(tmp, 0, 0);
- } else {
- RETVAL_ZVAL(num, 1, 0);
- }
+ RETVAL_STR(zval_get_string(num));
}
/* }}} */
diff --git a/sapi/phpdbg/phpdbg_info.c b/sapi/phpdbg/phpdbg_info.c
index f7c7ab0846..5596255d6e 100644
--- a/sapi/phpdbg/phpdbg_info.c
+++ b/sapi/phpdbg/phpdbg_info.c
@@ -215,7 +215,7 @@ PHPDBG_INFO(literal) /* {{{ */
if (Z_TYPE(ops->literals[literal]) != IS_NULL) {
phpdbg_write("|-------- C%u -------> [", literal);
zend_print_zval(
- &ops->literals[literal], 0);
+ &ops->literals[literal], 0 TSRMLS_CC);
phpdbg_write("]");
phpdbg_writeln(EMPTY);
}