summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2000-04-27 18:37:02 +0000
committerZeev Suraski <zeev@php.net>2000-04-27 18:37:02 +0000
commit39aa59bdecad946203481dfd13fd8808d3f09425 (patch)
treee8717f4282e7a01c70861a31b2f1976420c5410e /main
parent095f1d91b178ade6bdf629f020369df9cee19ceb (diff)
downloadphp-git-39aa59bdecad946203481dfd13fd8808d3f09425.tar.gz
More error handling work (still completely disabled)
Diffstat (limited to 'main')
-rw-r--r--main/main.c23
-rw-r--r--main/php.h9
2 files changed, 28 insertions, 4 deletions
diff --git a/main/main.c b/main/main.c
index 185f189004..1c61350c62 100644
--- a/main/main.c
+++ b/main/main.c
@@ -298,17 +298,24 @@ PHPAPI int php_printf(const char *format, ...)
/* extended error handling function */
-PHPAPI void php_error(int type, const char *format, ...)
+#if ZEND_NEW_ERROR_HANDLING
+static void php_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list orig_args)
+#else
+PHPAPI void php_error_cb(int type, const char *format, ...)
+#endif
{
- va_list args;
+#if !ZEND_NEW_ERROR_HANDLING
char *error_filename = NULL;
uint error_lineno;
+#endif
char buffer[1024];
int size = 0;
+ va_list args;
CLS_FETCH();
ELS_FETCH();
PLS_FETCH();
+#if !ZEND_NEW_ERROR_HANDLING
switch (type) {
case E_CORE_ERROR:
case E_CORE_WARNING:
@@ -344,6 +351,7 @@ PHPAPI void php_error(int type, const char *format, ...)
if (!error_filename) {
error_filename = "Unknown";
}
+#endif
if (EG(error_reporting) & type || (type & E_CORE)) {
char *error_type_str;
@@ -377,7 +385,11 @@ PHPAPI void php_error(int type, const char *format, ...)
/* get include file name */
if (PG(log_errors) || PG(display_errors) || (!module_initialized)) {
+#if ZEND_NEW_ERROR_HANDLING
+ args = orig_args;
+#else
va_start(args, format);
+#endif
size = vsnprintf(buffer, sizeof(buffer) - 1, format, args);
va_end(args);
buffer[sizeof(buffer) - 1] = 0;
@@ -419,9 +431,14 @@ PHPAPI void php_error(int type, const char *format, ...)
if (PG(track_errors)) {
pval *tmp;
+#if ZEND_NEW_ERROR_HANDLING
+ args = orig_args;
+#else
va_start(args, format);
+#endif
size = vsnprintf(buffer, sizeof(buffer) - 1, format, args);
va_end(args);
+
buffer[sizeof(buffer) - 1] = 0;
ALLOC_ZVAL(tmp);
@@ -812,7 +829,7 @@ int php_module_startup(sapi_module_struct *sf)
php_output_startup();
- zuf.error_function = php_error;
+ zuf.error_function = php_error_cb;
zuf.printf_function = php_printf;
zuf.write_function = php_body_write_wrapper;
zuf.fopen_function = php_fopen_wrapper_for_zend;
diff --git a/main/php.h b/main/php.h
index b7867bfcbf..326bbfc7e8 100644
--- a/main/php.h
+++ b/main/php.h
@@ -242,13 +242,20 @@ extern char **environ;
#endif
extern void phperror(char *error);
-extern PHPAPI void php_error(int type, const char *format, ...);
extern PHPAPI int php_write(void *buf, int size);
extern PHPAPI int php_printf(const char *format, ...);
extern void php_log_err(char *log_message);
extern int Debug(char *format, ...);
extern int cfgparse(void);
+#if ZEND_NEW_ERROR_HANDLING
+#define php_error zend_error
+#else
+extern PHPAPI void php_error_cb(int type, const char *format, ...);
+#define php_error php_error_cb
+#endif
+
+
extern void html_putc(char c);
#define zenderror phperror