helly Mon Sep 1 18:55:41 2003 EDT
Modified files:
/php-src/main main.c
Log:
Error message clean up part I: always show 'Unknown' instead of empty names.
Index: php-src/main/main.c
diff -u php-src/main/main.c:1.571 php-src/main/main.c:1.572
--- php-src/main/main.c:1.571 Sun Aug 31 05:35:53 2003
+++ php-src/main/main.c Mon Sep 1 18:55:40 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: main.c,v 1.571 2003/08/31 09:35:53 helly Exp $ */
+/* $Id: main.c,v 1.572 2003/09/01 22:55:40 helly Exp $ */
/* {{{ includes
*/
@@ -410,33 +410,33 @@
}
/* }}} */
-static char *get_active_class_name(char **space TSRMLS_DC)
-{
+static char *get_active_class_name(char **space TSRMLS_DC)
+{
if (!zend_is_executing(TSRMLS_C)) {
if (space) {
*space = "";
- }
- return "";
- }
- switch (EG(function_state_ptr)->function->type) {
- case ZEND_USER_FUNCTION:
+ }
+ return "";
+ }
+ switch (EG(function_state_ptr)->function->type) {
+ case ZEND_USER_FUNCTION:
case ZEND_INTERNAL_FUNCTION:
- {
- zend_class_entry *ce =
EG(function_state_ptr)->function->common.scope;
-
+ {
+ zend_class_entry *ce =
EG(function_state_ptr)->function->common.scope;
+
if (space) {
*space = ce ? "::" : "";
- }
+ }
return ce ? ce->name : "";
- }
- default:
+ }
+ default:
if (space) {
*space = "";
- }
- return "";
- }
-}
-
+ }
+ return "";
+ }
+}
+
/* {{{ php_verror */
/* php_verror is called from php_error_docref<n> functions.
* Its purpose is to unify error messages and automatically generate clickable
@@ -447,11 +447,15 @@
{
char *buffer = NULL, *docref_buf = NULL, *ref = NULL, *target = NULL;
char *docref_target = "", *docref_root = "";
- char *function, *p;
+ char *p;
int buffer_len = 0;
char *space;
char *class_name = get_active_class_name(&space TSRMLS_CC);
-
+ char *function = get_active_function_name(TSRMLS_C);
+
+ if (!function || !strlen(function)) {
+ function = "Unknown";
+ }
buffer_len = vspprintf(&buffer, 0, format, args);
if (buffer) {
if (PG(html_errors)) {
@@ -467,7 +471,6 @@
docref = NULL;
}
if (!docref) {
- function = get_active_function_name(TSRMLS_C);
if (function) {
spprintf(&docref_buf, 0, "function.%s", function);
if (docref_buf) {
@@ -506,20 +509,17 @@
}
if (!PG(html_errors) || !strlen(PG(docref_root))) {
/* no docref and no html errors -> do not point to any
documentation (e.g. production boxes) */
- php_error(type, "%s%s%s(%s): %s", class_name, space,
get_active_function_name(TSRMLS_C), params, buffer);
+ php_error(type, "%s%s%s(%s): %s", class_name, space,
function, params, buffer);
} else if (PG(html_errors)) {
- php_error(type, "%s%s%s(%s) [<a href='%s%s%s'>%s</a>]:
%s", class_name, space, get_active_function_name(TSRMLS_C), params, docref_root,
docref, docref_target, docref, buffer);
+ php_error(type, "%s%s%s(%s) [<a href='%s%s%s'>%s</a>]:
%s", class_name, space, function, params, docref_root, docref, docref_target, docref,
buffer);
} else {
- php_error(type, "%s%s%s(%s) [%s%s%s]: %s", class_name,
space, get_active_function_name(TSRMLS_C), params, docref_root, docref, docref_target,
buffer);
+ php_error(type, "%s%s%s(%s) [%s%s%s]: %s", class_name,
space, function, params, docref_root, docref, docref_target, buffer);
}
if (target) {
efree(target);
}
} else {
- docref = get_active_function_name(TSRMLS_C);
- if (!docref)
- docref = "Unknown";
- php_error(type, "%s%s%s(%s): %s ", class_name, space, docref,
params, buffer);
+ php_error(type, "%s%s%s(%s): %s ", class_name, space,
function, params, buffer);
}
if (PG(track_errors) && EG(active_symbol_table)) {
@@ -536,7 +536,7 @@
efree(docref_buf);
}
} else {
- php_error(E_ERROR, "%s%s%s(%s): Out of memory", class_name, space,
get_active_function_name(TSRMLS_C), params);
+ php_error(E_ERROR, "%s%s%s(%s): Out of memory", class_name, space,
function, params);
}
}
/* }}} */
@@ -576,8 +576,9 @@
va_start(args, format);
php_verror(docref, params ? params : "...", type, format, args TSRMLS_CC);
va_end(args);
- if (params)
+ if (params) {
efree(params);
+ }
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php