From 8af7d22ff029796484c78a16d4c6d44a47cb5729 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Mon, 19 Apr 2021 21:44:38 +0200 Subject: [PATCH] lib: Allow test suite to access raw accounting values --- expat/lib/internal.h | 7 +++++++ expat/lib/xmlparse.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/expat/lib/internal.h b/expat/lib/internal.h index 40c50333..ce6d27a2 100644 --- a/expat/lib/internal.h +++ b/expat/lib/internal.h @@ -139,6 +139,8 @@ 8388608 // 8 MiB, 2^23 /* NOTE END */ +#include "expat.h" // so we can use type XML_Parser below + #ifdef __cplusplus extern "C" { #endif @@ -146,6 +148,11 @@ extern "C" { void _INTERNAL_trim_to_complete_utf8_characters(const char *from, const char **fromLimRef); +#if defined(XML_DTD) +unsigned long long testingAccountingGetCountBytesDirect(XML_Parser parser); +unsigned long long testingAccountingGetCountBytesIndirect(XML_Parser parser); +#endif + #ifdef __cplusplus } #endif diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c index 4628def9..fce7447d 100644 --- a/expat/lib/xmlparse.c +++ b/expat/lib/xmlparse.c @@ -7357,6 +7357,20 @@ accountingDiffTolerated(XML_Parser originParser, int tok, const char *before, return tolerated; } +unsigned long long +testingAccountingGetCountBytesDirect(XML_Parser parser) { + if (! parser) + return 0; + return parser->m_accounting.countBytesDirect; +} + +unsigned long long +testingAccountingGetCountBytesIndirect(XML_Parser parser) { + if (! parser) + return 0; + return parser->m_accounting.countBytesIndirect; +} + static void entityTrackingReportStats(XML_Parser rootParser, ENTITY *entity, const char *action, int sourceLine) {