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;
}
}
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);
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);
}
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;
}
/* }}} */
#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;
}
/* }}} */
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);
/* {{{ _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);
}
/* }}} */
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);
} 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);
}
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;
}
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;
}
/* }}} */
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));
}
/* }}} */