From 3e070384c2645b9145dd7abeca711dc03f82a00c Mon Sep 17 00:00:00 2001 From: kwaclaw Date: Tue, 16 Mar 2004 22:14:30 +0000 Subject: [PATCH] Changed to allow aborting a suspended parser instance. --- lib/expat.h | 9 +++++---- lib/xmlparse.c | 8 ++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/expat.h b/lib/expat.h index 7e12489..d6e06d1 100644 --- a/lib/expat.h +++ b/lib/expat.h @@ -829,8 +829,9 @@ XMLPARSEAPI(enum XML_Status) XML_ParseBuffer(XML_Parser parser, int len, int isFinal); /* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return. - Must be called from within a call-back handler. Some call-backs - may still follow because they would otherwise get lost. Examples: + Must be called from within a call-back handler, except when aborting + (resumable = 0) an already suspended parser. Some call-backs may + still follow because they would otherwise get lost. Examples: - endElementHandler() for empty elements when stopped in startElementHandler(), - endNameSpaceDeclHandler() when stopped in endElementHandler(), @@ -840,8 +841,8 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal); except when parsing an external parameter entity and resumable != 0. Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise. Possible error codes: - - XML_ERROR_SUSPENDED: when the parser is already suspended. - - XML_ERROR_FINISHED: when the parser has already finished. + - XML_ERROR_SUSPENDED: when suspending an already suspended parser. + - XML_ERROR_FINISHED: when the parser has already finished. - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE. When resumable != 0 (true) then parsing is suspended, that is, diff --git a/lib/xmlparse.c b/lib/xmlparse.c index 2d84ea0..01542e1 100644 --- a/lib/xmlparse.c +++ b/lib/xmlparse.c @@ -1668,8 +1668,12 @@ XML_StopParser(XML_Parser parser, XML_Bool resumable) { switch (parsing) { case XML_SUSPENDED: - errorCode = XML_ERROR_SUSPENDED; - return XML_STATUS_ERROR; + if (resumable) { + errorCode = XML_ERROR_SUSPENDED; + return XML_STATUS_ERROR; + } + parsing = XML_FINISHED; + break; case XML_FINISHED: errorCode = XML_ERROR_FINISHED; return XML_STATUS_ERROR; -- 2.11.4.GIT