Skip to content
Browse files

rename php_error_func<n> to php_error_docref and support Wez idea

that solves ToDo requirement to point to PHP Manual in error messages.
  • Loading branch information...
1 parent 9abdbd9 commit 88c385e8176c50d0cfe1d5203cd0ce40859a1b68 Marcus Boerger committed Aug 8, 2002
Showing with 45 additions and 30 deletions.
  1. +37 −27 main/main.c
  2. +5 −3 main/php.h
  3. +3 −0 main/php_globals.h
View
64 main/main.c
@@ -234,6 +234,8 @@ PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("display_startup_errors", "0", PHP_INI_ALL, OnUpdateBool, display_startup_errors, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateBool, enable_dl, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("expose_php", "1", PHP_INI_SYSTEM, OnUpdateBool, expose_php, php_core_globals, core_globals)
+ STD_PHP_INI_ENTRY("docref_root", "http://www.php.net/", PHP_INI_ALL, OnUpdateString, docref_root, php_core_globals, core_globals)
+ STD_PHP_INI_ENTRY("docref_ext", "", PHP_INI_ALL, OnUpdateString, docref_ext, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("html_errors", "1", PHP_INI_SYSTEM, OnUpdateBool, html_errors, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("xmlrpc_errors", "0", PHP_INI_SYSTEM, OnUpdateBool, xmlrpc_errors, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("xmlrpc_error_number", "0", PHP_INI_ALL, OnUpdateInt, xmlrpc_error_number, php_core_globals, core_globals)
@@ -386,63 +388,71 @@ PHPAPI int php_printf(const char *format, ...)
/* }}} */
/* {{{ php_verror */
-PHPAPI void php_verror(int type, const char *format, va_list args TSRMLS_DC)
+PHPAPI void php_verror(const char *docref, const char *params, int type, const char *format, va_list args TSRMLS_DC)
{
- char *buffer = NULL;
+ char *buffer = NULL, *docref_buf = NULL, *p;
- if (format)
- vspprintf(&buffer, 0, format, args);
+ vspprintf(&buffer, 0, format, args);
if (buffer) {
- php_error(type, "%s", buffer);
+ if (!docref) {
+ spprintf(&docref_buf, 0, "function.%s%s", get_active_function_name(TSRMLS_C), PG(docref_ext));
+ if (docref_buf) {
+ while((p=strchr(docref_buf, '_'))!=NULL) *p = '-';
+ docref = docref_buf;
+ }
+ }
+ if (docref) {
+ if (PG(html_errors) && PG(docref_ext)) {
+ php_error(type, "%s(%s) [<a href='%s%s'>%s</a>]: %s", get_active_function_name(TSRMLS_C), params, PG(docref_root), docref, docref, buffer);
+ } else {
+ php_error(type, "%s(%s) [%s%s]: %s", get_active_function_name(TSRMLS_C), params, PG(docref_root), docref, buffer);
+ }
+ } else {
+ php_error(type, "%s(%s): %s", get_active_function_name(TSRMLS_C), params, buffer);
+ }
efree(buffer);
+ if (docref_buf)
+ efree(docref_buf);
} else {
- php_error(E_ERROR, "%s(): Out of memory", get_active_function_name(TSRMLS_C));
+ php_error(E_ERROR, "%s(%s): Out of memory", get_active_function_name(TSRMLS_C), params);
}
}
/* }}} */
-/* {{{ php_error_func0 */
-PHPAPI void php_error_func0(int type TSRMLS_DC, const char *format, ...)
+/* {{{ php_error_docref */
+PHPAPI void php_error_docref(const char *docref TSRMLS_DC, int type, 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);
+ php_verror(docref, "", type, format, 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, ...)
+/* {{{ php_error_docref1 */
+PHPAPI void php_error_docref1(const char *docref TSRMLS_DC, const char *param1, int type, 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);
+ php_verror(docref, param1, type, format, 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, ...)
+/* {{{ php_error_docref2 */
+PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, const char *param2, int type, const char *format, ...)
{
- char *message;
+ char *params;
va_list args;
- spprintf(&message, 0, "%s(%s,%s): %s", get_active_function_name(TSRMLS_C), param1, param2, format);
+ spprintf(&params, 0, "%s,%s", param1, param2);
va_start(args, format);
- php_verror(type, message, args TSRMLS_CC);
+ php_verror(docref, params ? params : "...", type, format, args TSRMLS_CC);
va_end(args);
- if (message)
- efree(message);
+ if (params)
+ efree(params);
}
/* }}} */
View
8 main/php.h
@@ -256,9 +256,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, ...);
+PHPAPI void php_error_docref0(const char *docref TSRMLS_DC, int type, const char *format, ...);
+PHPAPI void php_error_docref1(const char *docref TSRMLS_DC, const char *param1, int type, const char *format, ...);
+PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, const char *param2, int type, const char *format, ...);
+
+#define php_error_docref php_error_docref0
#define zenderror phperror
#define zendlex phplex
View
3 main/php_globals.h
@@ -120,6 +120,9 @@ struct _php_core_globals {
zend_bool y2k_compliance;
+ char *docref_root;
+ char *docref_ext;
+
zend_bool html_errors;
zend_bool xmlrpc_errors;

0 comments on commit 88c385e

Please sign in to comment.
Something went wrong with that request. Please try again.