applied patch from Aron Stansvik to add xmlTextReaderByteConsumed() added
* xmlreader.c include/libxml/xmlreader.h: applied patch from
Aron Stansvik to add xmlTextReaderByteConsumed()
* testReader.c: added a test option
* xmlschemastypes.c: fix a lack of pointer checking in APIs
Daniel
diff --git a/ChangeLog b/ChangeLog
index 3d949cb..74d9ad5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Feb 18 20:34:03 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+ * xmlreader.c include/libxml/xmlreader.h: applied patch from
+ Aron Stansvik to add xmlTextReaderByteConsumed()
+ * testReader.c: added a test option
+ * xmlschemastypes.c: fix a lack of pointer checking in APIs
+
Fri Feb 18 12:41:10 CET 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
* test/schemas/bug167754_0*: Added the regression test of Frans
diff --git a/include/libxml/xmlreader.h b/include/libxml/xmlreader.h
index 6c4c447..803f8e3 100644
--- a/include/libxml/xmlreader.h
+++ b/include/libxml/xmlreader.h
@@ -281,6 +281,13 @@
XMLPUBFUN int XMLCALL
xmlTextReaderStandalone (xmlTextReaderPtr reader);
+
+/*
+ * Index lookup
+ */
+XMLPUBFUN long XMLCALL
+ xmlTextReaderByteConsumed (xmlTextReaderPtr reader);
+
/*
* New more complete APIs for simpler creation and reuse of readers
*/
diff --git a/testReader.c b/testReader.c
index a874250..4d5711b 100644
--- a/testReader.c
+++ b/testReader.c
@@ -39,12 +39,14 @@
int noent = 0;
int count = 0;
int valid = 0;
+int consumed = 0;
static void usage(const char *progname) {
printf("Usage : %s [options] XMLfiles ...\n", progname);
printf("\tParse the XML files using the xmlTextReader API\n");
printf("\t --count: count the number of attribute and elements\n");
printf("\t --valid: validate the document\n");
+ printf("\t --consumed: count the number of bytes consumed\n");
exit(1);
}
static int elem, attrs;
@@ -87,6 +89,8 @@
/*
* Done, cleanup and status
*/
+ if (consumed)
+ printf("%ld bytes consumed by parser\n", xmlTextReaderByteConsumed(reader));
xmlFreeTextReader(reader);
if (ret != 0) {
printf("%s : failed to parse\n", filename);
@@ -113,6 +117,8 @@
dump++;
else if ((!strcmp(argv[i], "-count")) || (!strcmp(argv[i], "--count")))
count++;
+ else if ((!strcmp(argv[i], "-consumed")) || (!strcmp(argv[i], "--consumed")))
+ consumed++;
else if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid")))
valid++;
else if ((!strcmp(argv[i], "-noent")) ||
diff --git a/xmlreader.c b/xmlreader.c
index 4215261..e5b8898 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -4517,6 +4517,27 @@
}
/**
+ * xmlTextReaderByteConsumed:
+ * @reader: an XML reader
+ *
+ * This function provides the current index of the parser used
+ * by the reader, relative to the start of the current entity.
+ * This function actually just wraps a call to xmlBytesConsumed()
+ * for the parser context associated with the reader.
+ * See xmlBytesConsumed() for more information.
+ *
+ * Returns the index in bytes from the beginning of the entity or -1
+ * in case the index could not be computed.
+ */
+long
+xmlTextReaderByteConsumed(xmlTextReaderPtr reader) {
+ if ((reader == NULL) || (reader->ctxt == NULL))
+ return(-1);
+ return(xmlByteConsumed(reader->ctxt));
+}
+
+
+/**
* xmlReaderWalker:
* @doc: a preparsed document
*
diff --git a/xmlschemastypes.c b/xmlschemastypes.c
index bc31044..01eb497 100644
--- a/xmlschemastypes.c
+++ b/xmlschemastypes.c
@@ -4212,6 +4212,8 @@
xmlSchemaCompareValues(xmlSchemaValPtr x, xmlSchemaValPtr y) {
xmlSchemaWhitespaceValueType xws, yws;
+ if ((x == NULL) || (y == NULL))
+ return(-2);
if (x->type == XML_SCHEMAS_STRING)
xws = XML_SCHEMA_WHITESPACE_PRESERVE;
else if (x->type == XML_SCHEMAS_NORMSTRING)