cvs: ZendEngine2 / zend_exceptions.c

From: Date: Wed, 22 Feb 2006 11:38:32 +0000
Subject: cvs: ZendEngine2 / zend_exceptions.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-4612@lists.php.net to get a copy of this message
dmitry Wed Feb 22 11:38:32 2006 UTC Modified files: /ZendEngine2 zend_exceptions.c Log: Unicode support: fixed __toString() in user defined exceptions http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_exceptions.c?r1=1.99&r2=1.100&diff_format=u Index: ZendEngine2/zend_exceptions.c diff -u ZendEngine2/zend_exceptions.c:1.99 ZendEngine2/zend_exceptions.c:1.100 --- ZendEngine2/zend_exceptions.c:1.99 Tue Feb 21 20:12:41 2006 +++ ZendEngine2/zend_exceptions.c Wed Feb 22 11:38:32 2006 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_exceptions.c,v 1.99 2006/02/21 20:12:41 dmitry Exp $ */ +/* $Id: zend_exceptions.c,v 1.100 2006/02/22 11:38:32 dmitry Exp $ */ #include "zend.h" #include "zend_API.h" @@ -757,11 +757,12 @@ zend_call_method_with_0_params(&exception, ce_exception, NULL, "__tostring", &str); if (!EG(exception)) { - if (Z_TYPE_P(str) != IS_STRING) { - zend_error(E_WARNING, "%v::__toString() must return a string", ce_exception->name); + if (Z_TYPE_P(str) == IS_UNICODE) { + zend_update_property_unicodel(default_exception_ce, exception, "string", sizeof("string")-1, Z_USTRVAL_P(str), Z_USTRLEN_P(str) TSRMLS_CC); + } else if (Z_TYPE_P(str) == IS_STRING) { + zend_update_property_stringl(default_exception_ce, exception, "string", sizeof("string")-1, Z_STRVAL_P(str), Z_STRLEN_P(str) TSRMLS_CC); } else { - /* FIXME: Unicode support??? */ - zend_update_property_string(default_exception_ce, exception, "string", sizeof("string")-1, EG(exception) ? ce_exception->name.s : Z_STRVAL_P(str) TSRMLS_CC); + zend_error(E_WARNING, "%v::__toString() must return a string", ce_exception->name); } } zval_ptr_dtor(&str);

« previous php.zend-engine.cvs (#4612) next »