mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-27 18:50:07 +03:00
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
This commit is contained in:
parent
0c34776789
commit
5e094143e4
@ -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
|
||||
|
@ -281,6 +281,13 @@ XMLPUBFUN const xmlChar * XMLCALL
|
||||
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
|
||||
*/
|
||||
|
@ -39,12 +39,14 @@ int dump = 0;
|
||||
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 @@ static void handleFile(const char *filename) {
|
||||
/*
|
||||
* 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 @@ int main(int argc, char **argv) {
|
||||
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")) ||
|
||||
|
21
xmlreader.c
21
xmlreader.c
@ -4516,6 +4516,27 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
|
||||
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:
|
||||
* @doc: a preparsed document
|
||||
|
@ -4212,6 +4212,8 @@ int
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user