Patch null_comparison_warning for Scripting Engine problem Bug #53104
Patch version 2012-04-26 20:51 UTC
Return to Bug #53104 |
Download this patch
Patch Revisions:
Developer: roeitell@gmail.com
/* {{{ proto mixed min(mixed arg1 [, mixed arg2 [, mixed ...]])
Return the lowest value in an array or a series of arguments */
PHP_FUNCTION(min)
{
int argc;
zval ***args = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args, &argc) == FAILURE) {
return;
}
php_set_compare_func(PHP_SORT_REGULAR TSRMLS_CC);
/* mixed min ( array $values ) */
if (argc == 1) {
zval **result;
if (Z_TYPE_PP(args[0]) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "When only one parameter is given, it must be an array");
RETVAL_NULL();
} else {
if (zend_hash_minmax(Z_ARRVAL_PP(args[0]), php_array_data_compare, 0, (void **) &result TSRMLS_CC) == SUCCESS) {
RETVAL_ZVAL(*result, 1, 0);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array must contain at least one element");
RETVAL_FALSE;
}
}
} else {
/* mixed min ( mixed $value1 , mixed $value2 [, mixed $value3... ] ) */
zval **min, result;
int i;
min = args[0];
for (i = 1; i < argc; i++) {
if (Z_TYPE_PP(args[i]) == IS_NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Recieved NULL parameter for comparison");
}
is_smaller_function(&result, *args[i], *min TSRMLS_CC);
if (Z_LVAL(result) == 1) {
min = args[i];
}
}
RETVAL_ZVAL(*min, 1, 0);
}
if (args) {
efree(args);
}
}
/* }}} */
/** ... snip ... **/
/* {{{ proto mixed max(mixed arg1 [, mixed arg2 [, mixed ...]])
Return the highest value in an array or a series of arguments */
PHP_FUNCTION(max)
{
zval ***args = NULL;
int argc;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args, &argc) == FAILURE) {
return;
}
php_set_compare_func(PHP_SORT_REGULAR TSRMLS_CC);
/* mixed max ( array $values ) */
if (argc == 1) {
zval **result;
if (Z_TYPE_PP(args[0]) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "When only one parameter is given, it must be an array");
RETVAL_NULL();
} else {
if (zend_hash_minmax(Z_ARRVAL_PP(args[0]), php_array_data_compare, 1, (void **) &result TSRMLS_CC) == SUCCESS) {
RETVAL_ZVAL(*result, 1, 0);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array must contain at least one element");
RETVAL_FALSE;
}
}
} else {
/* mixed max ( mixed $value1 , mixed $value2 [, mixed $value3... ] ) */
zval **max, result;
int i;
max = args[0];
for (i = 1; i < argc; i++) {
if (Z_TYPE_PP(args[i]) == IS_NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Recieved NULL parameter for comparison");
}
is_smaller_or_equal_function(&result, *args[i], *max TSRMLS_CC);
if (Z_LVAL(result) == 0) {
max = args[i];
}
}
RETVAL_ZVAL(*max, 1, 0);
}
if (args) {
efree(args);
}
}
/* }}} */
|