From: James Clark Date: Sun, 25 Apr 1999 11:34:07 +0000 (+0000) Subject: Add GetCurrentByteCount() X-Git-Tag: V19990425~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f9560ef835d1546a4d65aacaf983e1a68e4f9ba0;p=libexpat Add GetCurrentByteCount() --- diff --git a/expat/xmlparse/xmlparse.c b/expat/xmlparse/xmlparse.c index c441ba10..35ce2fb3 100755 --- a/expat/xmlparse/xmlparse.c +++ b/expat/xmlparse/xmlparse.c @@ -864,6 +864,13 @@ long XML_GetCurrentByteIndex(XML_Parser parser) return -1; } +int XML_GetCurrentByteCount(XML_Parser parser) +{ + if (eventEndPtr && eventPtr) + return eventEndPtr - eventPtr; + return 0; +} + int XML_GetCurrentLineNumber(XML_Parser parser) { if (eventPtr) { diff --git a/expat/xmlparse/xmlparse.h b/expat/xmlparse/xmlparse.h index c3af771a..2c8f7d43 100755 --- a/expat/xmlparse/xmlparse.h +++ b/expat/xmlparse/xmlparse.h @@ -448,6 +448,11 @@ int XMLPARSEAPI XML_GetCurrentLineNumber(XML_Parser parser); int XMLPARSEAPI XML_GetCurrentColumnNumber(XML_Parser parser); long XMLPARSEAPI XML_GetCurrentByteIndex(XML_Parser parser); +/* Return the number of bytes in the current event. +Returns 0 if the event is in an internal entity. */ + +int XMLPARSEAPI XML_GetCurrentByteCount(XML_Parser parser); + /* For backwards compatibility with previous versions. */ #define XML_GetErrorLineNumber XML_GetCurrentLineNumber #define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber diff --git a/expat/xmlwf/xmlwf.c b/expat/xmlwf/xmlwf.c index 86eda0fa..5580afa9 100755 --- a/expat/xmlwf/xmlwf.c +++ b/expat/xmlwf/xmlwf.c @@ -235,8 +235,9 @@ void metaLocation(XML_Parser parser) if (uri) ftprintf(XML_GetUserData(parser), T(" uri=\"%s\""), uri); ftprintf(XML_GetUserData(parser), - T(" byte=\"%ld\" line=\"%d\" col=\"%d\""), + T(" byte=\"%ld\" nbytes=\"%d\" line=\"%d\" col=\"%d\""), XML_GetCurrentByteIndex(parser), + XML_GetCurrentByteCount(parser), XML_GetCurrentLineNumber(parser), XML_GetCurrentColumnNumber(parser)); }