summaryrefslogtreecommitdiff
path: root/Zend/zend_operators.c
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>1999-10-19 14:11:39 +0000
committerAndi Gutmans <andi@php.net>1999-10-19 14:11:39 +0000
commit70b41809f2386e87ccb6ae3d6d85c4e6cebc62e5 (patch)
tree727f48ce93192fb6e91c321f0658eaa5fbf38ea2 /Zend/zend_operators.c
parent24d2325ecb14f0a38e3e27d646dc36aa3006cbb5 (diff)
downloadphp-git-70b41809f2386e87ccb6ae3d6d85c4e6cebc62e5.tar.gz
- Fix is_identical function
Diffstat (limited to 'Zend/zend_operators.c')
-rw-r--r--Zend/zend_operators.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 2ef03fc2a5..46055dda52 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -916,21 +916,38 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2)
ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2)
{
+ result->type = IS_BOOL;
if (op1->type != op2->type) {
- convert_to_boolean(result);
result->value.lval = 0;
return SUCCESS;
}
- if (compare_function(result, op1, op2) == FAILURE) {
- return FAILURE;
- }
- convert_to_boolean(result);
- if (result->value.lval == 0) {
- result->value.lval = 1;
- } else {
- result->value.lval = 0;
+ switch (op1->type) {
+ case IS_BOOL:
+ case IS_LONG:
+ case IS_RESOURCE:
+ result->type = (op1->value.lval == op2->value.lval);
+ return SUCCESS;
+ break;
+ case IS_DOUBLE:
+ result->type = (op1->value.dval == op2->value.dval);
+ return SUCCESS;
+ break;
+ case IS_STRING:
+ if ((op1->value.str.len == op2->value.str.len)
+ && (!memcmp(op1->value.str.val, op2->value.str.val, op1->value.str.len))) {
+ result->value.lval = 1;
+ } else {
+ result->value.lval = 0;
+ }
+ return SUCCESS;
+ break;
+ case IS_ARRAY:
+ case IS_OBJECT:
+ zend_error(E_WARNING,"Cannot compare arrays or objects");
+ break;
}
- return SUCCESS;
+ var_reset(result);
+ return FAILURE;
}
ZEND_API int is_equal_function(zval *result, zval *op1, zval *op2)