]> granicus.if.org Git - php/commitdiff
Error message clean up part I: always show 'Unknown' instead of empty names.
authorMarcus Boerger <helly@php.net>
Mon, 1 Sep 2003 22:55:40 +0000 (22:55 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 1 Sep 2003 22:55:40 +0000 (22:55 +0000)
main/main.c

index 6294c64f856bf3482f366916e4f6cd74bc41b724..9ee9b680d6ddc571300a71286a45e73c674f38a7 100644 (file)
@@ -447,11 +447,15 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
 {
        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 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
                        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 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
                        }
                        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 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
                        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 @@ PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1,
        va_start(args, format);
        php_verror(docref, params ? params : "...", type, format, args TSRMLS_CC);
        va_end(args);
-       if (params)
+       if (params) {
                efree(params);
+       }
 }
 /* }}} */