version 1.1.1.1, 2012/02/21 23:48:02
|
version 1.1.1.4, 2014/06/15 20:03:57
|
Line 2
|
Line 2
|
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| PHP Version 5 | |
| PHP Version 5 | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Copyright (c) 1997-2012 The PHP Group | | | Copyright (c) 1997-2014 The PHP Group | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| This source file is subject to version 3.01 of the PHP license, | |
| This source file is subject to version 3.01 of the PHP license, | |
| that is bundled with this package in the file LICENSE, and is | |
| that is bundled with this package in the file LICENSE, and is | |
Line 136 PHP_MINFO_FUNCTION(assert) /* {{{ */
|
Line 136 PHP_MINFO_FUNCTION(assert) /* {{{ */
|
} |
} |
/* }}} */ |
/* }}} */ |
|
|
/* {{{ proto int assert(string|bool assertion) | /* {{{ proto int assert(string|bool assertion[, string description]) |
Checks if assertion is false */ |
Checks if assertion is false */ |
PHP_FUNCTION(assert) |
PHP_FUNCTION(assert) |
{ |
{ |
zval **assertion; |
zval **assertion; |
int val; | int val, description_len = 0; |
char *myeval = NULL; |
char *myeval = NULL; |
char *compiled_string_description; | char *compiled_string_description, *description = NULL; |
|
|
if (! ASSERTG(active)) { |
if (! ASSERTG(active)) { |
RETURN_TRUE; |
RETURN_TRUE; |
} |
} |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &assertion) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|s", &assertion, &description, &description_len) == FAILURE) { |
return; |
return; |
} |
} |
|
|
Line 167 PHP_FUNCTION(assert)
|
Line 167 PHP_FUNCTION(assert)
|
compiled_string_description = zend_make_compiled_string_description("assert code" TSRMLS_CC); |
compiled_string_description = zend_make_compiled_string_description("assert code" TSRMLS_CC); |
if (zend_eval_stringl(myeval, Z_STRLEN_PP(assertion), &retval, compiled_string_description TSRMLS_CC) == FAILURE) { |
if (zend_eval_stringl(myeval, Z_STRLEN_PP(assertion), &retval, compiled_string_description TSRMLS_CC) == FAILURE) { |
efree(compiled_string_description); |
efree(compiled_string_description); |
php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Failure evaluating code: %s%s", PHP_EOL, myeval); | if (description_len == 0) { |
| php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Failure evaluating code: %s%s", PHP_EOL, myeval); |
| } else { |
| php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Failure evaluating code: %s%s:\"%s\"", PHP_EOL, description, myeval); |
| } |
if (ASSERTG(bail)) { |
if (ASSERTG(bail)) { |
zend_bailout(); |
zend_bailout(); |
} |
} |
Line 196 PHP_FUNCTION(assert)
|
Line 200 PHP_FUNCTION(assert)
|
} |
} |
|
|
if (ASSERTG(callback)) { |
if (ASSERTG(callback)) { |
zval *args[3]; | zval **args = safe_emalloc(description_len == 0 ? 3 : 4, sizeof(zval **), 0); |
zval *retval; |
zval *retval; |
int i; |
int i; |
uint lineno = zend_get_executed_lineno(TSRMLS_C); |
uint lineno = zend_get_executed_lineno(TSRMLS_C); |
char *filename = zend_get_executed_filename(TSRMLS_C); | const char *filename = zend_get_executed_filename(TSRMLS_C); |
|
|
MAKE_STD_ZVAL(args[0]); |
MAKE_STD_ZVAL(args[0]); |
MAKE_STD_ZVAL(args[1]); |
MAKE_STD_ZVAL(args[1]); |
Line 214 PHP_FUNCTION(assert)
|
Line 218 PHP_FUNCTION(assert)
|
ZVAL_FALSE(retval); |
ZVAL_FALSE(retval); |
|
|
/* XXX do we want to check for error here? */ |
/* XXX do we want to check for error here? */ |
call_user_function(CG(function_table), NULL, ASSERTG(callback), retval, 3, args TSRMLS_CC); | if (description_len == 0) { |
| call_user_function(CG(function_table), NULL, ASSERTG(callback), retval, 3, args TSRMLS_CC); |
| for (i = 0; i <= 2; i++) { |
| zval_ptr_dtor(&(args[i])); |
| } |
| } else { |
| MAKE_STD_ZVAL(args[3]); |
| ZVAL_STRINGL(args[3], SAFE_STRING(description), description_len, 1); |
|
|
for (i = 0; i <= 2; i++) { | call_user_function(CG(function_table), NULL, ASSERTG(callback), retval, 4, args TSRMLS_CC); |
zval_ptr_dtor(&(args[i])); | for (i = 0; i <= 3; i++) { |
| zval_ptr_dtor(&(args[i])); |
| } |
} |
} |
|
|
|
efree(args); |
zval_ptr_dtor(&retval); |
zval_ptr_dtor(&retval); |
} |
} |
|
|
if (ASSERTG(warning)) { |
if (ASSERTG(warning)) { |
if (myeval) { | if (description_len == 0) { |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Assertion \"%s\" failed", myeval); | if (myeval) { |
| php_error_docref(NULL TSRMLS_CC, E_WARNING, "Assertion \"%s\" failed", myeval); |
| } else { |
| php_error_docref(NULL TSRMLS_CC, E_WARNING, "Assertion failed"); |
| } |
} else { |
} else { |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Assertion failed"); | if (myeval) { |
| php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s: \"%s\" failed", description, myeval); |
| } else { |
| php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s failed", description); |
| } |
} |
} |
} |
} |
|
|
Line 321 PHP_FUNCTION(assert_options)
|
Line 344 PHP_FUNCTION(assert_options)
|
* vim600: sw=4 ts=4 fdm=marker |
* vim600: sw=4 ts=4 fdm=marker |
* vim<600: sw=4 ts=4 |
* vim<600: sw=4 ts=4 |
*/ |
*/ |
|
|