Permalink
Browse files

Borland C fix from Moritz Both regenerate, workaround a problem for b…

…uffer

* trionan.c: Borland C fix from Moritz Both
* testapi.c: regenerate, workaround a problem for buffer testing
* xmlIO.c HTMLtree.c: new internal entry point to hide even better
  xmlAllocOutputBufferInternal
* tree.c: harden the code around buffer allocation schemes
* parser.c: restore the warning when namespace names are not absolute
  URIs
* runxmlconf.c: continue regression tests if we get the expected
  number of errors
* Makefile.am: run the python tests on make check
* xmlsave.c: handle the HTML documents and trees
* python/libxml.c: convert python serialization to the xmlSave APIs
  and avoid some horrible hacks
Daniel

svn path=/trunk/; revision=3790
  • Loading branch information...
1 parent 1572425 commit da3fee406da96c344d7b5f4e0631faee74f7e11d Daniel Veillard committed Sep 1, 2008
Showing with 367 additions and 214 deletions.
  1. +16 −0 ChangeLog
  2. +6 −1 HTMLtree.c
  3. +3 −1 Makefile.am
  4. +27 −0 NEWS
  5. +1 −0 gentest.py
  6. +1 −1 parser.c
  7. +33 −114 python/libxml.c
  8. +6 −2 runxmlconf.c
  9. +3 −1 testapi.c
  10. +9 −4 tree.c
  11. +4 −0 trionan.c
  12. +61 −8 xmlIO.c
  13. +197 −82 xmlsave.c
View
@@ -1,3 +1,19 @@
+Mon Sep 1 15:02:05 CEST 2008 Daniel Veillard <daniel@veillard.com>
+
+ * trionan.c: Borland C fix from Moritz Both
+ * testapi.c: regenerate, workaround a problem for buffer testing
+ * xmlIO.c HTMLtree.c: new internal entry point to hide even better
+ xmlAllocOutputBufferInternal
+ * tree.c: harden the code around buffer allocation schemes
+ * parser.c: restore the warning when namespace names are not absolute
+ URIs
+ * runxmlconf.c: continue regression tests if we get the expected
+ number of errors
+ * Makefile.am: run the python tests on make check
+ * xmlsave.c: handle the HTML documents and trees
+ * python/libxml.c: convert python serialization to the xmlSave APIs
+ and avoid some horrible hacks
+
Sat Aug 30 16:58:40 CEST 2008 Daniel Veillard <daniel@veillard.com>
* configure.in, doc/*: preparing 2.7.0 release
View
@@ -316,6 +316,11 @@ htmlIsBooleanAttr(const xmlChar *name)
}
#ifdef LIBXML_OUTPUT_ENABLED
+/*
+ * private routine exported from xmlIO.c
+ */
+xmlOutputBufferPtr
+xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder);
/************************************************************************
* *
* Output error handlers *
@@ -566,7 +571,7 @@ htmlDocDumpMemoryFormat(xmlDocPtr cur, xmlChar**mem, int *size, int format) {
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
- buf = xmlAllocOutputBuffer(handler);
+ buf = xmlAllocOutputBufferInternal(handler);
if (buf == NULL) {
*mem = NULL;
*size = 0;
View
@@ -157,7 +157,7 @@ rebuild_testapi:
# that one is just to make sure it is rebuilt if missing
# but adding the dependances generate mess
-testapi.c:
+testapi.c: $(srcdir)/gentest.py
-@(if [ "$(PYTHON)" != "" ] ; then \
$(PYTHON) $(srcdir)/gentest.py $(srcdir) ; fi )
@@ -178,6 +178,8 @@ runxmlconf_LDADD= $(LDADDS)
runtests:
$(CHECKER) ./runtest$(EXEEXT) && $(CHECKER) ./testrecurse$(EXEEXT) &&$(CHECKER) ./testapi$(EXEEXT) && $(CHECKER) ./testchar$(EXEEXT)&& $(CHECKER) ./testdict$(EXEEXT) && $(CHECKER) ./runxmlconf$(EXEEXT)
+ @(if [ "@PYTHON_SUBDIR@" != "" ] ; then cd python ; \
+ $(MAKE) MAKEFLAGS+=--silent tests ; fi)
check: all runtests
View
27 NEWS
@@ -15,6 +15,33 @@ ChangeLog.html
to the SVN at
http://svn.gnome.org/viewcvs/libxml2/trunk/
code base.Here is the list of public releases:
+2.7.0: Aug 30 2008:
+ - Documentation: switch ChangeLog to UTF-8, improve mutithreads and
+ xmlParserCleanup docs
+ - Portability fixes: Older Win32 platforms (Rob Richards), MSVC
+ porting fix (Rob Richards), Mac OS X regression tests (Sven Herzberg),
+ non GNUCC builds (Rob Richards), compilation on Haiku (Andreas Färber)
+
+ - Bug fixes: various realloc problems (Ashwin), potential double-free
+ (Ashwin), regexp crash, icrash with invalid whitespace facets (Rob
+ Richards), pattern fix when streaming (William Brack), various XML
+ parsing and validation fixes based on the W3C regression tests, reader
+ tree skipping function fix (Ashwin), Schemas regexps escaping fix
+ (Volker Grabsch), handling of entity push errors (Ashwin), fix a slowdown
+ when encoder cant serialize characters on output
+ - Code cleanup: compilation fix without the reader, without the output
+ (Robert Schwebel), python whitespace (Martin), many space/tabs cleanups,
+ serious cleanup of the entity handling code
+ - Improvement: switch parser to XML-1.0 5th edition, add parsing flags
+ for old versions, switch URI parsing to RFC 3986,
+ add xmlSchemaValidCtxtGetParserCtxt (Holger Kaelberer),
+ new hashing functions for dictionnaries (based on Stefan Behnel work),
+ improve handling of misplaced html/head/body in HTML parser, better
+ regression test tools and code coverage display, better algorithms
+ to detect various versions of the billion laughts attacks, make
+ arbitrary parser limits avoidable as a parser option
+
+
2.6.32: Apr 8 2008:
- Documentation: returning heap memory to kernel (Wolfram Sang),
trying to clarify xmlCleanupParser() use, xmlXPathContext improvement
View
@@ -260,6 +260,7 @@
"xmlParseChunk": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}",
"xmlParseExtParsedEnt": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}",
"xmlDOMWrapAdoptNode": "if ((node != NULL) && (node->parent == NULL)) {xmlUnlinkNode(node);xmlFreeNode(node);node = NULL;}",
+ "xmlBufferSetAllocationScheme": "if ((buf != NULL) && (scheme == XML_BUFFER_ALLOC_IMMUTABLE) && (buf->content != NULL) && (buf->content != static_buf_content)) { xmlFree(buf->content); buf->content = NULL;}"
}
modules = []
View
@@ -8694,7 +8694,7 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
"xmlns: '%s' is not a valid URI\n",
URL, NULL, NULL);
} else {
- if ((ctxt->pedantic) && (uri->scheme == NULL)) {
+ if (uri->scheme == NULL) {
xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE,
"xmlns: URI %s is not absolute\n",
URL, NULL, NULL);
View
@@ -24,6 +24,7 @@
#include <libxml/xmlIO.h>
#include <libxml/c14n.h>
#include <libxml/xmlreader.h>
+#include <libxml/xmlsave.h>
#include "libxml_wrap.h"
#include "libxml2-py.h"
@@ -2761,6 +2762,9 @@ libxml_serializeNode(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
const char *encoding;
int format;
int len;
+ xmlSaveCtxtPtr ctxt;
+ xmlBufferPtr buf;
+ int options = 0;
if (!PyArg_ParseTuple(args, (char *) "Ozi:serializeNode", &pyobj_node,
&encoding, &format))
@@ -2773,137 +2777,52 @@ libxml_serializeNode(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
}
if (node->type == XML_DOCUMENT_NODE) {
doc = (xmlDocPtr) node;
- xmlDocDumpFormatMemoryEnc(doc, &c_retval, &len,
- (const char *) encoding, format);
- py_retval = libxml_charPtrWrap((char *) c_retval);
+ node = NULL;
#ifdef LIBXML_HTML_ENABLED
} else if (node->type == XML_HTML_DOCUMENT_NODE) {
- xmlOutputBufferPtr buf;
- xmlCharEncodingHandlerPtr handler = NULL;
-
doc = (xmlDocPtr) node;
- if (encoding != NULL)
- htmlSetMetaEncoding(doc, (const xmlChar *) encoding);
- encoding = (const char *) htmlGetMetaEncoding(doc);
-
- if (encoding != NULL) {
- handler = xmlFindCharEncodingHandler(encoding);
- if (handler == NULL) {
- Py_INCREF(Py_None);
- return (Py_None);
- }
- }
-
- /*
- * Fallback to HTML or ASCII when the encoding is unspecified
- */
- if (handler == NULL)
- handler = xmlFindCharEncodingHandler("HTML");
- if (handler == NULL)
- handler = xmlFindCharEncodingHandler("ascii");
-
- buf = xmlAllocOutputBuffer(handler);
- if (buf == NULL) {
- Py_INCREF(Py_None);
- return (Py_None);
- }
- htmlDocContentDumpFormatOutput(buf, doc, encoding, format);
- xmlOutputBufferFlush(buf);
- if (buf->conv != NULL) {
- len = buf->conv->use;
- c_retval = buf->conv->content;
- buf->conv->content = NULL;
- } else {
- len = buf->buffer->use;
- c_retval = buf->buffer->content;
- buf->buffer->content = NULL;
- }
- (void) xmlOutputBufferClose(buf);
- py_retval = libxml_charPtrWrap((char *) c_retval);
-#endif /* LIBXML_HTML_ENABLED */
+ node = NULL;
+#endif
} else {
if (node->type == XML_NAMESPACE_DECL)
doc = NULL;
else
doc = node->doc;
if ((doc == NULL) || (doc->type == XML_DOCUMENT_NODE)) {
- xmlOutputBufferPtr buf;
- xmlCharEncodingHandlerPtr handler = NULL;
-
- if (encoding != NULL) {
- handler = xmlFindCharEncodingHandler(encoding);
- if (handler == NULL) {
- Py_INCREF(Py_None);
- return (Py_None);
- }
- }
-
- buf = xmlAllocOutputBuffer(handler);
- if (buf == NULL) {
- Py_INCREF(Py_None);
- return (Py_None);
- }
- xmlNodeDumpOutput(buf, doc, node, 0, format, encoding);
- xmlOutputBufferFlush(buf);
- if (buf->conv != NULL) {
- len = buf->conv->use;
- c_retval = buf->conv->content;
- buf->conv->content = NULL;
- } else {
- len = buf->buffer->use;
- c_retval = buf->buffer->content;
- buf->buffer->content = NULL;
- }
- (void) xmlOutputBufferClose(buf);
- py_retval = libxml_charPtrWrap((char *) c_retval);
#ifdef LIBXML_HTML_ENABLED
} else if (doc->type == XML_HTML_DOCUMENT_NODE) {
- xmlOutputBufferPtr buf;
- xmlCharEncodingHandlerPtr handler = NULL;
-
- if (encoding != NULL)
- htmlSetMetaEncoding(doc, (const xmlChar *) encoding);
- encoding = (const char *) htmlGetMetaEncoding(doc);
- if (encoding != NULL) {
- handler = xmlFindCharEncodingHandler(encoding);
- if (handler == NULL) {
- Py_INCREF(Py_None);
- return (Py_None);
- }
- }
-
- /*
- * Fallback to HTML or ASCII when the encoding is unspecified
- */
- if (handler == NULL)
- handler = xmlFindCharEncodingHandler("HTML");
- if (handler == NULL)
- handler = xmlFindCharEncodingHandler("ascii");
-
- buf = xmlAllocOutputBuffer(handler);
- if (buf == NULL) {
- Py_INCREF(Py_None);
- return (Py_None);
- }
- htmlNodeDumpFormatOutput(buf, doc, node, encoding, format);
- xmlOutputBufferFlush(buf);
- if (buf->conv != NULL) {
- len = buf->conv->use;
- c_retval = buf->conv->content;
- buf->conv->content = NULL;
- } else {
- len = buf->buffer->use;
- c_retval = buf->buffer->content;
- buf->buffer->content = NULL;
- }
- (void) xmlOutputBufferClose(buf);
- py_retval = libxml_charPtrWrap((char *) c_retval);
#endif /* LIBXML_HTML_ENABLED */
} else {
Py_INCREF(Py_None);
return (Py_None);
}
}
+
+
+ buf = xmlBufferCreate();
+ if (buf == NULL) {
+ Py_INCREF(Py_None);
+ return (Py_None);
+ }
+ if (format) options |= XML_SAVE_FORMAT;
+ ctxt = xmlSaveToBuffer(buf, encoding, options);
+ if (ctxt == NULL) {
+ xmlBufferFree(buf);
+ Py_INCREF(Py_None);
+ return (Py_None);
+ }
+ if (node == NULL)
+ xmlSaveDoc(ctxt, doc);
+ else
+ xmlSaveTree(ctxt, node);
+ xmlSaveClose(ctxt);
+
+ c_retval = buf->content;
+ buf->content = NULL;
+
+ xmlBufferFree(buf);
+ py_retval = libxml_charPtrWrap((char *) c_retval);
+
return (py_retval);
}
View
@@ -33,7 +33,7 @@
static FILE *logfile = NULL;
static int verbose = 0;
-
+#define NB_EXPECTED_ERRORS 15
#if defined(_WIN32) && !defined(__CYGWIN__)
@@ -588,10 +588,14 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
printf("Total %d tests, no errors\n",
nb_tests);
} else {
- ret = 1;
+ ret = 1;
printf("Total %d tests, %d errors, %d leaks\n",
nb_tests, nb_errors, nb_leaks);
printf("See %s for detailed output\n", LOGFILE);
+ if ((nb_leaks == 0) && (nb_errors == NB_EXPECTED_ERRORS)) {
+ printf("%d errors were expected\n", nb_errors);
+ ret = 0;
+ }
}
xmlXPathFreeContext(ctxtXPath);
xmlCleanupParser();
View
@@ -599,9 +599,10 @@ static void des_xmlTextReaderPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderPtr val,
#endif
#define gen_nb_xmlBufferPtr 3
+static const char *static_buf_content = "a static buffer";
static xmlBufferPtr gen_xmlBufferPtr(int no, int nr ATTRIBUTE_UNUSED) {
if (no == 0) return(xmlBufferCreate());
- if (no == 1) return(xmlBufferCreateStatic((void *)"a static buffer", 13));
+ if (no == 1) return(xmlBufferCreateStatic((void *)static_buf_content, 13));
return(NULL);
}
static void des_xmlBufferPtr(int no ATTRIBUTE_UNUSED, xmlBufferPtr val, int nr ATTRIBUTE_UNUSED) {
@@ -18827,6 +18828,7 @@ test_xmlBufferSetAllocationScheme(void) {
scheme = gen_xmlBufferAllocationScheme(n_scheme, 1);
xmlBufferSetAllocationScheme(buf, scheme);
+ if ((buf != NULL) && (scheme == XML_BUFFER_ALLOC_IMMUTABLE) && (buf->content != NULL) && (buf->content != static_buf_content)) { xmlFree(buf->content); buf->content = NULL;}
call_tests++;
des_xmlBufferPtr(n_buf, buf, 0);
des_xmlBufferAllocationScheme(n_scheme, scheme, 1);
View
13 tree.c
@@ -680,7 +680,9 @@ xmlValidateNMToken(const xmlChar *value, int space) {
*/
void
xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme) {
- xmlBufferAllocScheme = scheme;
+ if ((scheme == XML_BUFFER_ALLOC_EXACT) ||
+ (scheme == XML_BUFFER_ALLOC_DOUBLEIT))
+ xmlBufferAllocScheme = scheme;
}
/**
@@ -6736,9 +6738,12 @@ xmlBufferSetAllocationScheme(xmlBufferPtr buf,
#endif
return;
}
- if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return;
-
- buf->alloc = scheme;
+ if ((buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) ||
+ (buf->alloc == XML_BUFFER_ALLOC_IO)) return;
+ if ((scheme == XML_BUFFER_ALLOC_DOUBLEIT) ||
+ (scheme == XML_BUFFER_ALLOC_EXACT) ||
+ (scheme == XML_BUFFER_ALLOC_IMMUTABLE))
+ buf->alloc = scheme;
}
/**
View
@@ -129,7 +129,11 @@ static TRIO_CONST char rcsid[] = "@(#)$Id$";
*/
#define TRIO_DOUBLE_INDEX(x) (((unsigned char *)&internalEndianMagic)[7-(x)])
+#if (defined(__BORLANDC__) && __BORLANDC__ >= 0x0590)
+static TRIO_CONST double internalEndianMagic = 7.949928895127362e-275;
+#else
static TRIO_CONST double internalEndianMagic = 7.949928895127363e-275;
+#endif
/* Mask for the exponent */
static TRIO_CONST unsigned char ieee_754_exponent_mask[] = {
Oops, something went wrong.

0 comments on commit da3fee4

Please sign in to comment.