]> granicus.if.org Git - php/commitdiff
-new functions php_error_func<0> to support unified error messages
authorMarcus Boerger <helly@php.net>
Wed, 7 Aug 2002 18:29:36 +0000 (18:29 +0000)
committerMarcus Boerger <helly@php.net>
Wed, 7 Aug 2002 18:29:36 +0000 (18:29 +0000)
#read followup

main/main.c
main/php.h

index 68e90761d58d7c0ce15bef7e13cfab83f0318979..f5cce955583ef26d7b75d1a517fb52cab354b415 100644 (file)
@@ -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;
index 9fe824949e26d17e637345fc438ca14065427922..dbf0fdd68a93c6eaa0b2ef4a4d5db0a578a20b9d 100644 (file)
@@ -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