andrei Tue Jun 20 23:00:02 2006 UTC
Modified files:
/ZendEngine2 zend.c zend_execute_API.c zend_globals.h
/php-src/ext/unicode unicode.c
Log:
Implement unicode_set_error_handler() / unicode_restore_error_handler().
The error handler doesn't do anything yet. (vaporware)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.c?r1=1.361&r2=1.362&diff_format=u
Index: ZendEngine2/zend.c
diff -u ZendEngine2/zend.c:1.361 ZendEngine2/zend.c:1.362
--- ZendEngine2/zend.c:1.361 Tue Jun 13 12:56:20 2006
+++ ZendEngine2/zend.c Tue Jun 20 23:00:01 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend.c,v 1.361 2006/06/13 12:56:20 sesser Exp $ */
+/* $Id: zend.c,v 1.362 2006/06/20 23:00:01 andrei Exp $ */
#include "zend.h"
#include "zend_extensions.h"
@@ -920,6 +920,7 @@
memset(unicode_globals->from_subst_char, 0, 3 * sizeof(UChar));
zend_codepoint_to_uchar(0x3f, unicode_globals->from_subst_char);
unicode_globals->to_error_mode = ZEND_CONV_ERROR_STOP;
+ unicode_globals->conv_error_handler = NULL;
zend_hash_init_ex(&unicode_globals->flex_compatible, 0, NULL, NULL, 1,
0);
}
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute_API.c?r1=1.373&r2=1.374&diff_format=u
Index: ZendEngine2/zend_execute_API.c
diff -u ZendEngine2/zend_execute_API.c:1.373
ZendEngine2/zend_execute_API.c:1.374
--- ZendEngine2/zend_execute_API.c:1.373 Tue Jun 13 12:56:20 2006
+++ ZendEngine2/zend_execute_API.c Tue Jun 20 23:00:01 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute_API.c,v 1.373 2006/06/13 12:56:20 sesser Exp $ */
+/* $Id: zend_execute_API.c,v 1.374 2006/06/20 23:00:01 andrei Exp $ */
#include <stdio.h>
#include <signal.h>
@@ -187,6 +187,7 @@
zend_stack_init(&EG(user_error_handlers_error_reporting));
zend_ptr_stack_init(&EG(user_error_handlers));
zend_ptr_stack_init(&EG(user_exception_handlers));
+ zend_ptr_stack_init(&UG(conv_error_handlers));
zend_objects_store_init(&EG(objects_store), 1024);
@@ -251,10 +252,18 @@
FREE_ZVAL(zeh);
}
+ if (UG(conv_error_handler)) {
+ zeh = UG(conv_error_handler);
+ UG(conv_error_handler) = NULL;
+ zval_dtor(zeh);
+ FREE_ZVAL(zeh);
+ }
+
zend_stack_destroy(&EG(user_error_handlers_error_reporting));
zend_stack_init(&EG(user_error_handlers_error_reporting));
zend_ptr_stack_clean(&EG(user_error_handlers), ZVAL_DESTRUCTOR,
1);
zend_ptr_stack_clean(&EG(user_exception_handlers),
ZVAL_DESTRUCTOR, 1);
+ zend_ptr_stack_clean(&UG(conv_error_handlers), ZVAL_DESTRUCTOR,
1);
} zend_end_try();
zend_try {
@@ -308,6 +317,7 @@
zend_stack_destroy(&EG(user_error_handlers_error_reporting));
zend_ptr_stack_destroy(&EG(user_error_handlers));
zend_ptr_stack_destroy(&EG(user_exception_handlers));
+ zend_ptr_stack_destroy(&UG(conv_error_handlers));
zend_objects_store_destroy(&EG(objects_store));
if (EG(in_autoload)) {
zend_hash_destroy(EG(in_autoload));
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_globals.h?r1=1.159&r2=1.160&diff_format=u
Index: ZendEngine2/zend_globals.h
diff -u ZendEngine2/zend_globals.h:1.159 ZendEngine2/zend_globals.h:1.160
--- ZendEngine2/zend_globals.h:1.159 Fri May 19 06:11:02 2006
+++ ZendEngine2/zend_globals.h Tue Jun 20 23:00:02 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_globals.h,v 1.159 2006/05/19 06:11:02 dmitry Exp $ */
+/* $Id: zend_globals.h,v 1.160 2006/06/20 23:00:02 andrei Exp $ */
#ifndef ZEND_GLOBALS_H
#define ZEND_GLOBALS_H
@@ -312,6 +312,9 @@
zend_collator *default_collator;
HashTable flex_compatible; /* table of
flex-compatible encodings */
+
+ zval *conv_error_handler; /* user-defined
conversion error handler */
+ zend_ptr_stack conv_error_handlers; /* stack for user error handlers */
};
#endif /* ZEND_GLOBALS_H */
http://cvs.php.net/viewvc.cgi/php-src/ext/unicode/unicode.c?r1=1.36&r2=1.37&diff_format=u
Index: php-src/ext/unicode/unicode.c
diff -u php-src/ext/unicode/unicode.c:1.36 php-src/ext/unicode/unicode.c:1.37
--- php-src/ext/unicode/unicode.c:1.36 Thu Jun 15 17:37:48 2006
+++ php-src/ext/unicode/unicode.c Tue Jun 20 23:00:02 2006
@@ -15,7 +15,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: unicode.c,v 1.36 2006/06/15 17:37:48 andrei Exp $ */
+/* $Id: unicode.c,v 1.37 2006/06/20 23:00:02 andrei Exp $ */
#include "php_unicode.h"
#include "zend_unicode.h"
@@ -232,6 +232,66 @@
}
/* }}} */
+PHP_FUNCTION(unicode_set_error_handler)
+{
+ zval *error_handler;
+ zend_bool had_orig_error_handler=0;
+ zval error_handler_name;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z",
&error_handler) == FAILURE) {
+ return;
+ }
+
+ if (Z_TYPE_P(error_handler) != IS_NULL) { /* NULL == unset */
+ if (!zend_is_callable(error_handler, 0, &error_handler_name)) {
+ zend_error(E_WARNING, "%v() expects the argument (%R)
to be a valid callback",
+ get_active_function_name(TSRMLS_C),
Z_TYPE(error_handler_name), Z_UNIVAL(error_handler_name));
+ zval_dtor(&error_handler_name);
+ return;
+ }
+ zval_dtor(&error_handler_name);
+ }
+
+ if (UG(conv_error_handler)) {
+ had_orig_error_handler = 1;
+ *return_value = *UG(conv_error_handler);
+ zval_copy_ctor(return_value);
+ zend_ptr_stack_push(&UG(conv_error_handlers),
UG(conv_error_handler));
+ }
+ ALLOC_ZVAL(UG(conv_error_handler));
+
+ if (Z_TYPE_P(error_handler) == IS_NULL) { /* unset user-defined handler
*/
+ FREE_ZVAL(UG(conv_error_handler));
+ UG(conv_error_handler) = NULL;
+ zval_dtor(return_value);
+ RETURN_TRUE;
+ }
+
+ *UG(conv_error_handler) = *error_handler;
+ zval_copy_ctor(UG(conv_error_handler));
+
+ if (!had_orig_error_handler) {
+ RETURN_NULL();
+ }
+}
+
+PHP_FUNCTION(unicode_restore_error_handler)
+{
+ if (UG(conv_error_handler)) {
+ zval *ceh = UG(conv_error_handler);
+
+ UG(conv_error_handler) = NULL;
+ zval_ptr_dtor(&ceh);
+ }
+
+ if (zend_ptr_stack_num_elements(&UG(conv_error_handlers))==0) {
+ UG(conv_error_handler) = NULL;
+ } else {
+ UG(conv_error_handler) =
zend_ptr_stack_pop(&UG(conv_error_handlers));
+ }
+ RETURN_TRUE;
+}
+
/* {{{ unicode_functions[] */
zend_function_entry unicode_functions[] = {
PHP_FE(locale_get_default, NULL)
@@ -239,6 +299,8 @@
PHP_FE(unicode_decode, NULL)
PHP_FE(unicode_semantics, NULL)
PHP_FE(unicode_encode, NULL)
+ PHP_FE(unicode_set_error_handler, NULL)
+ PHP_FE(unicode_restore_error_handler, NULL)
PHP_FE(unicode_set_error_mode, NULL)
PHP_FE(unicode_set_subst_char, NULL)
PHP_FE(unicode_get_error_mode, NULL)
@@ -307,7 +369,6 @@
};
/* }}} */
-
/* {{{ unicode_module_entry
*/
zend_module_entry unicode_module_entry = {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php