Re: cvs: php4 /main main.c php.h
| From: | (Marcus Börger) | Date: | Wed, 07 Aug 2002 18:35:49 +0000 |
| Subject: | Re: cvs: php4 /main main.c php.h | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-13198@lists.php.net to get a copy of this message | ||
This patch introduces new functions php_error_func<n>.
These support unified error messages AND they allow to
show parameters in call.
For example i plan to display the filename in all messages
generated by exif module as aparameter.
I would have to use php_error(<type>, "%s(%s): <message>", get_active_function_name(TSRMLS_C), filename);
now i call php_error_func1(<type>, filename TSRMLS_CC, "<message>");
Main advantage is the easy exchange way between old and
new messages (sorry for the late solution Derick) and the ability
to change ALL messages in php if required AND the unified handling
of parameters.
regards
marcus
At 20:29 07.08.2002, Marcus Börger wrote:
helly Wed Aug 7 14:29:36 2002 EDTModified files:/php4/main main.c php.hLog: -new functions php_error_func<0> to support unified error messages #read followup Index: php4/main/main.c diff -u php4/main/main.c:1.470 php4/main/main.c:1.471--- php4/main/main.c:1.470 Fri Aug 2 02:53:48 2002 +++ php4/main/main.c Wed Aug 7 14:29:35 2002@@ -18,7 +18,7 @@+----------------------------------------------------------------------+*/ -/* $Id: main.c,v 1.470 2002/08/02 06:53:48 hirokawa Exp $ */ +/* $Id: main.c,v 1.471 2002/08/07 18:29:35 helly Exp $ */ /* {{{ includes */ @@ -385,6 +385,67 @@ } /* }}} */ +/* {{{ 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 @@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;Index: php4/main/php.h diff -u php4/main/php.h:1.171 php4/main/php.h:1.172--- php4/main/php.h:1.171 Fri May 31 00:49:45 2002 +++ php4/main/php.h Wed Aug 7 14:29:36 2002@@ -17,7 +17,7 @@+----------------------------------------------------------------------+*/ -/* $Id: php.h,v 1.171 2002/05/31 04:49:45 rvenkat Exp $ */ +/* $Id: php.h,v 1.172 2002/08/07 18:29:36 helly Exp $ */ #ifndef PHP_H #define PHP_H @@ -254,6 +254,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 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php