Commit 5e094143 authored by Daniel Veillard's avatar Daniel Veillard

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
parent 0c347767
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> Fri Feb 18 12:41:10 CET 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
* test/schemas/bug167754_0*: Added the regression test of Frans * test/schemas/bug167754_0*: Added the regression test of Frans
......
...@@ -281,6 +281,13 @@ XMLPUBFUN const xmlChar * XMLCALL ...@@ -281,6 +281,13 @@ XMLPUBFUN const xmlChar * XMLCALL
XMLPUBFUN int XMLCALL XMLPUBFUN int XMLCALL
xmlTextReaderStandalone (xmlTextReaderPtr reader); xmlTextReaderStandalone (xmlTextReaderPtr reader);
/*
* Index lookup
*/
XMLPUBFUN long XMLCALL
xmlTextReaderByteConsumed (xmlTextReaderPtr reader);
/* /*
* New more complete APIs for simpler creation and reuse of readers * New more complete APIs for simpler creation and reuse of readers
*/ */
......
...@@ -39,12 +39,14 @@ int dump = 0; ...@@ -39,12 +39,14 @@ int dump = 0;
int noent = 0; int noent = 0;
int count = 0; int count = 0;
int valid = 0; int valid = 0;
int consumed = 0;
static void usage(const char *progname) { static void usage(const char *progname) {
printf("Usage : %s [options] XMLfiles ...\n", progname); printf("Usage : %s [options] XMLfiles ...\n", progname);
printf("\tParse the XML files using the xmlTextReader API\n"); printf("\tParse the XML files using the xmlTextReader API\n");
printf("\t --count: count the number of attribute and elements\n"); printf("\t --count: count the number of attribute and elements\n");
printf("\t --valid: validate the document\n"); printf("\t --valid: validate the document\n");
printf("\t --consumed: count the number of bytes consumed\n");
exit(1); exit(1);
} }
static int elem, attrs; static int elem, attrs;
...@@ -87,6 +89,8 @@ static void handleFile(const char *filename) { ...@@ -87,6 +89,8 @@ static void handleFile(const char *filename) {
/* /*
* Done, cleanup and status * Done, cleanup and status
*/ */
if (consumed)
printf("%ld bytes consumed by parser\n", xmlTextReaderByteConsumed(reader));
xmlFreeTextReader(reader); xmlFreeTextReader(reader);
if (ret != 0) { if (ret != 0) {
printf("%s : failed to parse\n", filename); printf("%s : failed to parse\n", filename);
...@@ -113,6 +117,8 @@ int main(int argc, char **argv) { ...@@ -113,6 +117,8 @@ int main(int argc, char **argv) {
dump++; dump++;
else if ((!strcmp(argv[i], "-count")) || (!strcmp(argv[i], "--count"))) else if ((!strcmp(argv[i], "-count")) || (!strcmp(argv[i], "--count")))
count++; count++;
else if ((!strcmp(argv[i], "-consumed")) || (!strcmp(argv[i], "--consumed")))
consumed++;
else if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid"))) else if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid")))
valid++; valid++;
else if ((!strcmp(argv[i], "-noent")) || else if ((!strcmp(argv[i], "-noent")) ||
......
...@@ -4516,6 +4516,27 @@ xmlTextReaderSetup(xmlTextReaderPtr reader, ...@@ -4516,6 +4516,27 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
return (0); return (0);
} }
/**
* 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: * xmlReaderWalker:
* @doc: a preparsed document * @doc: a preparsed document
......
...@@ -4212,6 +4212,8 @@ int ...@@ -4212,6 +4212,8 @@ int
xmlSchemaCompareValues(xmlSchemaValPtr x, xmlSchemaValPtr y) { xmlSchemaCompareValues(xmlSchemaValPtr x, xmlSchemaValPtr y) {
xmlSchemaWhitespaceValueType xws, yws; xmlSchemaWhitespaceValueType xws, yws;
if ((x == NULL) || (y == NULL))
return(-2);
if (x->type == XML_SCHEMAS_STRING) if (x->type == XML_SCHEMAS_STRING)
xws = XML_SCHEMA_WHITESPACE_PRESERVE; xws = XML_SCHEMA_WHITESPACE_PRESERVE;
else if (x->type == XML_SCHEMAS_NORMSTRING) else if (x->type == XML_SCHEMAS_NORMSTRING)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment