summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2003-12-09 21:55:02 +0000
committerRob Richards <rrichards@php.net>2003-12-09 21:55:02 +0000
commit1f33239c919006d7b927b80d6fff1836279656b4 (patch)
tree7209b524ad59d4569dd7af26bb150b0560784104
parent85ce95847f99c03c22816b920a373ebc48e3ab1b (diff)
downloadphp-git-1f33239c919006d7b927b80d6fff1836279656b4.tar.gz
buffer error messages until newline is hit
-rw-r--r--ext/libxml/libxml.c28
-rw-r--r--ext/libxml/php_libxml.h2
2 files changed, 25 insertions, 5 deletions
diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c
index 49500d88aa..f9e6ded171 100644
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -221,6 +221,7 @@ static void php_libxml_node_free_list(xmlNodePtr node TSRMLS_DC)
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 @@ static void php_libxml_error_handler(void *ctx, const char *msg, ...)
{
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 @@ PHP_MINIT_FUNCTION(libxml)
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_MSHUTDOWN_FUNCTION(libxml)
PHP_RSHUTDOWN_FUNCTION(libxml)
{
+ if (LIBXML(error_buffer)) {
+ smart_str_free(&LIBXML(error_buffer));
+ LIBXML(error_buffer) = NULL;
+ }
return SUCCESS;
}
diff --git a/ext/libxml/php_libxml.h b/ext/libxml/php_libxml.h
index 6ed39f88ef..11a63609e9 100644
--- a/ext/libxml/php_libxml.h
+++ b/ext/libxml/php_libxml.h
@@ -37,10 +37,12 @@ extern zend_module_entry libxml_module_entry;
#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 {