Changing the debug robot to be able to cope with the parser push model.

Updated the robot sink apis.
Fixed the global url holder in the destructor of the parser.
Changed the robot observer to set a flag when completed parsing of a
url so that it doesn't create lottsa little parsers.
This commit is contained in:
jevering 1998-05-28 00:21:34 +00:00
Родитель 8237687bfe
Коммит 0abd8e75a7
8 изменённых файлов: 236 добавлений и 118 удалений

Просмотреть файл

@ -38,6 +38,7 @@ public:
NS_IMETHOD ProcessLink(const nsString& aURLSpec);
NS_IMETHOD VerifyDirectory (const char * verify_dir);
NS_IMETHOD ReadyForNextUrl(void);
};
@ -46,6 +47,7 @@ static nsVoidArray * g_duplicateList;
static int g_iProcessed;
static int g_iMaxProcess = 5000;
static PRBool g_bHitTop;
static PRBool g_bReadyForNextUrl;
NS_IMPL_ISUPPORTS(RobotSinkObserver, kIRobotSinkObserverIID);
@ -54,6 +56,12 @@ NS_IMETHODIMP RobotSinkObserver::VerifyDirectory(const char * verify_dir)
return NS_OK;
}
NS_IMETHODIMP RobotSinkObserver::ReadyForNextUrl(void)
{
g_bReadyForNextUrl = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP RobotSinkObserver::ProcessLink(const nsString& aURLSpec)
{
if (!g_bHitTop) {
@ -156,11 +164,15 @@ extern "C" NS_EXPORT int DebugRobot(
sink->AddObserver(myObserver);
parser->SetContentSink(sink);
g_bReadyForNextUrl = PR_FALSE;
parser->Parse(url);
if (yieldProc != NULL)
(*yieldProc)(url->GetSpec());
while (!g_bReadyForNextUrl) {
if (yieldProc != NULL)
(*yieldProc)(url->GetSpec());
}
if (ww)
ww->LoadURL(url->GetSpec());
ww->LoadURL(url->GetSpec());
NS_RELEASE(sink);
NS_RELEASE(parser);
NS_RELEASE(url);

Просмотреть файл

@ -30,6 +30,7 @@ class nsIRobotSinkObserver : public nsISupports {
public:
NS_IMETHOD ProcessLink(const nsString& aURLSpec) = 0;
NS_IMETHOD VerifyDirectory(const char * verify_dir) = 0;
NS_IMETHOD ReadyForNextUrl(void) = 0;
};
#endif /* nsIRobotSinkObserver_h___ */

Просмотреть файл

@ -18,6 +18,7 @@
#include "nsIRobotSink.h"
#include "nsIRobotSinkObserver.h"
#include "nsIParserNode.h"
#include "nsParserTypes.h"
#include "nsString.h"
#include "nsIURL.h"
#include "nsCRT.h"
@ -51,23 +52,23 @@ public:
NS_DECL_ISUPPORTS
// nsIHTMLContentSink
virtual PRBool SetTitle(const nsString& aValue);
virtual PRBool OpenHTML(const nsIParserNode& aNode);
virtual PRBool CloseHTML(const nsIParserNode& aNode);
virtual PRBool OpenHead(const nsIParserNode& aNode);
virtual PRBool CloseHead(const nsIParserNode& aNode);
virtual PRBool OpenBody(const nsIParserNode& aNode);
virtual PRBool CloseBody(const nsIParserNode& aNode);
virtual PRBool OpenForm(const nsIParserNode& aNode);
virtual PRBool CloseForm(const nsIParserNode& aNode);
virtual PRBool OpenFrameset(const nsIParserNode& aNode);
virtual PRBool CloseFrameset(const nsIParserNode& aNode);
virtual PRBool OpenContainer(const nsIParserNode& aNode);
virtual PRBool CloseContainer(const nsIParserNode& aNode);
virtual PRBool CloseTopmostContainer();
virtual PRBool AddLeaf(const nsIParserNode& aNode);
virtual PRInt32 SetTitle(const nsString& aValue);
virtual PRInt32 OpenHTML(const nsIParserNode& aNode);
virtual PRInt32 CloseHTML(const nsIParserNode& aNode);
virtual PRInt32 OpenHead(const nsIParserNode& aNode);
virtual PRInt32 CloseHead(const nsIParserNode& aNode);
virtual PRInt32 OpenBody(const nsIParserNode& aNode);
virtual PRInt32 CloseBody(const nsIParserNode& aNode);
virtual PRInt32 OpenForm(const nsIParserNode& aNode);
virtual PRInt32 CloseForm(const nsIParserNode& aNode);
virtual PRInt32 OpenFrameset(const nsIParserNode& aNode);
virtual PRInt32 CloseFrameset(const nsIParserNode& aNode);
virtual PRInt32 OpenContainer(const nsIParserNode& aNode);
virtual PRInt32 CloseContainer(const nsIParserNode& aNode);
virtual PRInt32 CloseTopmostContainer();
virtual PRInt32 AddLeaf(const nsIParserNode& aNode);
virtual void WillBuildModel(void) { }
virtual void DidBuildModel(void){ }
virtual void DidBuildModel(void);
virtual void WillInterrupt(void) { }
virtual void WillResume(void) { }
@ -130,62 +131,62 @@ NS_IMETHODIMP RobotSink::QueryInterface(REFNSIID aIID, void** aInstancePtr)
return NS_NOINTERFACE;
}
PRBool RobotSink::SetTitle(const nsString& aValue)
PRInt32 RobotSink::SetTitle(const nsString& aValue)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::OpenHTML(const nsIParserNode& aNode)
PRInt32 RobotSink::OpenHTML(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::CloseHTML(const nsIParserNode& aNode)
PRInt32 RobotSink::CloseHTML(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::OpenHead(const nsIParserNode& aNode)
PRInt32 RobotSink::OpenHead(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::CloseHead(const nsIParserNode& aNode)
PRInt32 RobotSink::CloseHead(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::OpenBody(const nsIParserNode& aNode)
PRInt32 RobotSink::OpenBody(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::CloseBody(const nsIParserNode& aNode)
PRInt32 RobotSink::CloseBody(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::OpenForm(const nsIParserNode& aNode)
PRInt32 RobotSink::OpenForm(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::CloseForm(const nsIParserNode& aNode)
PRInt32 RobotSink::CloseForm(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::OpenFrameset(const nsIParserNode& aNode)
PRInt32 RobotSink::OpenFrameset(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::CloseFrameset(const nsIParserNode& aNode)
PRInt32 RobotSink::CloseFrameset(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::OpenContainer(const nsIParserNode& aNode)
PRInt32 RobotSink::OpenContainer(const nsIParserNode& aNode)
{
nsAutoString tmp(aNode.GetText());
tmp.ToUpperCase();
@ -218,22 +219,22 @@ PRBool RobotSink::OpenContainer(const nsIParserNode& aNode)
}
}
}
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::CloseContainer(const nsIParserNode& aNode)
PRInt32 RobotSink::CloseContainer(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::CloseTopmostContainer()
PRInt32 RobotSink::CloseTopmostContainer()
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::AddLeaf(const nsIParserNode& aNode)
PRInt32 RobotSink::AddLeaf(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
NS_IMETHODIMP RobotSink::Init(nsIURL* aDocumentURL)
@ -287,3 +288,13 @@ void RobotSink::ProcessLink(const nsString& aLink)
cop->ProcessLink(absURLSpec);
}
}
void RobotSink::DidBuildModel(void)
{
PRInt32 i, n = mObservers.Count();
for (i = 0; i < n; i++) {
nsIRobotSinkObserver* cop = (nsIRobotSinkObserver*)mObservers.ElementAt(i);
cop->ReadyForNextUrl();
}
}

Просмотреть файл

@ -30,6 +30,7 @@
#include "CNavDelegate.h"
#include "CNavDTD.h"
#include "prenv.h" //this is here for debug reasons...
#include "prio.h"
#include "plstr.h"
#include <fstream.h>
#include "nsIInputStream.h"
@ -48,6 +49,7 @@ static const char* kNullToken = "Error: Null token given";
static const char* kInvalidTagStackPos = "Error: invalid tag stack position";
static char* gVerificationOutputDir=0;
static char* gURLRef=0;
static int rickGDebug=0;
static const int gTransferBufferSize=4096; //size of the buffer used in moving data from iistream
@ -160,6 +162,7 @@ nsHTMLParser::nsHTMLParser() {
mHasOpenForm=PR_FALSE;
InitializeDefaultTokenHandlers();
gVerificationOutputDir = PR_GetEnv("VERIFY_PARSER");
gURLRef = 0;
}
@ -172,6 +175,11 @@ nsHTMLParser::nsHTMLParser() {
*/
nsHTMLParser::~nsHTMLParser() {
DeleteTokenHandlers();
if (gURLRef)
{
PL_strfree(gURLRef);
gURLRef = 0;
}
if(mTransferBuffer)
delete [] mTransferBuffer;
mTransferBuffer=0;
@ -279,12 +287,12 @@ PRInt32 nsHTMLParser::GetTopmostIndex(eHTMLTags aTag) const {
return kNotFound;
}
/**
* Destroy the list of token handlers
* Finds a tag handler for the given tag type, given in string.
*
* @update gess 4/2/98
* @return this
* @param aString contains name of tag to be handled
* @return valid tag handler (if found) or null
*/
nsHTMLParser& nsHTMLParser::DeleteTokenHandlers(void) {
int i=0;
@ -374,8 +382,6 @@ PRBool VerifyContextVector(PRInt32 aTags[],PRInt32 count,nsIDTD* aDTD) {
if(0!=gVerificationOutputDir) {
if(aDTD){
#ifdef XP_PC
char path[_MAX_PATH+1];
strcpy(path,gVerificationOutputDir);
@ -393,8 +399,22 @@ PRBool VerifyContextVector(PRInt32 aTags[],PRInt32 count,nsIDTD* aDTD) {
}
//ok, now see if we understand this vector
result=aDTD->VerifyContextVector(aTags,count);
}
if(PR_FALSE==result){
if(PR_FALSE==result){
#ifdef NS_WIN32
// save file to directory indicated by bad context vector
int iCount = 1;
char filename[_MAX_PATH];
do {
sprintf(filename,"%s/html%04d.dbg", path, iCount++);
} while (PR_Access(filename,PR_ACCESS_EXISTS) == PR_SUCCESS);
PRFileDesc * debugFile = PR_Open(filename,PR_CREATE_FILE|PR_RDWR,0);
if (debugFile) {
PR_Write(debugFile,gURLRef,PL_strlen(gURLRef));
PR_Write(debugFile,"\n",PL_strlen("\n"));
PR_Close(debugFile);
}
#endif
//add debugging code here to record the fact that we just encountered
//a context vector we don't know how to handle.
}
@ -528,7 +548,13 @@ PRInt32 nsHTMLParser::ParseFileIncrementally(const char* aFilename){
nsString theBuffer;
const int kLocalBufSize=10;
if (gURLRef)
PL_strfree(gURLRef);
if (aFilename)
gURLRef = PL_strdup(aFilename);
mIteration=-1;
#if defined(XP_UNIX) && defined(IRIX)
/* XXX: IRIX does not support ios::binary */
mFileStream=new fstream(aFilename,ios::in);
@ -576,14 +602,15 @@ PRInt32 nsHTMLParser::ParseFileIncrementally(const char* aFilename){
*/
PRBool nsHTMLParser::Parse(const char* aFilename,PRBool aIncremental){
NS_PRECONDITION(0!=aFilename,kNullFilename);
PRInt32 status=kBadFilename;
mIncremental=aIncremental;
mParseMode=DetermineParseMode();
if(aFilename) {
if (gURLRef)
PL_strfree(gURLRef);
gURLRef = PL_strdup(aFilename);
GetDelegateAndDTD(mParseMode,mDelegate,mDTD);
if(mDelegate) {
@ -632,6 +659,14 @@ PRInt32 nsHTMLParser::Parse(nsIURL* aURL,PRBool aIncremental ){
if(aURL) {
if (gURLRef)
{
PL_strfree(gURLRef);
gURLRef = 0;
}
if (aURL->GetSpec())
gURLRef = PL_strdup(aURL->GetSpec());
GetDelegateAndDTD(mParseMode,mDelegate,mDTD);
if(mDelegate) {
@ -1334,7 +1369,7 @@ PRInt32 nsHTMLParser::CloseContainer(const nsIParserNode& aNode){
break;
case eHTMLTag_head:
//result=CloseHead(aNode);
result=CloseHead(aNode);
break;
case eHTMLTag_body:

Просмотреть файл

@ -38,6 +38,7 @@ public:
NS_IMETHOD ProcessLink(const nsString& aURLSpec);
NS_IMETHOD VerifyDirectory (const char * verify_dir);
NS_IMETHOD ReadyForNextUrl(void);
};
@ -46,6 +47,7 @@ static nsVoidArray * g_duplicateList;
static int g_iProcessed;
static int g_iMaxProcess = 5000;
static PRBool g_bHitTop;
static PRBool g_bReadyForNextUrl;
NS_IMPL_ISUPPORTS(RobotSinkObserver, kIRobotSinkObserverIID);
@ -54,6 +56,12 @@ NS_IMETHODIMP RobotSinkObserver::VerifyDirectory(const char * verify_dir)
return NS_OK;
}
NS_IMETHODIMP RobotSinkObserver::ReadyForNextUrl(void)
{
g_bReadyForNextUrl = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP RobotSinkObserver::ProcessLink(const nsString& aURLSpec)
{
if (!g_bHitTop) {
@ -156,11 +164,15 @@ extern "C" NS_EXPORT int DebugRobot(
sink->AddObserver(myObserver);
parser->SetContentSink(sink);
g_bReadyForNextUrl = PR_FALSE;
parser->Parse(url);
if (yieldProc != NULL)
(*yieldProc)(url->GetSpec());
while (!g_bReadyForNextUrl) {
if (yieldProc != NULL)
(*yieldProc)(url->GetSpec());
}
if (ww)
ww->LoadURL(url->GetSpec());
ww->LoadURL(url->GetSpec());
NS_RELEASE(sink);
NS_RELEASE(parser);
NS_RELEASE(url);

Просмотреть файл

@ -30,6 +30,7 @@ class nsIRobotSinkObserver : public nsISupports {
public:
NS_IMETHOD ProcessLink(const nsString& aURLSpec) = 0;
NS_IMETHOD VerifyDirectory(const char * verify_dir) = 0;
NS_IMETHOD ReadyForNextUrl(void) = 0;
};
#endif /* nsIRobotSinkObserver_h___ */

Просмотреть файл

@ -18,6 +18,7 @@
#include "nsIRobotSink.h"
#include "nsIRobotSinkObserver.h"
#include "nsIParserNode.h"
#include "nsParserTypes.h"
#include "nsString.h"
#include "nsIURL.h"
#include "nsCRT.h"
@ -51,23 +52,23 @@ public:
NS_DECL_ISUPPORTS
// nsIHTMLContentSink
virtual PRBool SetTitle(const nsString& aValue);
virtual PRBool OpenHTML(const nsIParserNode& aNode);
virtual PRBool CloseHTML(const nsIParserNode& aNode);
virtual PRBool OpenHead(const nsIParserNode& aNode);
virtual PRBool CloseHead(const nsIParserNode& aNode);
virtual PRBool OpenBody(const nsIParserNode& aNode);
virtual PRBool CloseBody(const nsIParserNode& aNode);
virtual PRBool OpenForm(const nsIParserNode& aNode);
virtual PRBool CloseForm(const nsIParserNode& aNode);
virtual PRBool OpenFrameset(const nsIParserNode& aNode);
virtual PRBool CloseFrameset(const nsIParserNode& aNode);
virtual PRBool OpenContainer(const nsIParserNode& aNode);
virtual PRBool CloseContainer(const nsIParserNode& aNode);
virtual PRBool CloseTopmostContainer();
virtual PRBool AddLeaf(const nsIParserNode& aNode);
virtual PRInt32 SetTitle(const nsString& aValue);
virtual PRInt32 OpenHTML(const nsIParserNode& aNode);
virtual PRInt32 CloseHTML(const nsIParserNode& aNode);
virtual PRInt32 OpenHead(const nsIParserNode& aNode);
virtual PRInt32 CloseHead(const nsIParserNode& aNode);
virtual PRInt32 OpenBody(const nsIParserNode& aNode);
virtual PRInt32 CloseBody(const nsIParserNode& aNode);
virtual PRInt32 OpenForm(const nsIParserNode& aNode);
virtual PRInt32 CloseForm(const nsIParserNode& aNode);
virtual PRInt32 OpenFrameset(const nsIParserNode& aNode);
virtual PRInt32 CloseFrameset(const nsIParserNode& aNode);
virtual PRInt32 OpenContainer(const nsIParserNode& aNode);
virtual PRInt32 CloseContainer(const nsIParserNode& aNode);
virtual PRInt32 CloseTopmostContainer();
virtual PRInt32 AddLeaf(const nsIParserNode& aNode);
virtual void WillBuildModel(void) { }
virtual void DidBuildModel(void){ }
virtual void DidBuildModel(void);
virtual void WillInterrupt(void) { }
virtual void WillResume(void) { }
@ -130,62 +131,62 @@ NS_IMETHODIMP RobotSink::QueryInterface(REFNSIID aIID, void** aInstancePtr)
return NS_NOINTERFACE;
}
PRBool RobotSink::SetTitle(const nsString& aValue)
PRInt32 RobotSink::SetTitle(const nsString& aValue)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::OpenHTML(const nsIParserNode& aNode)
PRInt32 RobotSink::OpenHTML(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::CloseHTML(const nsIParserNode& aNode)
PRInt32 RobotSink::CloseHTML(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::OpenHead(const nsIParserNode& aNode)
PRInt32 RobotSink::OpenHead(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::CloseHead(const nsIParserNode& aNode)
PRInt32 RobotSink::CloseHead(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::OpenBody(const nsIParserNode& aNode)
PRInt32 RobotSink::OpenBody(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::CloseBody(const nsIParserNode& aNode)
PRInt32 RobotSink::CloseBody(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::OpenForm(const nsIParserNode& aNode)
PRInt32 RobotSink::OpenForm(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::CloseForm(const nsIParserNode& aNode)
PRInt32 RobotSink::CloseForm(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::OpenFrameset(const nsIParserNode& aNode)
PRInt32 RobotSink::OpenFrameset(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::CloseFrameset(const nsIParserNode& aNode)
PRInt32 RobotSink::CloseFrameset(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::OpenContainer(const nsIParserNode& aNode)
PRInt32 RobotSink::OpenContainer(const nsIParserNode& aNode)
{
nsAutoString tmp(aNode.GetText());
tmp.ToUpperCase();
@ -218,22 +219,22 @@ PRBool RobotSink::OpenContainer(const nsIParserNode& aNode)
}
}
}
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::CloseContainer(const nsIParserNode& aNode)
PRInt32 RobotSink::CloseContainer(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::CloseTopmostContainer()
PRInt32 RobotSink::CloseTopmostContainer()
{
return PR_TRUE;
return kNoError;
}
PRBool RobotSink::AddLeaf(const nsIParserNode& aNode)
PRInt32 RobotSink::AddLeaf(const nsIParserNode& aNode)
{
return PR_TRUE;
return kNoError;
}
NS_IMETHODIMP RobotSink::Init(nsIURL* aDocumentURL)
@ -287,3 +288,13 @@ void RobotSink::ProcessLink(const nsString& aLink)
cop->ProcessLink(absURLSpec);
}
}
void RobotSink::DidBuildModel(void)
{
PRInt32 i, n = mObservers.Count();
for (i = 0; i < n; i++) {
nsIRobotSinkObserver* cop = (nsIRobotSinkObserver*)mObservers.ElementAt(i);
cop->ReadyForNextUrl();
}
}

Просмотреть файл

@ -30,6 +30,7 @@
#include "CNavDelegate.h"
#include "CNavDTD.h"
#include "prenv.h" //this is here for debug reasons...
#include "prio.h"
#include "plstr.h"
#include <fstream.h>
#include "nsIInputStream.h"
@ -48,6 +49,7 @@ static const char* kNullToken = "Error: Null token given";
static const char* kInvalidTagStackPos = "Error: invalid tag stack position";
static char* gVerificationOutputDir=0;
static char* gURLRef=0;
static int rickGDebug=0;
static const int gTransferBufferSize=4096; //size of the buffer used in moving data from iistream
@ -160,6 +162,7 @@ nsHTMLParser::nsHTMLParser() {
mHasOpenForm=PR_FALSE;
InitializeDefaultTokenHandlers();
gVerificationOutputDir = PR_GetEnv("VERIFY_PARSER");
gURLRef = 0;
}
@ -172,6 +175,11 @@ nsHTMLParser::nsHTMLParser() {
*/
nsHTMLParser::~nsHTMLParser() {
DeleteTokenHandlers();
if (gURLRef)
{
PL_strfree(gURLRef);
gURLRef = 0;
}
if(mTransferBuffer)
delete [] mTransferBuffer;
mTransferBuffer=0;
@ -279,12 +287,12 @@ PRInt32 nsHTMLParser::GetTopmostIndex(eHTMLTags aTag) const {
return kNotFound;
}
/**
* Destroy the list of token handlers
* Finds a tag handler for the given tag type, given in string.
*
* @update gess 4/2/98
* @return this
* @param aString contains name of tag to be handled
* @return valid tag handler (if found) or null
*/
nsHTMLParser& nsHTMLParser::DeleteTokenHandlers(void) {
int i=0;
@ -374,8 +382,6 @@ PRBool VerifyContextVector(PRInt32 aTags[],PRInt32 count,nsIDTD* aDTD) {
if(0!=gVerificationOutputDir) {
if(aDTD){
#ifdef XP_PC
char path[_MAX_PATH+1];
strcpy(path,gVerificationOutputDir);
@ -393,8 +399,22 @@ PRBool VerifyContextVector(PRInt32 aTags[],PRInt32 count,nsIDTD* aDTD) {
}
//ok, now see if we understand this vector
result=aDTD->VerifyContextVector(aTags,count);
}
if(PR_FALSE==result){
if(PR_FALSE==result){
#ifdef NS_WIN32
// save file to directory indicated by bad context vector
int iCount = 1;
char filename[_MAX_PATH];
do {
sprintf(filename,"%s/html%04d.dbg", path, iCount++);
} while (PR_Access(filename,PR_ACCESS_EXISTS) == PR_SUCCESS);
PRFileDesc * debugFile = PR_Open(filename,PR_CREATE_FILE|PR_RDWR,0);
if (debugFile) {
PR_Write(debugFile,gURLRef,PL_strlen(gURLRef));
PR_Write(debugFile,"\n",PL_strlen("\n"));
PR_Close(debugFile);
}
#endif
//add debugging code here to record the fact that we just encountered
//a context vector we don't know how to handle.
}
@ -528,7 +548,13 @@ PRInt32 nsHTMLParser::ParseFileIncrementally(const char* aFilename){
nsString theBuffer;
const int kLocalBufSize=10;
if (gURLRef)
PL_strfree(gURLRef);
if (aFilename)
gURLRef = PL_strdup(aFilename);
mIteration=-1;
#if defined(XP_UNIX) && defined(IRIX)
/* XXX: IRIX does not support ios::binary */
mFileStream=new fstream(aFilename,ios::in);
@ -576,14 +602,15 @@ PRInt32 nsHTMLParser::ParseFileIncrementally(const char* aFilename){
*/
PRBool nsHTMLParser::Parse(const char* aFilename,PRBool aIncremental){
NS_PRECONDITION(0!=aFilename,kNullFilename);
PRInt32 status=kBadFilename;
mIncremental=aIncremental;
mParseMode=DetermineParseMode();
if(aFilename) {
if (gURLRef)
PL_strfree(gURLRef);
gURLRef = PL_strdup(aFilename);
GetDelegateAndDTD(mParseMode,mDelegate,mDTD);
if(mDelegate) {
@ -632,6 +659,14 @@ PRInt32 nsHTMLParser::Parse(nsIURL* aURL,PRBool aIncremental ){
if(aURL) {
if (gURLRef)
{
PL_strfree(gURLRef);
gURLRef = 0;
}
if (aURL->GetSpec())
gURLRef = PL_strdup(aURL->GetSpec());
GetDelegateAndDTD(mParseMode,mDelegate,mDTD);
if(mDelegate) {
@ -1334,7 +1369,7 @@ PRInt32 nsHTMLParser::CloseContainer(const nsIParserNode& aNode){
break;
case eHTMLTag_head:
//result=CloseHead(aNode);
result=CloseHead(aNode);
break;
case eHTMLTag_body: