From e50228ab5ba229a68031e8b90935e678f86bab0f Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Wed, 7 Aug 2002 18:29:36 +0000 Subject: [PATCH] -new functions php_error_func<0> to support unified error messages #read followup --- main/main.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++- main/php.h | 5 +++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/main/main.c b/main/main.c index 68e90761d5..f5cce95558 100644 --- a/main/main.c +++ b/main/main.c @@ -385,6 +385,67 @@ PHPAPI int php_printf(const char *format, ...) } /* }}} */ +/* {{{ php_verror */ +PHPAPI void php_verror(int type, const char *format, va_list args TSRMLS_DC) +{ + char *buffer = NULL; + + if (format) + vspprintf(&buffer, 0, format, args); + if (buffer) { + php_error(type, "%s", buffer); + efree(buffer); + } else { + php_error(E_ERROR, "%s(): Out of memory", get_active_function_name(TSRMLS_C)); + } +} +/* }}} */ + +/* {{{ php_error_func0 */ +PHPAPI void php_error_func0(int type TSRMLS_DC, const char *format, ...) +{ + char *message; + va_list args; + + spprintf(&message, 0, "%s(): %s", get_active_function_name(TSRMLS_C), format); + va_start(args, format); + php_verror(type, message, args TSRMLS_CC); + va_end(args); + if (message) + efree(message); +} +/* }}} */ + +/* {{{ php_error_func1 */ +PHPAPI void php_error_func1(int type, const char *param1 TSRMLS_DC, const char *format, ...) +{ + char *message; + va_list args; + + spprintf(&message, 0, "%s(%s): %s", get_active_function_name(TSRMLS_C), param1, format); + va_start(args, format); + php_verror(type, message, args TSRMLS_CC); + va_end(args); + if (message) + efree(message); +} +/* }}} */ + +/* {{{ php_error_func2 */ +PHPAPI void php_error_func2(int type, const char *param1, const char *param2 TSRMLS_DC, const char *format, ...) +{ + char *message; + va_list args; + + spprintf(&message, 0, "%s(%s,%s): %s", get_active_function_name(TSRMLS_C), param1, param2, format); + va_start(args, format); + php_verror(type, message, args TSRMLS_CC); + va_end(args); + if (message) + efree(message); +} +/* }}} */ + /* {{{ php_html_puts */ PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC) { @@ -1108,7 +1169,7 @@ static int php_hash_environment(TSRMLS_D) char *p; unsigned char _gpc_flags[3] = {0, 0, 0}; zend_bool have_variables_order; - zval *dummy_track_vars_array; + zval *dummy_track_vars_array = NULL; zend_bool initialized_dummy_track_vars_array=0; int i; char *variables_order; diff --git a/main/php.h b/main/php.h index 9fe824949e..dbf0fdd68a 100644 --- a/main/php.h +++ b/main/php.h @@ -255,6 +255,11 @@ int cfgparse(void); #define php_error zend_error +/* PHPAPI void php_error(int type, const char *format, ...); */ +PHPAPI void php_error_func0(int type TSRMLS_DC, const char *format, ...); +PHPAPI void php_error_func1(int type, const char *param1 TSRMLS_DC, const char *format, ...); +PHPAPI void php_error_func2(int type, const char *param1, const char *param2 TSRMLS_DC, const char *format, ...); + #define zenderror phperror #define zendlex phplex -- 2.50.1