rrichards Tue Dec 9 16:55:03 2003 EDT Modified files: /php-src/ext/libxml libxml.c php_libxml.h Log: buffer error messages until newline is hit Index: php-src/ext/libxml/libxml.c diff -u php-src/ext/libxml/libxml.c:1.9 php-src/ext/libxml/libxml.c:1.10 --- php-src/ext/libxml/libxml.c:1.9 Fri Nov 28 18:25:25 2003 +++ php-src/ext/libxml/libxml.c Tue Dec 9 16:55:02 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: libxml.c,v 1.9 2003/11/28 23:25:25 pollita Exp $ */ +/* $Id: libxml.c,v 1.10 2003/12/09 21:55:02 rrichards Exp $ */ #define IS_EXT_MODULE @@ -221,6 +221,7 @@ static void php_libxml_init_globals(php_libxml_globals *libxml_globals_p TSRMLS_DC) { LIBXML(stream_context) = NULL; + LIBXML(error_buffer) = NULL; } #endif @@ -297,19 +298,31 @@ { va_list ap; char *buf; - int len; + int len, len_iter, output = 0; + + TSRMLS_FETCH(); va_start(ap, msg); len = vspprintf(&buf, 0, msg, ap); va_end(ap); - + + len_iter = len; + /* remove any trailing \n */ - while (len && buf[--len] == '\n') { - buf[len] = '\0'; + while (len && buf[--len_iter] == '\n') { + buf[len_iter] = '\0'; + output = 1; } - php_error(E_WARNING, "%s", buf); + smart_str_appendl(&LIBXML(error_buffer), buf, len); + efree(buf); + + if (output == 1) { + php_error(E_WARNING, "%s", (char *) LIBXML(error_buffer)); + smart_str_free(&LIBXML(error_buffer)); + LIBXML(error_buffer) = NULL; + } } PHP_LIBXML_API void php_libxml_initialize() { @@ -357,6 +370,7 @@ ts_allocate_id(&libxml_globals_id, sizeof(php_libxml_globals), (ts_allocate_ctor) php_libxml_init_globals, NULL); #else LIBXML(stream_context) = NULL; + LIBXML(error_buffer) = NULL; #endif return SUCCESS; @@ -378,6 +392,10 @@ PHP_RSHUTDOWN_FUNCTION(libxml) { + if (LIBXML(error_buffer)) { + smart_str_free(&LIBXML(error_buffer)); + LIBXML(error_buffer) = NULL; + } return SUCCESS; } Index: php-src/ext/libxml/php_libxml.h diff -u php-src/ext/libxml/php_libxml.h:1.3 php-src/ext/libxml/php_libxml.h:1.4 --- php-src/ext/libxml/php_libxml.h:1.3 Sun Oct 26 10:53:20 2003 +++ php-src/ext/libxml/php_libxml.h Tue Dec 9 16:55:02 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_libxml.h,v 1.3 2003/10/26 15:53:20 rrichards Exp $ */ +/* $Id: php_libxml.h,v 1.4 2003/12/09 21:55:02 rrichards Exp $ */ #ifndef PHP_LIBXML_H #define PHP_LIBXML_H @@ -37,10 +37,12 @@ #define PHP_LIBXML_API #endif +#include "ext/standard/php_smart_str.h" #include <libxml/tree.h> typedef struct { zval *stream_context; + smart_str *error_buffer; } php_libxml_globals; typedef struct _php_libxml_ref_obj {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php