зеркало из https://github.com/mozilla/gecko-dev.git
Back out to fix orange.
This commit is contained in:
Родитель
92bf9b9fe0
Коммит
887499750a
|
@ -1,6 +1,6 @@
|
|||
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||
and Clark Cooper
|
||||
Copyright (c) 2001, 2002, 2003 Expat maintainers.
|
||||
Copyright (c) 2001, 2002 Expat maintainers.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
|
|
@ -133,9 +133,6 @@ typedef char XML_LChar;
|
|||
#define XML_Parse MOZ_XML_Parse
|
||||
#define XML_GetBuffer MOZ_XML_GetBuffer
|
||||
#define XML_ParseBuffer MOZ_XML_ParseBuffer
|
||||
#define XML_StopParser MOZ_XML_StopParser
|
||||
#define XML_ResumeParser MOZ_XML_ResumeParser
|
||||
#define XML_GetParsingStatus MOZ_XML_GetParsingStatus
|
||||
#define XML_ExternalEntityParserCreate MOZ_XML_ExternalEntityParserCreate
|
||||
#define XML_SetParamEntityParsing MOZ_XML_SetParamEntityParsing
|
||||
#define XML_GetErrorCode MOZ_XML_GetErrorCode
|
||||
|
|
|
@ -51,9 +51,7 @@ CSRCS = \
|
|||
xmltok.c \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
expat.h \
|
||||
expat_external.h
|
||||
EXPORTS = expat.h
|
||||
|
||||
# We want only the static lib, not the shared lib
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
|
|
@ -15,11 +15,103 @@
|
|||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "expat_external.h"
|
||||
|
||||
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
|
||||
#define XML_USE_MSC_EXTENSIONS 1
|
||||
#endif
|
||||
|
||||
/* Expat tries very hard to make the API boundary very specifically
|
||||
defined. There are two macros defined to control this boundary;
|
||||
each of these can be defined before including this header to
|
||||
achieve some different behavior, but doing so it not recommended or
|
||||
tested frequently.
|
||||
|
||||
XMLCALL - The calling convention to use for all calls across the
|
||||
"library boundary." This will default to cdecl, and
|
||||
try really hard to tell the compiler that's what we
|
||||
want.
|
||||
|
||||
XMLIMPORT - Whatever magic is needed to note that a function is
|
||||
to be imported from a dynamically loaded library
|
||||
(.dll, .so, or .sl, depending on your platform).
|
||||
|
||||
The XMLCALL macro was added in Expat 1.95.7. The only one which is
|
||||
expected to be directly useful in client code is XMLCALL.
|
||||
|
||||
Note that on at least some Unix versions, the Expat library must be
|
||||
compiled with the cdecl calling convention as the default since
|
||||
system headers may assume the cdecl convention.
|
||||
*/
|
||||
#ifndef XMLCALL
|
||||
#if defined(XML_USE_MSC_EXTENSIONS)
|
||||
#define XMLCALL __cdecl
|
||||
#elif defined(__GNUC__)
|
||||
#define XMLCALL __attribute__((cdecl))
|
||||
#else
|
||||
/* For any platform which uses this definition and supports more than
|
||||
one calling convention, we need to extend this definition to
|
||||
declare the convention used on that platform, if it's possible to
|
||||
do so.
|
||||
|
||||
If this is the case for your platform, please file a bug report
|
||||
with information on how to identify your platform via the C
|
||||
pre-processor and how to specify the same calling convention as the
|
||||
platform's malloc() implementation.
|
||||
*/
|
||||
#define XMLCALL
|
||||
#endif
|
||||
#endif /* not defined XMLCALL */
|
||||
|
||||
|
||||
#if !defined(XML_STATIC) && !defined(XMLIMPORT)
|
||||
#ifndef XML_BUILDING_EXPAT
|
||||
/* using Expat from an application */
|
||||
|
||||
#ifdef XML_USE_MSC_EXTENSIONS
|
||||
#define XMLIMPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* not defined XML_STATIC */
|
||||
|
||||
/* If we didn't define it above, define it away: */
|
||||
#ifndef XMLIMPORT
|
||||
#define XMLIMPORT
|
||||
#endif
|
||||
|
||||
|
||||
#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
#define XML_UNICODE
|
||||
#endif
|
||||
|
||||
struct XML_ParserStruct;
|
||||
typedef struct XML_ParserStruct *XML_Parser;
|
||||
|
||||
/* BEGIN MOZILLA CHANGE (typedef XML_Char to PRUnichar) */
|
||||
#if 0
|
||||
|
||||
#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
typedef wchar_t XML_Char;
|
||||
typedef wchar_t XML_LChar;
|
||||
#else
|
||||
typedef unsigned short XML_Char;
|
||||
typedef char XML_LChar;
|
||||
#endif /* XML_UNICODE_WCHAR_T */
|
||||
#else /* Information is UTF-8 encoded. */
|
||||
typedef char XML_Char;
|
||||
typedef char XML_LChar;
|
||||
#endif /* XML_UNICODE */
|
||||
|
||||
#endif
|
||||
/* END MOZILLA CHANGE */
|
||||
|
||||
/* Should this be defined using stdbool.h when C99 is available? */
|
||||
typedef unsigned char XML_Bool;
|
||||
#define XML_TRUE ((XML_Bool) 1)
|
||||
|
@ -41,10 +133,8 @@ typedef unsigned char XML_Bool;
|
|||
enum XML_Status {
|
||||
XML_STATUS_ERROR = 0,
|
||||
#define XML_STATUS_ERROR XML_STATUS_ERROR
|
||||
XML_STATUS_OK = 1,
|
||||
XML_STATUS_OK = 1
|
||||
#define XML_STATUS_OK XML_STATUS_OK
|
||||
XML_STATUS_SUSPENDED = 2
|
||||
#define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED
|
||||
};
|
||||
|
||||
enum XML_Error {
|
||||
|
@ -75,19 +165,10 @@ enum XML_Error {
|
|||
XML_ERROR_ENTITY_DECLARED_IN_PE,
|
||||
XML_ERROR_FEATURE_REQUIRES_XML_DTD,
|
||||
XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING,
|
||||
/* Added in 1.95.7. */
|
||||
XML_ERROR_UNBOUND_PREFIX,
|
||||
/* Added in 1.95.8. */
|
||||
XML_ERROR_UNDECLARING_PREFIX,
|
||||
XML_ERROR_INCOMPLETE_PE,
|
||||
XML_ERROR_XML_DECL,
|
||||
XML_ERROR_TEXT_DECL,
|
||||
XML_ERROR_PUBLICID,
|
||||
XML_ERROR_SUSPENDED,
|
||||
XML_ERROR_NOT_SUSPENDED,
|
||||
XML_ERROR_ABORTED,
|
||||
XML_ERROR_FINISHED,
|
||||
XML_ERROR_SUSPEND_PE,
|
||||
XML_ERROR_UNBOUND_PREFIX
|
||||
/* BEGIN MOZILLA CHANGE (blocking parser) */
|
||||
, XML_ERROR_SUSPENDED,
|
||||
/* END MOZILLA CHANGE */
|
||||
/* BEGIN MOZILLA CHANGE (backport of bug fix from Expat trunk) */
|
||||
XML_ERROR_RESERVED_PREFIX_XML,
|
||||
XML_ERROR_RESERVED_PREFIX_XMLNS,
|
||||
|
@ -191,9 +272,9 @@ XML_SetXmlDeclHandler(XML_Parser parser,
|
|||
|
||||
|
||||
typedef struct {
|
||||
void *(*malloc_fcn)(size_t size);
|
||||
void *(*realloc_fcn)(void *ptr, size_t size);
|
||||
void (*free_fcn)(void *ptr);
|
||||
void *(XMLCALL *malloc_fcn)(size_t size);
|
||||
void *(XMLCALL *realloc_fcn)(void *ptr, size_t size);
|
||||
void (XMLCALL *free_fcn)(void *ptr);
|
||||
} XML_Memory_Handling_Suite;
|
||||
|
||||
/* Constructs a new parser; encoding is the encoding specified by the
|
||||
|
@ -533,12 +614,10 @@ XML_SetElementHandler(XML_Parser parser,
|
|||
XML_EndElementHandler end);
|
||||
|
||||
XMLPARSEAPI(void)
|
||||
XML_SetStartElementHandler(XML_Parser parser,
|
||||
XML_StartElementHandler handler);
|
||||
XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
|
||||
|
||||
XMLPARSEAPI(void)
|
||||
XML_SetEndElementHandler(XML_Parser parser,
|
||||
XML_EndElementHandler handler);
|
||||
XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
|
||||
|
||||
XMLPARSEAPI(void)
|
||||
XML_SetCharacterDataHandler(XML_Parser parser,
|
||||
|
@ -627,8 +706,7 @@ XML_SetExternalEntityRefHandler(XML_Parser parser,
|
|||
instead of the parser object.
|
||||
*/
|
||||
XMLPARSEAPI(void)
|
||||
XML_SetExternalEntityRefHandlerArg(XML_Parser parser,
|
||||
void *arg);
|
||||
XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
|
||||
|
||||
XMLPARSEAPI(void)
|
||||
XML_SetSkippedEntityHandler(XML_Parser parser,
|
||||
|
@ -691,9 +769,6 @@ XML_UseParserAsHandlerArg(XML_Parser parser);
|
|||
specified in the document. In such a case the parser will call the
|
||||
externalEntityRefHandler with a value of NULL for the systemId
|
||||
argument (the publicId and context arguments will be NULL as well).
|
||||
Note: For the purpose of checking WFC: Entity Declared, passing
|
||||
useDTD == XML_TRUE will make the parser behave as if the document
|
||||
had a DTD with an external subset.
|
||||
Note: If this function is called, then this must be done before
|
||||
the first call to XML_Parse or XML_ParseBuffer, since it will
|
||||
have no effect after that. Returns
|
||||
|
@ -757,74 +832,13 @@ XML_GetBuffer(XML_Parser parser, int len);
|
|||
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, 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(),
|
||||
and possibly others.
|
||||
|
||||
Can be called from most handlers, including DTD related call-backs,
|
||||
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 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,
|
||||
XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED.
|
||||
Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer()
|
||||
return XML_STATUS_ERROR with error code XML_ERROR_ABORTED.
|
||||
|
||||
*Note*:
|
||||
This will be applied to the current parser instance only, that is, if
|
||||
there is a parent parser then it will continue parsing when the
|
||||
externalEntityRefHandler() returns. It is up to the implementation of
|
||||
the externalEntityRefHandler() to call XML_StopParser() on the parent
|
||||
parser (recursively), if one wants to stop parsing altogether.
|
||||
|
||||
When suspended, parsing can be resumed by calling XML_ResumeParser().
|
||||
*/
|
||||
/* BEGIN MOZILLA CHANGE (blocking parser) */
|
||||
XMLPARSEAPI(enum XML_Status)
|
||||
XML_StopParser(XML_Parser parser, XML_Bool resumable);
|
||||
MOZ_XML_StopParser(XML_Parser parser, XML_Bool resumable);
|
||||
|
||||
/* Resumes parsing after it has been suspended with XML_StopParser().
|
||||
Must not be called from within a handler call-back. Returns same
|
||||
status codes as XML_Parse() or XML_ParseBuffer().
|
||||
Additional error code XML_ERROR_NOT_SUSPENDED possible.
|
||||
|
||||
*Note*:
|
||||
This must be called on the most deeply nested child parser instance
|
||||
first, and on its parent parser only after the child parser has finished,
|
||||
to be applied recursively until the document entity's parser is restarted.
|
||||
That is, the parent parser will not resume by itself and it is up to the
|
||||
application to call XML_ResumeParser() on it at the appropriate moment.
|
||||
*/
|
||||
XMLPARSEAPI(enum XML_Status)
|
||||
XML_ResumeParser(XML_Parser parser);
|
||||
|
||||
enum XML_Parsing {
|
||||
XML_INITIALIZED,
|
||||
XML_PARSING,
|
||||
XML_FINISHED,
|
||||
XML_SUSPENDED
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
enum XML_Parsing parsing;
|
||||
XML_Bool finalBuffer;
|
||||
} XML_ParsingStatus;
|
||||
|
||||
/* Returns status of parser with respect to being initialized, parsing,
|
||||
finished, or suspended and processing the final buffer.
|
||||
XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus,
|
||||
XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED
|
||||
*/
|
||||
XMLPARSEAPI(void)
|
||||
XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status);
|
||||
MOZ_XML_ResumeParser(XML_Parser parser);
|
||||
/* END MOZILLA CHANGE */
|
||||
|
||||
/* Creates an XML_Parser object that can parse an external general
|
||||
entity; context is a '\0'-terminated string specifying the parse
|
||||
|
@ -1000,7 +1014,7 @@ XML_GetFeatureList(void);
|
|||
*/
|
||||
#define XML_MAJOR_VERSION 1
|
||||
#define XML_MINOR_VERSION 95
|
||||
#define XML_MICRO_VERSION 8
|
||||
#define XML_MICRO_VERSION 7
|
||||
|
||||
/* BEGIN MOZILLA CHANGE (Report opening tag of mismatched closing tag) */
|
||||
XMLPARSEAPI(const XML_Char*)
|
||||
|
|
|
@ -20,10 +20,7 @@
|
|||
and therefore subject to change.
|
||||
*/
|
||||
|
||||
/* BEGIN MOZILLA CHANGE (https://bugzilla.mozilla.org/show_bug.cgi?id=297604) */
|
||||
// #if defined(__GNUC__) && defined(__i386__)
|
||||
#if defined(__GNUC__) && defined(__i386__) && !defined(XP_MACOSX)
|
||||
/* END MOZILLA CHANGE */
|
||||
/* We'll use this version by default only where we know it helps.
|
||||
|
||||
regparm() generates warnings on Solaris boxes. See SF bug #692878.
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -2,8 +2,6 @@
|
|||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef COMPILED_FROM_DSP
|
||||
#include "winconfig.h"
|
||||
#elif defined(MACOS_CLASSIC)
|
||||
|
@ -14,7 +12,6 @@
|
|||
#endif
|
||||
#endif /* ndef COMPILED_FROM_DSP */
|
||||
|
||||
#include "expat_external.h"
|
||||
#include "internal.h"
|
||||
#include "xmlrole.h"
|
||||
#include "ascii.h"
|
||||
|
@ -373,8 +370,6 @@ internalSubset(PROLOG_STATE *state,
|
|||
case XML_TOK_CLOSE_BRACKET:
|
||||
state->handler = doctype5;
|
||||
return XML_ROLE_DOCTYPE_NONE;
|
||||
case XML_TOK_NONE:
|
||||
return XML_ROLE_NONE;
|
||||
}
|
||||
return common(state, tok);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef COMPILED_FROM_DSP
|
||||
#include "winconfig.h"
|
||||
#elif defined(MACOS_CLASSIC)
|
||||
|
@ -14,7 +12,6 @@
|
|||
#endif
|
||||
#endif /* ndef COMPILED_FROM_DSP */
|
||||
|
||||
#include "expat_external.h"
|
||||
#include "internal.h"
|
||||
#include "xmltok.h"
|
||||
#include "nametab.h"
|
||||
|
@ -1249,7 +1246,7 @@ XmlUtf16Encode(int charNum, unsigned short *buf)
|
|||
|
||||
struct unknown_encoding {
|
||||
struct normal_encoding normal;
|
||||
CONVERTER convert;
|
||||
int (*convert)(void *userData, const char *p);
|
||||
void *userData;
|
||||
unsigned short utf16[256];
|
||||
char utf8[256][4];
|
||||
|
|
|
@ -281,8 +281,7 @@ int FASTCALL XmlUtf8Encode(int charNumber, char *buf);
|
|||
int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf);
|
||||
int XmlSizeOfUnknownEncoding(void);
|
||||
|
||||
|
||||
typedef int (XMLCALL *CONVERTER) (void *userData, const char *p);
|
||||
typedef int (*CONVERTER)(void *userData, const char *p);
|
||||
|
||||
ENCODING *
|
||||
XmlInitUnknownEncoding(void *mem,
|
||||
|
|
|
@ -386,7 +386,7 @@ nsExpatDriver::HandleEndElement(const PRUnichar *aValue)
|
|||
if (mSink &&
|
||||
mSink->HandleEndElement(aValue) == NS_ERROR_HTMLPARSER_BLOCK) {
|
||||
mInternalState = NS_ERROR_HTMLPARSER_BLOCK;
|
||||
XML_StopParser(mExpatParser, XML_TRUE);
|
||||
MOZ_XML_StopParser(mExpatParser, XML_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -453,7 +453,7 @@ nsExpatDriver::HandleProcessingInstruction(const PRUnichar *aTarget,
|
|||
mSink->HandleProcessingInstruction(aTarget, aData) ==
|
||||
NS_ERROR_HTMLPARSER_BLOCK) {
|
||||
mInternalState = NS_ERROR_HTMLPARSER_BLOCK;
|
||||
XML_StopParser(mExpatParser, XML_TRUE);
|
||||
MOZ_XML_StopParser(mExpatParser, XML_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -573,9 +573,10 @@ ExternalDTDStreamReaderFunc(nsIUnicharInputStream* aIn,
|
|||
PRUint32 aCount,
|
||||
PRUint32 *aWriteCount)
|
||||
{
|
||||
// Pass the buffer to expat for parsing.
|
||||
// Pass the buffer to expat for parsing. XML_Parse returns 0 for
|
||||
// fatal errors.
|
||||
if (XML_Parse((XML_Parser)aClosure, (const char *)aFromSegment,
|
||||
aCount * sizeof(PRUnichar), 0) == XML_STATUS_OK) {
|
||||
aCount * sizeof(PRUnichar), 0)) {
|
||||
*aWriteCount = aCount;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -847,16 +848,8 @@ nsExpatDriver::ParseBuffer(const char* aBuffer,
|
|||
XML_GetCurrentByteIndex(mExpatParser) % sizeof(PRUnichar) == 0,
|
||||
"Consumed part of a PRUnichar?");
|
||||
|
||||
if (mExpatParser && (mInternalState == NS_OK ||
|
||||
mInternalState == NS_ERROR_HTMLPARSER_BLOCK)) {
|
||||
XML_Status status;
|
||||
if (mInternalState == NS_ERROR_HTMLPARSER_BLOCK) {
|
||||
mInternalState = NS_OK; // Resume in case we're blocked.
|
||||
status = XML_ResumeParser(mExpatParser);
|
||||
}
|
||||
else {
|
||||
status = XML_Parse(mExpatParser, aBuffer, aLength, aIsFinal);
|
||||
}
|
||||
if (mExpatParser && mInternalState == NS_OK) {
|
||||
XML_Bool parsedAll = XML_Parse(mExpatParser, aBuffer, aLength, aIsFinal);
|
||||
|
||||
PRInt32 parserBytesConsumed = XML_GetCurrentByteIndex(mExpatParser);
|
||||
|
||||
|
@ -870,10 +863,8 @@ nsExpatDriver::ParseBuffer(const char* aBuffer,
|
|||
const PRUnichar* const buffer =
|
||||
NS_REINTERPRET_CAST(const PRUnichar*, aBuffer);
|
||||
PRUint32 startOffset;
|
||||
// If expat failed to consume some bytes last time it won't consume them
|
||||
// this time without also consuming some bytes from aBuffer. Note that when
|
||||
// resuming after suspending the parser, aBuffer will contain the data that
|
||||
// Expat also has in its internal buffer.
|
||||
// we assume that if expat failed to consume some bytes last time it won't
|
||||
// consume them this time without also consuming some bytes from aBuffer.
|
||||
// Note that if expat consumed everything we passed it, it will have nulled
|
||||
// out all its internal pointers to data, so parserBytesConsumed will come
|
||||
// out -1 in that case.
|
||||
|
@ -914,46 +905,46 @@ nsExpatDriver::ParseBuffer(const char* aBuffer,
|
|||
}
|
||||
}
|
||||
|
||||
if (status == XML_STATUS_SUSPENDED) {
|
||||
NS_ASSERTION(mInternalState == NS_ERROR_HTMLPARSER_BLOCK,
|
||||
"mInternalState out of sync!");
|
||||
NS_ASSERTION((PRUint32)parserBytesConsumed >= mBytesParsed,
|
||||
"How'd this happen?");
|
||||
mBytePosition = parserBytesConsumed - mBytesParsed;
|
||||
mBytesParsed = parserBytesConsumed;
|
||||
if (buffer) {
|
||||
PRUint32 endOffset = mBytePosition / sizeof(PRUnichar);
|
||||
NS_ASSERTION(startOffset <= endOffset,
|
||||
"Something is confused about what we've consumed");
|
||||
// Only append the data we actually parsed. The rest will come
|
||||
// through this method again.
|
||||
mLastLine.Append(Substring(buffer + startOffset,
|
||||
buffer + endOffset));
|
||||
}
|
||||
|
||||
return mInternalState;
|
||||
}
|
||||
|
||||
PRUint32 length = aLength / sizeof(PRUnichar);
|
||||
if (status == XML_STATUS_ERROR) {
|
||||
// Look for the next newline after the last one we consumed
|
||||
if (buffer) {
|
||||
PRUint32 endOffset = startOffset;
|
||||
while (endOffset < length && buffer[endOffset] != '\n' &&
|
||||
buffer[endOffset] != '\r') {
|
||||
++endOffset;
|
||||
if (!parsedAll) {
|
||||
if (mInternalState == NS_ERROR_HTMLPARSER_BLOCK ||
|
||||
mInternalState == NS_ERROR_HTMLPARSER_STOPPARSING) {
|
||||
NS_ASSERTION((PRUint32)parserBytesConsumed >= mBytesParsed,
|
||||
"How'd this happen?");
|
||||
mBytePosition = parserBytesConsumed - mBytesParsed;
|
||||
mBytesParsed = parserBytesConsumed;
|
||||
if (buffer) {
|
||||
PRUint32 endOffset = mBytePosition / sizeof(PRUnichar);
|
||||
NS_ASSERTION(startOffset <= endOffset,
|
||||
"Something is confused about what we've consumed");
|
||||
// Only append the data we actually parsed. The rest will come
|
||||
// through this method again.
|
||||
mLastLine.Append(Substring(buffer + startOffset,
|
||||
buffer + endOffset));
|
||||
}
|
||||
mLastLine.Append(Substring(buffer + startOffset,
|
||||
buffer + endOffset));
|
||||
}
|
||||
HandleError();
|
||||
mInternalState = NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
else {
|
||||
// An error occured, look for the next newline after the last one we
|
||||
// consumed.
|
||||
PRUint32 length = aLength / sizeof(PRUnichar);
|
||||
if (buffer) {
|
||||
PRUint32 endOffset = startOffset;
|
||||
while (endOffset < length && buffer[endOffset] != '\n' &&
|
||||
buffer[endOffset] != '\r') {
|
||||
++endOffset;
|
||||
}
|
||||
mLastLine.Append(Substring(buffer + startOffset,
|
||||
buffer + endOffset));
|
||||
}
|
||||
HandleError();
|
||||
mInternalState = NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
}
|
||||
|
||||
return mInternalState;
|
||||
}
|
||||
|
||||
if (!aIsFinal && buffer) {
|
||||
mLastLine.Append(Substring(buffer + startOffset, buffer + length));
|
||||
mLastLine.Append(Substring(buffer + startOffset,
|
||||
buffer + aLength / sizeof(PRUnichar)));
|
||||
}
|
||||
mBytesParsed += aLength;
|
||||
mBytePosition = 0;
|
||||
|
@ -975,6 +966,9 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner,
|
|||
// Ask the scanner to send us all the data it has
|
||||
// scanned and pass that data to expat.
|
||||
|
||||
mInternalState = NS_OK; // Resume in case we're blocked.
|
||||
MOZ_XML_ResumeParser(mExpatParser);
|
||||
|
||||
nsScannerIterator start, end;
|
||||
aScanner.CurrentPosition(start);
|
||||
aScanner.EndReading(end);
|
||||
|
@ -984,7 +978,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner,
|
|||
|
||||
mInternalState = ParseBuffer((const char*)start.get(),
|
||||
fragLength * sizeof(PRUnichar),
|
||||
PR_FALSE);
|
||||
aFlushTokens);
|
||||
|
||||
if (NS_FAILED(mInternalState)) {
|
||||
if (mInternalState == NS_ERROR_HTMLPARSER_BLOCK) {
|
||||
|
@ -1134,8 +1128,7 @@ nsExpatDriver::WillInterruptParse(nsIContentSink* aSink)
|
|||
NS_IMETHODIMP
|
||||
nsExpatDriver::DidTokenize(PRBool aIsFinalChunk)
|
||||
{
|
||||
return mInternalState == NS_OK ? ParseBuffer(nsnull, 0, aIsFinalChunk) :
|
||||
NS_OK;
|
||||
return ParseBuffer(nsnull, 0, aIsFinalChunk);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(const nsIID&)
|
||||
|
@ -1149,7 +1142,7 @@ nsExpatDriver::Terminate()
|
|||
{
|
||||
// XXX - not sure what happens to the unparsed data.
|
||||
if (mExpatParser) {
|
||||
XML_StopParser(mExpatParser, XML_FALSE);
|
||||
MOZ_XML_StopParser(mExpatParser, XML_FALSE);
|
||||
}
|
||||
mInternalState = NS_ERROR_HTMLPARSER_STOPPARSING;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче