From a100265576b58e6f80070a893f05c810731f69e1 Mon Sep 17 00:00:00 2001 From: kwaclaw Date: Fri, 23 Dec 2005 14:45:27 +0000 Subject: [PATCH] Added support for 64-bit integers when reporting byte indexes, line and column numbers. Can be turned on/off using the XML_LARGE_SIZE switch. --- Changes | 4 +++- doc/reference.html | 16 +++++++++++++--- lib/expat.h | 6 +++--- lib/expat_external.h | 8 ++++++++ lib/xmlparse.c | 8 ++++---- lib/xmltok.h | 4 ++-- 6 files changed, 33 insertions(+), 13 deletions(-) diff --git a/Changes b/Changes index 16ffadd..536a634 100644 --- a/Changes +++ b/Changes @@ -1,8 +1,10 @@ -Release 1.95.9 TBD +Release 2.0 TBD - We no longer use the "check" library for C unit testing; we always use the (partial) internal implementation of the API. - Report XML_NS setting via XML_GetFeatureList(). - Fixed headers for use from C++. + - Added XML_LARGE_SIZE switch to enable 64bit values for + byte indexes and line/column numbers. - Updated to use libtool 1.5.10 (the most recent). - Added support for AmigaOS. - Some mostly minor bug fixes. SF issues include: 1006708, diff --git a/doc/reference.html b/doc/reference.html index 574ae31..b91797b 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -344,6 +344,16 @@ defined using the wchar_t type; otherwise, unsigned short is used. Defining this implies XML_UNICODE. +
XML_LARGE_SIZE
+
If defined, causes the XML_Size and XML_Index +integer types to be at least 64 bits in size. This is intended to support +processing of very large input streams, where the return values of +XML_GetCurrentByteIndex, +XML_GetCurrentLineNumber and +XML_GetCurrentColumnNumber +could overflow. It may not be supported by all compilers, and is turned +off by default.
+
XML_CONTEXT_BYTES
The number of input bytes of markup context which the parser will ensure are available for reporting via
-long XMLCALL
+XML_Index XMLCALL
 XML_GetCurrentByteIndex(XML_Parser p);
 
@@ -1916,7 +1926,7 @@ the values returned by
-int XMLCALL
+XML_Size XMLCALL
 XML_GetCurrentLineNumber(XML_Parser p);
 
@@ -1925,7 +1935,7 @@ Return the line number of the position. The first line is reported as
-int XMLCALL
+XML_Size XMLCALL
 XML_GetCurrentColumnNumber(XML_Parser p);
 
diff --git a/lib/expat.h b/lib/expat.h index ac1053f..09c5d14 100644 --- a/lib/expat.h +++ b/lib/expat.h @@ -905,9 +905,9 @@ XML_GetErrorCode(XML_Parser parser); was detected; otherwise the location is the location of the last parse event, as described above. */ -XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser); -XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser); -XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser); +XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser); +XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser); +XMLPARSEAPI(XML_Index) XML_GetCurrentByteIndex(XML_Parser parser); /* Return the number of bytes in the current event. Returns 0 if the event is in an internal entity. diff --git a/lib/expat_external.h b/lib/expat_external.h index 7202e11..ddb162d 100644 --- a/lib/expat_external.h +++ b/lib/expat_external.h @@ -94,6 +94,14 @@ typedef char XML_Char; typedef char XML_LChar; #endif /* XML_UNICODE */ +#ifdef XML_LARGE_SIZE /* Use large integers for counts and positions. */ +typedef long long XML_Index; +typedef unsigned long long XML_Size; +#else +typedef long XML_Index; +typedef unsigned long XML_Size; +#endif /* XML_LARGE_SIZE */ + #ifdef __cplusplus } #endif diff --git a/lib/xmlparse.c b/lib/xmlparse.c index 453077f..04f8b91 100644 --- a/lib/xmlparse.c +++ b/lib/xmlparse.c @@ -458,7 +458,7 @@ struct XML_ParserStruct { char *m_bufferEnd; /* allocated end of buffer */ const char *m_bufferLim; - long m_parseEndByteIndex; + XML_Index m_parseEndByteIndex; const char *m_parseEndPtr; XML_Char *m_dataBuf; XML_Char *m_dataBufEnd; @@ -1751,7 +1751,7 @@ XML_GetErrorCode(XML_Parser parser) return errorCode; } -long XMLCALL +XML_Index XMLCALL XML_GetCurrentByteIndex(XML_Parser parser) { if (eventPtr) @@ -1780,7 +1780,7 @@ XML_GetInputContext(XML_Parser parser, int *offset, int *size) return (char *) 0; } -int XMLCALL +XML_Size XMLCALL XML_GetCurrentLineNumber(XML_Parser parser) { if (eventPtr && eventPtr >= positionPtr) { @@ -1790,7 +1790,7 @@ XML_GetCurrentLineNumber(XML_Parser parser) return position.lineNumber + 1; } -int XMLCALL +XML_Size XMLCALL XML_GetCurrentColumnNumber(XML_Parser parser) { if (eventPtr && eventPtr >= positionPtr) { diff --git a/lib/xmltok.h b/lib/xmltok.h index 1ecd05f..ca867aa 100644 --- a/lib/xmltok.h +++ b/lib/xmltok.h @@ -111,8 +111,8 @@ extern "C" { typedef struct position { /* first line and first column are 0 not 1 */ - unsigned long lineNumber; - unsigned long columnNumber; + XML_Size lineNumber; + XML_Size columnNumber; } POSITION; typedef struct { -- 2.11.4.GIT