summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/bz2/bz2_filter.c4
-rw-r--r--ext/date/php_date.c4
-rw-r--r--ext/dom/xpath.c4
-rw-r--r--ext/ldap/ldap.c4
-rw-r--r--ext/mysql/php_mysql.c2
-rw-r--r--ext/mysqli/mysqli.c2
-rw-r--r--ext/opcache/Optimizer/block_pass.c20
-rw-r--r--ext/opcache/Optimizer/compact_literals.c37
-rw-r--r--ext/opcache/Optimizer/pass1_5.c10
-rw-r--r--ext/opcache/ZendAccelerator.c3
-rw-r--r--ext/pdo/pdo_dbh.c2
-rw-r--r--ext/pdo/pdo_sql_parser.c3
-rw-r--r--ext/pdo/pdo_sql_parser.re3
-rw-r--r--ext/pdo/pdo_stmt.c2
-rw-r--r--ext/reflection/php_reflection.c10
-rw-r--r--ext/session/session.c2
-rw-r--r--ext/simplexml/simplexml.c10
-rw-r--r--ext/sockets/multicast.c6
-rw-r--r--ext/spl/spl_array.c63
-rw-r--r--ext/spl/spl_directory.c2
-rw-r--r--ext/spl/spl_engine.c8
-rw-r--r--ext/spl/spl_iterators.c6
-rw-r--r--ext/spl/spl_observer.c6
-rw-r--r--ext/standard/array.c8
-rw-r--r--ext/standard/assert.c4
-rw-r--r--ext/standard/file.c3
-rw-r--r--ext/standard/filters.c4
-rw-r--r--ext/standard/http.c7
-rw-r--r--ext/standard/password.c3
-rw-r--r--ext/standard/string.c12
-rw-r--r--ext/standard/type.c15
-rw-r--r--ext/standard/user_filters.c2
-rw-r--r--ext/standard/var.c35
-rw-r--r--ext/xmlrpc/xmlrpc-epi-php.c2
34 files changed, 187 insertions, 121 deletions
diff --git a/ext/bz2/bz2_filter.c b/ext/bz2/bz2_filter.c
index b31ab3c261..b6d8787274 100644
--- a/ext/bz2/bz2_filter.c
+++ b/ext/bz2/bz2_filter.c
@@ -358,7 +358,7 @@ static php_stream_filter *php_bz2_filter_create(const char *filtername, zval *fi
zval_copy_ctor(&tmp);
tmp2 = &tmp;
convert_to_boolean_ex(&tmp2);
- data->expect_concatenated = Z_LVAL(tmp);
+ data->expect_concatenated = Z_TMP(tmp) == IS_TRUE;
tmpzval = NULL;
}
@@ -374,7 +374,7 @@ static php_stream_filter *php_bz2_filter_create(const char *filtername, zval *fi
zval_copy_ctor(&tmp);
tmp2 = &tmp;
convert_to_boolean_ex(&tmp2);
- data->small_footprint = Z_LVAL(tmp);
+ data->small_footprint = Z_TYPE(tmp) == IS_TRUE;
}
}
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index a0a189bbe4..439621f5e5 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -4888,8 +4888,8 @@ static int php_date_period_initialize_from_hash(php_period_obj *period_obj, Hash
ht_entry = zend_hash_str_find(myht, "include_start_date", sizeof("include_start_date")-1);
if (ht_entry &&
- Z_TYPE_P(ht_entry) == IS_BOOL) {
- period_obj->include_start_date = Z_BVAL_P(ht_entry);
+ (Z_TYPE_P(ht_entry) == IS_FALSE || Z_TYPE_P(ht_entry) == IS_TRUE)) {
+ period_obj->include_start_date = (Z_TYPE_P(ht_entry) == IS_TRUE);
} else {
return 0;
}
diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c
index 32adfe3b6f..8a7bf60f38 100644
--- a/ext/dom/xpath.c
+++ b/ext/dom/xpath.c
@@ -215,8 +215,8 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs,
obj = Z_XPATHOBJ_P(&retval);
nodep = dom_object_get_node(obj);
valuePush(ctxt, xmlXPathNewNodeSet(nodep));
- } else if (Z_TYPE(retval) == IS_BOOL) {
- valuePush(ctxt, xmlXPathNewBoolean(Z_BVAL(retval)));
+ } else if (Z_TYPE(retval) == IS_FALSE || Z_TYPE(retval) == IS_TRUE) {
+ valuePush(ctxt, xmlXPathNewBoolean(Z_TYPE(retval) == IS_TRUE));
} else if (Z_TYPE(retval) == IS_OBJECT) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "A PHP Object cannot be converted to a XPath-string");
valuePush(ctxt, xmlXPathNewString((xmlChar *)""));
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index 6e698640f7..eb7d405b63 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -2118,7 +2118,7 @@ PHP_FUNCTION(ldap_set_option)
{
void *val;
convert_to_boolean_ex(newval);
- val = Z_LVAL_PP(newval)
+ val = Z_TYPE_PP(newval) == IS_TRUE
? LDAP_OPT_ON : LDAP_OPT_OFF;
if (ldap_set_option(ldap, option, val)) {
RETURN_FALSE;
@@ -2165,7 +2165,7 @@ PHP_FUNCTION(ldap_set_option)
}
if (zend_hash_find(Z_ARRVAL_PP(ctrlval), "iscritical", sizeof("iscritical"), (void **) &val) == SUCCESS) {
convert_to_boolean_ex(val);
- ctrl->ldctl_iscritical = Z_BVAL_PP(val);
+ ctrl->ldctl_iscritical = Z_TYPE_PP(val) == IS_TRUE;
} else {
ctrl->ldctl_iscritical = 0;
}
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index 56dcf7b373..9f7f07d038 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -2165,7 +2165,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type,
#ifdef ZEND_ENGINE_2
/* mysqlnd might return FALSE if no more rows */
- if (into_object && Z_TYPE_P(return_value) != IS_BOOL) {
+ if (into_object && Z_TYPE_P(return_value) != IS_FALSE) {
zval dataset;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index c3162f6f8f..8f5b5c14e4 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -425,7 +425,7 @@ static int mysqli_object_has_property(zval *object, zval *member, int has_set_ex
zval *value = mysqli_read_property(object, member, BP_VAR_IS, key TSRMLS_CC);
if (value != EG(uninitialized_zval_ptr)) {
convert_to_boolean(value);
- ret = Z_BVAL_P(value)? 1:0;
+ ret = Z_TYPE_P(value) == IS_TRUE ? 1 : 0;
/* refcount is 0 */
Z_ADDREF_P(value);
zval_ptr_dtor(&value);
diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c
index 51ab3cd97b..f108012bbd 100644
--- a/ext/opcache/Optimizer/block_pass.c
+++ b/ext/opcache/Optimizer/block_pass.c
@@ -792,16 +792,28 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array,
opline->opcode == ZEND_IS_NOT_EQUAL ||
opline->opcode == ZEND_CASE) {
if (ZEND_OP1_TYPE(opline) == IS_CONST &&
- Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_BOOL) {
+// TODO: Optimization of comparison with null may be not safe ???
+#if 1
+ (Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_FALSE ||
+ Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_TRUE)) {
+#else
+ Z_TYPE(ZEND_OP1_LITERAL(opline)) <= IS_TRUE) {
+#endif
opline->opcode =
- ((opline->opcode != ZEND_IS_NOT_EQUAL) == Z_LVAL(ZEND_OP1_LITERAL(opline)))?
+ ((opline->opcode != ZEND_IS_NOT_EQUAL) == ((Z_TYPE(ZEND_OP1_LITERAL(opline))) == IS_TRUE)) ?
ZEND_BOOL : ZEND_BOOL_NOT;
COPY_NODE(opline->op1, opline->op2);
SET_UNUSED(opline->op2);
} else if (ZEND_OP2_TYPE(opline) == IS_CONST &&
- Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_BOOL) {
+// TODO: Optimization of comparison with null may be not safe ???
+#if 1
+ (Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_FALSE ||
+ Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_TRUE)) {
+#else
+ Z_TYPE(ZEND_OP2_LITERAL(opline)) <= IS_TRUE) {
+#endif
opline->opcode =
- ((opline->opcode != ZEND_IS_NOT_EQUAL) == Z_LVAL(ZEND_OP2_LITERAL(opline)))?
+ ((opline->opcode != ZEND_IS_NOT_EQUAL) == ((Z_TYPE(ZEND_OP2_LITERAL(opline))) == IS_TRUE)) ?
ZEND_BOOL : ZEND_BOOL_NOT;
SET_UNUSED(opline->op2);
}
diff --git a/ext/opcache/Optimizer/compact_literals.c b/ext/opcache/Optimizer/compact_literals.c
index 04183292d6..8c562f887a 100644
--- a/ext/opcache/Optimizer/compact_literals.c
+++ b/ext/opcache/Optimizer/compact_literals.c
@@ -300,28 +300,27 @@ static void optimizer_compact_literals(zend_op_array *op_array TSRMLS_DC)
}
map[i] = l_null;
break;
- case IS_BOOL:
- if (Z_LVAL(op_array->literals[i])) {
- if (l_true < 0) {
- l_true = j;
- if (i != j) {
- op_array->literals[j] = op_array->literals[i];
- info[j] = info[i];
- }
- j++;
+ case IS_FALSE:
+ if (l_false < 0) {
+ l_false = j;
+ if (i != j) {
+ op_array->literals[j] = op_array->literals[i];
+ info[j] = info[i];
}
- map[i] = l_true;
- } else {
- if (l_false < 0) {
- l_false = j;
- if (i != j) {
- op_array->literals[j] = op_array->literals[i];
- info[j] = info[i];
- }
- j++;
+ j++;
+ }
+ map[i] = l_false;
+ break;
+ case IS_TRUE:
+ if (l_true < 0) {
+ l_true = j;
+ if (i != j) {
+ op_array->literals[j] = op_array->literals[i];
+ info[j] = info[i];
}
- map[i] = l_false;
+ j++;
}
+ map[i] = l_true;
break;
case IS_LONG:
if ((pos = (int)zend_hash_index_find_ptr(&hash, Z_LVAL(op_array->literals[i]))) != 0) {
diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c
index cae7e80375..2ec3931907 100644
--- a/ext/opcache/Optimizer/pass1_5.c
+++ b/ext/opcache/Optimizer/pass1_5.c
@@ -82,7 +82,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
case IS_NULL:
convert_to_null(&res);
break;
- case IS_BOOL:
+ case _IS_BOOL:
convert_to_boolean(&res);
break;
case IS_LONG:
@@ -104,7 +104,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
} else /* if (opline->result_type == IS_VAR) */ {
replace_var_by_const(op_array, opline + 1, tv, &res TSRMLS_CC);
}
- } else if (opline->extended_value == IS_BOOL) {
+ } else if (opline->extended_value == _IS_BOOL) {
/* T = CAST(X, IS_BOOL) => T = BOOL(X) */
opline->opcode = ZEND_BOOL;
opline->extended_value = 0;
@@ -327,8 +327,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
zend_binary_strcasecmp(Z_STRVAL(ZEND_OP1_LITERAL(opline)), Z_STRLEN(ZEND_OP1_LITERAL(opline)), "define", sizeof("define")-1) == 0 &&
(opline-1)->opcode == ZEND_SEND_VAL &&
ZEND_OP1_TYPE(opline-1) == IS_CONST &&
- (Z_TYPE(ZEND_OP1_LITERAL(opline-1)) <= IS_BOOL ||
- Z_TYPE(ZEND_OP1_LITERAL(opline-1)) == IS_STRING) &&
+ Z_TYPE(ZEND_OP1_LITERAL(opline-1)) <= IS_STRING &&
(opline-2)->opcode == ZEND_SEND_VAL &&
ZEND_OP1_TYPE(opline-2) == IS_CONST &&
Z_TYPE(ZEND_OP1_LITERAL(opline-2)) == IS_STRING) {
@@ -449,8 +448,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
case ZEND_DECLARE_CONST:
if (collect_constants &&
Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_STRING &&
- (Z_TYPE(ZEND_OP2_LITERAL(opline)) <= IS_BOOL ||
- Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING)) {
+ Z_TYPE(ZEND_OP2_LITERAL(opline)) <= IS_STRING) {
zend_optimizer_collect_constant(constants, &ZEND_OP1_LITERAL(opline), &ZEND_OP2_LITERAL(opline));
}
break;
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index bf951ff72a..11a1dc2ce7 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -2250,7 +2250,8 @@ static void accel_fast_zval_dtor(zval *zvalue)
break;
case IS_LONG:
case IS_DOUBLE:
- case IS_BOOL:
+ case IS_FALSE:
+ case IS_TRUE:
case IS_NULL:
case IS_STRING:
case IS_CONSTANT:
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index 73431049d6..d75ae21dcd 100644
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -695,7 +695,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D
{
#define PDO_LONG_PARAM_CHECK \
- if (Z_TYPE_P(value) != IS_LONG && Z_TYPE_P(value) != IS_STRING && Z_TYPE_P(value) != IS_BOOL) { \
+ if (Z_TYPE_P(value) != IS_LONG && Z_TYPE_P(value) != IS_STRING && Z_TYPE_P(value) != IS_FALSE && Z_TYPE_P(value) != IS_TRUE) { \
pdo_raise_impl_error(dbh, NULL, "HY000", "attribute value must be an integer" TSRMLS_CC); \
PDO_HANDLE_DBH_ERR(); \
return FAILURE; \
diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c
index be2fa35501..4420fcf97c 100644
--- a/ext/pdo/pdo_sql_parser.c
+++ b/ext/pdo/pdo_sql_parser.c
@@ -594,7 +594,8 @@ safe:
plc->freeq = 0;
break;
- case IS_BOOL:
+ case IS_FALSE:
+ case IS_TRUE:
convert_to_long(&tmp_param);
/* fall through */
case IS_LONG:
diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re
index e182bf65d1..883a22c7ff 100644
--- a/ext/pdo/pdo_sql_parser.re
+++ b/ext/pdo/pdo_sql_parser.re
@@ -236,7 +236,8 @@ safe:
plc->freeq = 0;
break;
- case IS_BOOL:
+ case IS_FALSE:
+ case IS_TRUE:
convert_to_long(&tmp_param);
/* fall through */
case IS_LONG:
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 8ec246926c..3fbe29cc76 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -327,7 +327,7 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s
} else {
convert_to_string(parameter);
}
- } else if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_INT && Z_TYPE_P(parameter) == IS_BOOL) {
+ } else if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_INT && (Z_TYPE_P(parameter) == IS_FALSE || Z_TYPE_P(parameter) == IS_TRUE)) {
convert_to_long(parameter);
} else if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_BOOL && Z_TYPE_P(parameter) == IS_LONG) {
convert_to_boolean(parameter);
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index c3f02fe079..f16c39272d 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -725,12 +725,10 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg
string_write(str, " = ", sizeof(" = ")-1);
ZVAL_DUP(&zv, precv->op2.zv);
zval_update_constant_ex(&zv, 1, fptr->common.scope TSRMLS_CC);
- if (Z_TYPE(zv) == IS_BOOL) {
- if (Z_LVAL(zv)) {
- string_write(str, "true", sizeof("true")-1);
- } else {
- string_write(str, "false", sizeof("false")-1);
- }
+ if (Z_TYPE(zv) == IS_TRUE) {
+ string_write(str, "true", sizeof("true")-1);
+ } else if (Z_TYPE(zv) == IS_FALSE) {
+ string_write(str, "false", sizeof("false")-1);
} else if (Z_TYPE(zv) == IS_NULL) {
string_write(str, "NULL", sizeof("NULL")-1);
} else if (Z_TYPE(zv) == IS_STRING) {
diff --git a/ext/session/session.c b/ext/session/session.c
index 8784016db6..f910d0cf37 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -2598,7 +2598,7 @@ static zend_bool php_check_cancel_upload(php_session_rfc1867_progress *progress
if ((cancel_upload = zend_hash_str_find(Z_ARRVAL_P(progress_ary), "cancel_upload", sizeof("cancel_upload") - 1)) == NULL) {
return 0;
}
- return Z_TYPE_P(cancel_upload) == IS_BOOL && Z_LVAL_P(cancel_upload);
+ return Z_TYPE_P(cancel_upload) == IS_TRUE;
} /* }}} */
static void php_session_rfc1867_update(php_session_rfc1867_progress *progress, int force_update TSRMLS_DC) /* {{{ */
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 31beb1a9f0..403b7afc4e 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -411,7 +411,8 @@ static void change_node_zval(xmlNodePtr node, zval *value TSRMLS_DC)
}
switch (Z_TYPE_P(value)) {
case IS_LONG:
- case IS_BOOL:
+ case IS_FALSE:
+ case IS_TRUE:
case IS_DOUBLE:
case IS_NULL:
if (Z_REFCOUNT_P(value) > 1) {
@@ -525,7 +526,8 @@ static int sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bool
if (value) {
switch (Z_TYPE_P(value)) {
case IS_LONG:
- case IS_BOOL:
+ case IS_FALSE:
+ case IS_TRUE:
case IS_DOUBLE:
case IS_NULL:
convert_to_string(value);
@@ -1754,7 +1756,7 @@ static int cast_object(zval *object, int type, char *contents TSRMLS_DC)
case IS_STRING:
convert_to_string(object);
break;
- case IS_BOOL:
+ case _IS_BOOL:
convert_to_boolean(object);
break;
case IS_LONG:
@@ -1782,7 +1784,7 @@ static int sxe_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC)
sxe = Z_SXEOBJ_P(readobj);
- if (type == IS_BOOL) {
+ if (type == _IS_BOOL) {
node = php_sxe_get_first_node(sxe, NULL TSRMLS_CC);
prop_hash = sxe_get_prop_hash(readobj, 1 TSRMLS_CC);
ZVAL_BOOL(writeobj, node != NULL || zend_hash_num_elements(prop_hash) > 0);
diff --git a/ext/sockets/multicast.c b/ext/sockets/multicast.c
index dc3151a137..ec8e16ce45 100644
--- a/ext/sockets/multicast.c
+++ b/ext/sockets/multicast.c
@@ -282,6 +282,7 @@ int php_do_setsockopt_ip_mcast(php_socket *php_sock,
case IP_MULTICAST_LOOP:
convert_to_boolean_ex(arg4);
+ ipv4_mcast_ttl_lback = (unsigned char) (Z_TYPE_PP(arg4) == IS_TRUE);
goto ipv4_loop_ttl;
case IP_MULTICAST_TTL:
@@ -291,8 +292,8 @@ int php_do_setsockopt_ip_mcast(php_socket *php_sock,
"Expected a value between 0 and 255");
return FAILURE;
}
-ipv4_loop_ttl:
ipv4_mcast_ttl_lback = (unsigned char) Z_LVAL_PP(arg4);
+ipv4_loop_ttl:
opt_ptr = &ipv4_mcast_ttl_lback;
optlen = sizeof(ipv4_mcast_ttl_lback);
goto dosockopt;
@@ -347,6 +348,7 @@ int php_do_setsockopt_ipv6_mcast(php_socket *php_sock,
case IPV6_MULTICAST_LOOP:
convert_to_boolean_ex(arg4);
+ ov = (int) Z_TYPE_PP(arg4) == IS_TRUE;
goto ipv6_loop_hops;
case IPV6_MULTICAST_HOPS:
convert_to_long_ex(arg4);
@@ -355,8 +357,8 @@ int php_do_setsockopt_ipv6_mcast(php_socket *php_sock,
"Expected a value between -1 and 255");
return FAILURE;
}
-ipv6_loop_hops:
ov = (int) Z_LVAL_PP(arg4);
+ipv6_loop_hops:
opt_ptr = &ov;
optlen = sizeof(ov);
goto dosockopt;
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 0baba586ce..67b4f886c6 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -366,7 +366,12 @@ fetch_dim_string:
case IS_DOUBLE:
index = (long)Z_DVAL_P(offset);
goto num_index;
- case IS_BOOL:
+ case IS_FALSE:
+ index = 0;
+ goto num_index;
+ case IS_TRUE:
+ index = 1;
+ goto num_index;
case IS_LONG:
index = Z_LVAL_P(offset);
num_index:
@@ -488,19 +493,25 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval
zend_symtable_update_ind(ht, Z_STR_P(offset), value);
return;
case IS_DOUBLE:
+ index = (long)Z_DVAL_P(offset);
+ goto num_index;
case IS_RESOURCE:
- case IS_BOOL:
+ index = Z_RES_HANDLE_P(offset);
+ goto num_index;
+ case IS_FALSE:
+ index = 0;
+ goto num_index;
+ case IS_TRUE:
+ index = 1;
+ goto num_index;
case IS_LONG:
+ index = Z_LVAL_P(offset);
+num_index:
ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
if (ht->u.v.nApplyCount > 0) {
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
return;
}
- if (Z_TYPE_P(offset) == IS_DOUBLE) {
- index = (long)Z_DVAL_P(offset);
- } else {
- index = Z_LVAL_P(offset);
- }
zend_hash_index_update(ht, index, value);
return;
case IS_NULL:
@@ -574,21 +585,27 @@ static void spl_array_unset_dimension_ex(int check_inherited, zval *object, zval
}
break;
case IS_DOUBLE:
+ index = (long)Z_DVAL_P(offset);
+ goto num_index;
case IS_RESOURCE:
- case IS_BOOL:
+ index = Z_RES_HANDLE_P(offset);
+ goto num_index;
+ case IS_FALSE:
+ index = 0;
+ goto num_index;
+ case IS_TRUE:
+ index = 1;
+ goto num_index;
case IS_LONG:
- if (Z_TYPE_P(offset) == IS_DOUBLE) {
- index = (long)Z_DVAL_P(offset);
- } else {
- index = Z_LVAL_P(offset);
- }
+ index = Z_LVAL_P(offset);
+num_index:
ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
if (ht->u.v.nApplyCount > 0) {
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
return;
}
if (zend_hash_index_del(ht, index) == FAILURE) {
- zend_error(E_NOTICE,"Undefined offset: %ld", Z_LVAL_P(offset));
+ zend_error(E_NOTICE,"Undefined offset: %ld", index);
}
break;
default:
@@ -646,14 +663,20 @@ static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *o
}
break;
case IS_DOUBLE:
+ index = (long)Z_DVAL_P(offset);
+ goto num_index;
case IS_RESOURCE:
- case IS_BOOL:
+ index = Z_RES_HANDLE_P(offset);
+ goto num_index;
+ case IS_FALSE:
+ index = 0;
+ goto num_index;
+ case IS_TRUE:
+ index = 1;
+ goto num_index;
case IS_LONG:
- if (Z_TYPE_P(offset) == IS_DOUBLE) {
- index = (long)Z_DVAL_P(offset);
- } else {
- index = Z_LVAL_P(offset);
- }
+ index = Z_LVAL_P(offset);
+num_index:
if ((tmp = zend_hash_index_find(ht, index)) != NULL) {
if (check_empty == 2) {
return 1;
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index ca6c4adbb2..07d3d83b8e 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -265,7 +265,7 @@ static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_inclu
intern->type = SPL_FS_FILE;
php_stat(intern->file_name, intern->file_name_len, FS_IS_DIR, &tmp TSRMLS_CC);
- if (Z_LVAL(tmp)) {
+ if (Z_TYPE(tmp) == IS_TRUE) {
intern->u.file.open_mode = NULL;
intern->file_name = NULL;
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Cannot use SplFileObject with directories");
diff --git a/ext/spl/spl_engine.c b/ext/spl/spl_engine.c
index 3d12b04799..a2f3653432 100644
--- a/ext/spl/spl_engine.c
+++ b/ext/spl/spl_engine.c
@@ -48,10 +48,14 @@ PHPAPI long spl_offset_convert_to_long(zval *offset TSRMLS_DC) /* {{{ */
break;
case IS_DOUBLE:
return (long)Z_DVAL_P(offset);
- case IS_RESOURCE:
- case IS_BOOL:
case IS_LONG:
return Z_LVAL_P(offset);
+ case IS_FALSE:
+ return 0;
+ case IS_TRUE:
+ return 1;
+ case IS_RESOURCE:
+ return Z_RES_HANDLE_P(offset);
}
return -1;
}
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index cb7024d0a3..6d74169f24 100644
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -977,7 +977,7 @@ static void spl_recursive_tree_iterator_get_prefix(spl_recursive_it_object *obje
for (level = 0; level < object->level; ++level) {
zend_call_method_with_0_params(&object->iterators[level].zobject, object->iterators[level].ce, NULL, "hasnext", &has_next);
if (Z_TYPE(has_next) != IS_UNDEF) {
- if (Z_LVAL(has_next)) {
+ if (Z_TYPE(has_next) == IS_TRUE) {
smart_str_appendl(&str, object->prefix[1].s->val, object->prefix[1].s->len);
} else {
smart_str_appendl(&str, object->prefix[2].s->val, object->prefix[2].s->len);
@@ -987,7 +987,7 @@ static void spl_recursive_tree_iterator_get_prefix(spl_recursive_it_object *obje
}
zend_call_method_with_0_params(&object->iterators[level].zobject, object->iterators[level].ce, NULL, "hasnext", &has_next);
if (Z_TYPE(has_next) != IS_UNDEF) {
- if (Z_LVAL(has_next)) {
+ if (Z_TYPE(has_next) == IS_TRUE) {
smart_str_appendl(&str, object->prefix[3].s->val, object->prefix[3].s->len);
} else {
smart_str_appendl(&str, object->prefix[4].s->val, object->prefix[4].s->len);
@@ -2041,7 +2041,7 @@ SPL_METHOD(RegexIterator, accept)
}
if (intern->u.regex.flags & REGIT_INVERTED) {
- RETVAL_BOOL(! Z_LVAL_P(return_value));
+ RETVAL_BOOL(Z_TYPE_P(return_value) != IS_TRUE);
}
if (use_copy) {
diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c
index 4ddd86773e..110951d015 100644
--- a/ext/spl/spl_observer.c
+++ b/ext/spl/spl_observer.c
@@ -1064,7 +1064,7 @@ SPL_METHOD(MultipleIterator, attachIterator)
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
while ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) != NULL) {
is_identical_function(&compare_result, info, &element->inf TSRMLS_CC);
- if (Z_LVAL(compare_result)) {
+ if (Z_TYPE(compare_result) == IS_TRUE) {
zend_throw_exception(spl_ce_InvalidArgumentException, "Key duplication error", 0 TSRMLS_CC);
return;
}
@@ -1149,7 +1149,7 @@ SPL_METHOD(MultipleIterator, valid)
zend_call_method_with_0_params(it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs.zf_valid, "valid", &retval);
if (!ZVAL_IS_UNDEF(&retval)) {
- valid = Z_LVAL(retval);
+ valid = (Z_TYPE(retval) == IS_TRUE);
zval_ptr_dtor(&retval);
} else {
valid = 0;
@@ -1185,7 +1185,7 @@ static void spl_multiple_iterator_get_all(spl_SplObjectStorage *intern, int get_
zend_call_method_with_0_params(it, Z_OBJCE_P(it), &Z_OBJCE_P(it)->iterator_funcs.zf_valid, "valid", &retval);
if (!ZVAL_IS_UNDEF(&retval)) {
- valid = Z_LVAL(retval);
+ valid = Z_TYPE(retval) == IS_TRUE;
zval_ptr_dtor(&retval);
} else {
valid = 0;
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 3d587fa98e..eb8a9cd325 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -933,7 +933,7 @@ PHP_FUNCTION(min)
for (i = 1; i < argc; i++) {
is_smaller_function(&result, &args[i], min TSRMLS_CC);
- if (Z_LVAL(result) == 1) {
+ if (Z_TYPE(result) == IS_TRUE) {
min = &args[i];
}
}
@@ -980,7 +980,7 @@ PHP_FUNCTION(max)
for (i = 1; i < argc; i++) {
is_smaller_or_equal_function(&result, &args[i], max TSRMLS_CC);
- if (Z_LVAL(result) == 0) {
+ if (Z_TYPE(result) == IS_FALSE) {
max = &args[i];
}
}
@@ -1166,7 +1166,7 @@ static void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior) /* {{{
if (strict) {
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
is_identical_function(&res, value, entry TSRMLS_CC);
- if (Z_LVAL(res)) {
+ if (Z_TYPE(res) == IS_TRUE) {
if (behavior == 0) {
RETURN_TRUE;
} else {
@@ -1181,7 +1181,7 @@ static void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior) /* {{{
} ZEND_HASH_FOREACH_END();
} else {
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
- if (fast_equal_function(&res, value, entry TSRMLS_CC)) {
+ if (fast_equal_check_function(&res, value, entry TSRMLS_CC)) {
if (behavior == 0) {
RETURN_TRUE;
} else {
diff --git a/ext/standard/assert.c b/ext/standard/assert.c
index dab747c172..3ec7361197 100644
--- a/ext/standard/assert.c
+++ b/ext/standard/assert.c
@@ -183,10 +183,10 @@ PHP_FUNCTION(assert)
}
convert_to_boolean(&retval);
- val = Z_LVAL(retval);
+ val = Z_TYPE(retval) == IS_TRUE;
} else {
convert_to_boolean_ex(assertion);
- val = Z_LVAL_P(assertion);
+ val = Z_TYPE_P(assertion) == IS_TRUE;
}
if (val) {
diff --git a/ext/standard/file.c b/ext/standard/file.c
index c14a0d7f97..f8c3e98108 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -634,7 +634,8 @@ PHP_FUNCTION(file_put_contents)
case IS_NULL:
case IS_LONG:
case IS_DOUBLE:
- case IS_BOOL:
+ case IS_FALSE:
+ case IS_TRUE:
convert_to_string_ex(data);
case IS_STRING:
diff --git a/ext/standard/filters.c b/ext/standard/filters.c
index a77ca7fda6..d40321f959 100644
--- a/ext/standard/filters.c
+++ b/ext/standard/filters.c
@@ -1289,13 +1289,13 @@ static php_conv_err_t php_conv_get_bool_prop_ex(const HashTable *ht, int *pretva
if ((tmpval = zend_hash_str_find((HashTable *)ht, field_name, field_name_len-1)) != NULL) {
zval tmp;
- if (Z_TYPE_P(tmpval) != IS_BOOL) {
+ if (Z_TYPE_P(tmpval) != IS_FALSE || Z_TYPE_P(tmpval) != IS_TRUE) {
ZVAL_DUP(&tmp, tmpval);
zval_copy_ctor(&tmp);
convert_to_boolean(&tmp);
tmpval = &tmp;
}
- *pretval = Z_BVAL_P(tmpval);
+ *pretval = (Z_TYPE_P(tmpval) == IS_TRUE);
} else {
return PHP_CONV_ERR_NOT_FOUND;
}
diff --git a/ext/standard/http.c b/ext/standard/http.c
index fbda5ccc9e..20e4023fc7 100644
--- a/ext/standard/http.c
+++ b/ext/standard/http.c
@@ -183,7 +183,6 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
}
break;
case IS_LONG:
- case IS_BOOL:
{
char *ekey;
int ekey_len;
@@ -192,6 +191,12 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
efree(ekey);
}
break;
+ case IS_FALSE:
+ smart_str_appendl(formstr, "0", sizeof("0")-1);
+ break;
+ case IS_TRUE:
+ smart_str_appendl(formstr, "1", sizeof("1")-1);
+ break;
case IS_DOUBLE:
{
char *ekey;
diff --git a/ext/standard/password.c b/ext/standard/password.c
index 738bdcc7ac..aa50ab1f00 100644
--- a/ext/standard/password.c
+++ b/ext/standard/password.c
@@ -376,7 +376,8 @@ PHP_FUNCTION(password_hash)
}
zval_dtor(&cast_option_buffer);
}
- case IS_BOOL:
+ case IS_FALSE:
+ case IS_TRUE:
case IS_NULL:
case IS_RESOURCE:
case IS_ARRAY:
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 67c8001b5b..ebd667956a 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -1146,13 +1146,12 @@ again:
}
break;
- case IS_BOOL:
- if (Z_LVAL_P(tmp) == 1) {
- smart_str_appendl(&implstr, "1", sizeof("1")-1);
- }
+ case IS_TRUE:
+ smart_str_appendl(&implstr, "1", sizeof("1")-1);
break;
case IS_NULL:
+ case IS_FALSE:
break;
case IS_DOUBLE: {
@@ -1648,12 +1647,15 @@ static int php_needle_char(zval *needle, char *target TSRMLS_DC)
{
switch (Z_TYPE_P(needle)) {
case IS_LONG:
- case IS_BOOL:
*target = (char)Z_LVAL_P(needle);
return SUCCESS;
case IS_NULL:
+ case IS_FALSE:
*target = '\0';
return SUCCESS;
+ case IS_TRUE:
+ *target = '\1';
+ return SUCCESS;
case IS_DOUBLE:
*target = (char)(int)Z_DVAL_P(needle);
return SUCCESS;
diff --git a/ext/standard/type.c b/ext/standard/type.c
index 1e3572c22f..5c7da45ae9 100644
--- a/ext/standard/type.c
+++ b/ext/standard/type.c
@@ -36,7 +36,8 @@ PHP_FUNCTION(gettype)
RETVAL_STRING("NULL");
break;
- case IS_BOOL:
+ case IS_FALSE:
+ case IS_TRUE:
RETVAL_STRING("boolean");
break;
@@ -258,7 +259,14 @@ PHP_FUNCTION(is_resource)
Returns true if variable is a boolean */
PHP_FUNCTION(is_bool)
{
- php_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_BOOL);
+ zval *arg;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ ZVAL_DEREF(arg);
+ RETURN_BOOL(Z_TYPE_P(arg) == IS_FALSE || Z_TYPE_P(arg) == IS_TRUE);
}
/* }}} */
@@ -344,7 +352,8 @@ PHP_FUNCTION(is_scalar)
}
switch (Z_TYPE_P(arg)) {
- case IS_BOOL:
+ case IS_FALSE:
+ case IS_TRUE:
case IS_DOUBLE:
case IS_LONG:
case IS_STRING:
diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c
index 6945315903..23efacf5b8 100644
--- a/ext/standard/user_filters.c
+++ b/ext/standard/user_filters.c
@@ -363,7 +363,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
0, NULL TSRMLS_CC);
if (Z_TYPE(retval) != IS_UNDEF) {
- if (Z_TYPE(retval) == IS_BOOL && Z_LVAL(retval) == 0) {
+ if (Z_TYPE(retval) == IS_FALSE) {
/* User reported filter creation error "return false;" */
zval_ptr_dtor(&retval);
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 3dbd71abd5..b2e11bc9fc 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -129,8 +129,11 @@ PHPAPI void php_var_dump(zval *struc, int level TSRMLS_DC) /* {{{ */
again:
switch (Z_TYPE_P(struc)) {
- case IS_BOOL:
- php_printf("%sbool(%s)\n", COMMON, Z_LVAL_P(struc) ? "true" : "false");
+ case IS_FALSE:
+ php_printf("%sbool(false)\n", COMMON);
+ break;
+ case IS_TRUE:
+ php_printf("%sbool(true)\n", COMMON);
break;
case IS_NULL:
php_printf("%sNULL\n", COMMON);
@@ -304,8 +307,11 @@ PHPAPI void php_debug_zval_dump(zval *struc, int level TSRMLS_DC) /* {{{ */
again:
switch (Z_TYPE_P(struc)) {
- case IS_BOOL:
- php_printf("%sbool(%s)\n", COMMON, Z_LVAL_P(struc)?"true":"false");
+ case IS_FALSE:
+ php_printf("%sbool(false)\n", COMMON);
+ break;
+ case IS_TRUE:
+ php_printf("%sbool(true)\n", COMMON);
break;
case IS_NULL:
php_printf("%sNULL\n", COMMON);
@@ -491,12 +497,11 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf TSRMLS_DC)
again:
switch (Z_TYPE_P(struc)) {
- case IS_BOOL:
- if (Z_LVAL_P(struc)) {
- smart_str_appendl(buf, "true", 4);
- } else {
- smart_str_appendl(buf, "false", 5);
- }
+ case IS_FALSE:
+ smart_str_appendl(buf, "false", 5);
+ break;
+ case IS_TRUE:
+ smart_str_appendl(buf, "true", 4);
break;
case IS_NULL:
smart_str_appendl(buf, "NULL", 4);
@@ -828,10 +833,12 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var
again:
switch (Z_TYPE_P(struc)) {
- case IS_BOOL:
- smart_str_appendl(buf, "b:", 2);
- smart_str_append_long(buf, Z_LVAL_P(struc));
- smart_str_appendc(buf, ';');
+ case IS_FALSE:
+ smart_str_appendl(buf, "b:0;", 4);
+ return;
+
+ case IS_TRUE:
+ smart_str_appendl(buf, "b:1;", 4);
return;
case IS_NULL:
diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c
index 0d5d8b9d4c..3fb2ba6bb6 100644
--- a/ext/xmlrpc/xmlrpc-epi-php.c
+++ b/ext/xmlrpc/xmlrpc-epi-php.c
@@ -541,7 +541,7 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int dep
break;
case xmlrpc_boolean:
convert_to_boolean(val);
- xReturn = XMLRPC_CreateValueBoolean(key, Z_LVAL_P(val));
+ xReturn = XMLRPC_CreateValueBoolean(key, Z_TYPE_P(val) == IS_TRUE);
break;
case xmlrpc_int:
convert_to_long(val);