cvs: ZendEngine2 / zend_default_classes.c

From: Date: Mon, 01 Sep 2003 20:54:48 +0000
Subject: cvs: ZendEngine2 / zend_default_classes.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-1784@lists.php.net to get a copy of this message
helly Mon Sep 1 16:54:48 2003 EDT Modified files: /ZendEngine2 zend_default_classes.c Log: Show {main} and prevent showing empty stack traces Index: ZendEngine2/zend_default_classes.c diff -u ZendEngine2/zend_default_classes.c:1.32 ZendEngine2/zend_default_classes.c:1.33 --- ZendEngine2/zend_default_classes.c:1.32 Mon Sep 1 16:02:47 2003 +++ ZendEngine2/zend_default_classes.c Mon Sep 1 16:54:48 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_default_classes.c,v 1.32 2003/09/01 20:02:47 helly Exp $ */ +/* $Id: zend_default_classes.c,v 1.33 2003/09/01 20:54:48 helly Exp $ */ #include "zend.h" #include "zend_API.h" @@ -274,14 +274,19 @@ ZEND_METHOD(exception, gettraceasstring) { zval *trace; - char *str = estrdup(""); - int len = 0, num = 0; + char *res = estrdup(""), **str = &res, *s_tmp; + int res_len = 0, *len = &res_len, num = 0; trace = zend_read_property(Z_OBJCE_P(getThis()), getThis(), "trace", sizeof("trace")-1, 1 TSRMLS_CC); - zend_hash_apply_with_arguments(Z_ARRVAL_P(trace), (apply_func_args_t)_build_trace_string, 3, &str, &len, &num); + zend_hash_apply_with_arguments(Z_ARRVAL_P(trace), (apply_func_args_t)_build_trace_string, 3, str, len, &num); - str[len] = '\0'; - RETURN_STRINGL(str, len, 0); + s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 7 + 1); + sprintf(s_tmp, "#%d {main}", num); + TRACE_APPEND_STRL(s_tmp, strlen(s_tmp)); + efree(s_tmp); + + res[res_len] = '\0'; + RETURN_STRINGL(res, res_len, 0); } /* }}} */ @@ -315,7 +320,7 @@ str = emalloc(len); sprintf(str, "exception '%s' with message '%s' in %s:%ld\nStack trace:\n%s", Z_OBJCE_P(getThis())->name, Z_STRVAL_P(message), Z_STRVAL_P(file), Z_LVAL_P(line), - Z_STRVAL_P(trace)); + Z_STRLEN_P(trace) ? Z_STRVAL_P(trace) : "#0 {main}\n"); len = strlen(str); /* We store the result in the private property string so we can access

« previous php.zend-engine.cvs (#1784) next »