cvs: ZendEngine2 / zend.c zend.h zend_default_classes.c php-src/main main.c
| From: | Marcus Boerger | Date: | Sun, 31 Aug 2003 09:35:54 +0000 |
| Subject: | cvs: ZendEngine2 / zend.c zend.h zend_default_classes.c php-src/main main.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-1763@lists.php.net to get a copy of this message | ||
helly Sun Aug 31 05:35:54 2003 EDT
Modified files:
/php-src/main main.c
/ZendEngine2 zend.c zend.h zend_default_classes.c
Log:
Make vspprintf available as zend utility function. Use it in exception output.
Index: php-src/main/main.c
diff -u php-src/main/main.c:1.570 php-src/main/main.c:1.571
--- php-src/main/main.c:1.570 Thu Aug 28 13:07:40 2003
+++ php-src/main/main.c Sun Aug 31 05:35:53 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: main.c,v 1.570 2003/08/28 17:07:40 sas Exp $ */
+/* $Id: main.c,v 1.571 2003/08/31 09:35:53 helly Exp $ */
/* {{{ includes
*/
@@ -1313,6 +1313,7 @@
zuf.ticks_function = php_run_ticks;
zuf.on_timeout = php_on_timeout;
zuf.stream_open_function = php_stream_open_for_zend;
+ zuf.vspprintf_function = vspprintf;
zend_startup(&zuf, NULL, 1);
#ifdef ZTS
Index: ZendEngine2/zend.c
diff -u ZendEngine2/zend.c:1.245 ZendEngine2/zend.c:1.246
--- ZendEngine2/zend.c:1.245 Thu Aug 28 18:53:24 2003
+++ ZendEngine2/zend.c Sun Aug 31 05:35:54 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend.c,v 1.245 2003/08/28 22:53:24 helly Exp $ */
+/* $Id: zend.c,v 1.246 2003/08/31 09:35:54 helly Exp $ */
#include "zend.h"
#include "zend_extensions.h"
@@ -54,6 +54,7 @@
ZEND_API void (*zend_unblock_interruptions)(void);
ZEND_API void (*zend_ticks_function)(int ticks);
ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const
char *format, va_list args);
+int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
void (*zend_on_timeout)(int seconds TSRMLS_DC);
@@ -567,6 +568,7 @@
zend_get_configuration_directive_p = utility_functions->get_configuration_directive;
zend_ticks_function = utility_functions->ticks_function;
zend_on_timeout = utility_functions->on_timeout;
+ zend_vspprintf = utility_functions->vspprintf_function;
zend_compile_file = compile_file;
zend_execute = execute;
Index: ZendEngine2/zend.h
diff -u ZendEngine2/zend.h:1.223 ZendEngine2/zend.h:1.224
--- ZendEngine2/zend.h:1.223 Thu Aug 28 13:31:31 2003
+++ ZendEngine2/zend.h Sun Aug 31 05:35:54 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend.h,v 1.223 2003/08/28 17:31:31 sas Exp $ */
+/* $Id: zend.h,v 1.224 2003/08/31 09:35:54 helly Exp $ */
#ifndef ZEND_H
#define ZEND_H
@@ -365,6 +365,7 @@
void (*ticks_function)(int ticks);
void (*on_timeout)(int seconds TSRMLS_DC);
int (*stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
+ int (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap);
} zend_utility_functions;
@@ -501,6 +502,7 @@
extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint
error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
extern void (*zend_on_timeout)(int seconds TSRMLS_DC);
extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle
TSRMLS_DC);
+extern int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
ZEND_API void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
Index: ZendEngine2/zend_default_classes.c
diff -u ZendEngine2/zend_default_classes.c:1.28 ZendEngine2/zend_default_classes.c:1.29
--- ZendEngine2/zend_default_classes.c:1.28 Sat Aug 30 19:55:04 2003
+++ ZendEngine2/zend_default_classes.c Sun Aug 31 05:35:54 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_default_classes.c,v 1.28 2003/08/30 23:55:04 helly Exp $ */
+/* $Id: zend_default_classes.c,v 1.29 2003/08/31 09:35:54 helly Exp $ */
#include "zend.h"
#include "zend_API.h"
@@ -232,7 +232,7 @@
len = va_arg(args, int*);
num = va_arg(args, int*);
- s_tmp = emalloc(Z_STRLEN_PP(file) + MAX_LENGTH_OF_LONG + 2 + 1);
+ s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 1 + 1);
sprintf(s_tmp, "#%d ", (*num)++);
TRACE_APPEND_STRL(s_tmp, strlen(s_tmp));
efree(s_tmp);
@@ -358,18 +358,11 @@
{
zval *ex;
va_list arg;
-
-#ifdef _GNU_SOURCE
char *message;
+
va_start(arg, format);
- vasprintf(message, format, arg);
- va_end(arg);
-#else
- char message[1024];
- va_start(arg, format);
- vsnprintf(message, sizeof(message), format, arg);
+ zend_vspprintf(&message, 0, format, arg);
va_end(arg);
-#endif
MAKE_STD_ZVAL(ex);
if (exception_ce) {
@@ -390,9 +383,7 @@
zend_update_property_long(exception_ce, ex, "code", sizeof("code")-1, code
TSRMLS_CC);
}
-#ifdef _GNU_SOURCE
- free(message);
-#endif
+ efree(message);
EG(exception) = ex;
}