]> granicus.if.org Git - php/commitdiff
Added error mask to set_error_handler()
authorZeev Suraski <zeev@php.net>
Sat, 10 Jan 2004 11:43:42 +0000 (11:43 +0000)
committerZeev Suraski <zeev@php.net>
Sat, 10 Jan 2004 11:43:42 +0000 (11:43 +0000)
Patch by Christian Schneider <cschneid@cschneid.com>

Zend/zend_builtin_functions.c
Zend/zend_execute_API.c
Zend/zend_globals.h
Zend/zend_operators.c

index 57bc1dd0ce830eed1f74f8bf410192e68d7a20a7..45d5d81d337c24eef68ec7eab70c12fd4d493a06 100644 (file)
@@ -934,19 +934,20 @@ ZEND_FUNCTION(trigger_error)
 /* }}} */
 
 
-/* {{{ proto string set_error_handler(string error_handler)
+/* {{{ proto string set_error_handler(string error_handler [, int error_types])
    Sets a user-defined error handler function.  Returns the previously defined error handler, or false on error */
 ZEND_FUNCTION(set_error_handler)
 {
-       zval **error_handler;
+       zval *error_handler;
        zend_bool had_orig_error_handler=0;
        char *error_handler_name = NULL;
+       long error_type = E_ALL;
  
-       if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &error_handler)==FAILURE) {
-               ZEND_WRONG_PARAM_COUNT();
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &error_handler, &error_type) == FAILURE) {
+               return;
        }
 
-       if (!zend_is_callable(*error_handler, 0, &error_handler_name)) {
+       if (!zend_is_callable(error_handler, 0, &error_handler_name)) {
                zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
                                   get_active_function_name(TSRMLS_C), error_handler_name?error_handler_name:"unknown");
                efree(error_handler_name);
@@ -958,17 +959,19 @@ ZEND_FUNCTION(set_error_handler)
                had_orig_error_handler = 1;
                *return_value = *EG(user_error_handler);
                zval_copy_ctor(return_value);
+               zend_stack_push(&EG(user_error_handlers_error_reporting), &EG(user_error_handler_error_reporting), sizeof(EG(user_error_handler_error_reporting)));
                zend_ptr_stack_push(&EG(user_error_handlers), EG(user_error_handler));
        }
        ALLOC_ZVAL(EG(user_error_handler));
 
-       if (!zend_is_true(*error_handler)) { /* unset user-defined handler */
+       if (!zend_is_true(error_handler)) { /* unset user-defined handler */
                FREE_ZVAL(EG(user_error_handler));
                EG(user_error_handler) = NULL;
                RETURN_TRUE;
        }
 
-       *EG(user_error_handler) = **error_handler;
+       EG(user_error_handler_error_reporting) = (int)error_type;
+       *EG(user_error_handler) = *error_handler;
        zval_copy_ctor(EG(user_error_handler));
 
        if (!had_orig_error_handler) {
@@ -988,6 +991,8 @@ ZEND_FUNCTION(restore_error_handler)
        if (zend_ptr_stack_num_elements(&EG(user_error_handlers))==0) {
                EG(user_error_handler) = NULL;
        } else {
+               EG(user_error_handler_error_reporting) = zend_stack_int_top(&EG(user_error_handlers_error_reporting));
+               zend_stack_del_top(&EG(user_error_handlers_error_reporting));
                EG(user_error_handler) = zend_ptr_stack_pop(&EG(user_error_handlers));
        }
        RETURN_TRUE;
index 5a55f091bdccd12be7d17902e55ae73011dfdb34..127708b4fccb6eb1006c807268ae9878d267f41a 100644 (file)
@@ -167,6 +167,7 @@ void init_executor(TSRMLS_D)
 
        EG(current_execute_data) = NULL;
 
+       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));
 
@@ -229,6 +230,8 @@ void shutdown_executor(TSRMLS_D)
                        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_end_try();
@@ -287,6 +290,7 @@ void shutdown_executor(TSRMLS_D)
                zend_hash_destroy(&EG(included_files));
 
                zend_ptr_stack_destroy(&EG(arg_types_stack));
+               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_objects_store_destroy(&EG(objects_store));
index 0577ec14987699d15a9200cfccedb410eb306a40..8408cb8916772d258b8282e479b44503e5d02241 100644 (file)
@@ -214,8 +214,10 @@ struct _zend_executor_globals {
        zval *garbage[2];
        int garbage_ptr;
 
+       int user_error_handler_error_reporting;
        zval *user_error_handler;
        zval *user_exception_handler;
+       zend_stack user_error_handlers_error_reporting;
        zend_ptr_stack user_error_handlers;
        zend_ptr_stack user_exception_handlers;
 
index c83fd08e039127cd67f20c69c7c7d64d6cc7ebb2..2051235c7d0ac417c27d8f31a550d8165971158a 100644 (file)
 #include "ext/bcmath/number.h"
 #endif
 
+<<<<<<< zend_operators.c
+#define LONG_SIGN_MASK (1L << (8*SIZEOF_LONG-1))
+
+=======
 #define LONG_SIGN_MASK (1L << (8*sizeof(long)-1))
 
+>>>>>>> 1.162
 ZEND_API int zend_atoi(const char *str, int str_len)
 {
        int retval;