cleanup imap parser syntax error line handling a little, 312572, r/sr=bienvenu

This commit is contained in:
bienvenu%nventure.com 2005-10-18 18:33:17 +00:00
Родитель ea2955ba39
Коммит ad2a41ccbc
3 изменённых файлов: 4 добавлений и 23 удалений

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

@ -53,7 +53,6 @@ fLineOfTokens(nsnull),
fStartOfLineOfTokens(nsnull), fStartOfLineOfTokens(nsnull),
fCurrentTokenPlaceHolder(nsnull), fCurrentTokenPlaceHolder(nsnull),
fAtEndOfLine(PR_FALSE), fAtEndOfLine(PR_FALSE),
fSyntaxErrorLine(nsnull),
fSyntaxError(PR_FALSE), fSyntaxError(PR_FALSE),
fDisconnected(PR_FALSE) fDisconnected(PR_FALSE)
{ {
@ -63,7 +62,6 @@ nsIMAPGenericParser::~nsIMAPGenericParser()
{ {
PR_FREEIF( fCurrentLine ); PR_FREEIF( fCurrentLine );
PR_FREEIF( fStartOfLineOfTokens); PR_FREEIF( fStartOfLineOfTokens);
PR_FREEIF( fSyntaxErrorLine );
} }
void nsIMAPGenericParser::HandleMemoryFailure() void nsIMAPGenericParser::HandleMemoryFailure()
@ -88,22 +86,9 @@ PRBool nsIMAPGenericParser::LastCommandSuccessful()
void nsIMAPGenericParser::SetSyntaxError(PRBool error) void nsIMAPGenericParser::SetSyntaxError(PRBool error)
{ {
fSyntaxError = error; fSyntaxError = error;
PR_FREEIF( fSyntaxErrorLine ); NS_ASSERTION(!error, "syntax error in generic parser");
if (error)
{
NS_ASSERTION(PR_FALSE, "syntax error in generic parser");
fSyntaxErrorLine = PL_strdup(fCurrentLine);
}
else
fSyntaxErrorLine = NULL;
} }
char *nsIMAPGenericParser::CreateSyntaxErrorLine()
{
return PL_strdup(fSyntaxErrorLine);
}
PRBool nsIMAPGenericParser::SyntaxError() PRBool nsIMAPGenericParser::SyntaxError()
{ {
return fSyntaxError; return fSyntaxError;

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

@ -66,8 +66,6 @@ public:
PRBool Connected(); PRBool Connected();
virtual void SetConnected(PRBool error); virtual void SetConnected(PRBool error);
char *CreateSyntaxErrorLine();
protected: protected:
// This is a pure virtual member which must be overridden in the derived class // This is a pure virtual member which must be overridden in the derived class
@ -103,8 +101,6 @@ protected:
char *fStartOfLineOfTokens; char *fStartOfLineOfTokens;
char *fCurrentTokenPlaceHolder; char *fCurrentTokenPlaceHolder;
PRBool fAtEndOfLine; PRBool fAtEndOfLine;
char *fSyntaxErrorLine;
PRBool fSyntaxError; PRBool fSyntaxError;
private: private:
PRBool fDisconnected; PRBool fDisconnected;

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

@ -2928,17 +2928,17 @@ void nsImapServerResponseParser::SetSyntaxError(PRBool error)
nsIMAPGenericParser::SetSyntaxError(error); nsIMAPGenericParser::SetSyntaxError(error);
if (error) if (error)
{ {
if (!fSyntaxErrorLine) if (!fCurrentLine)
{ {
HandleMemoryFailure(); HandleMemoryFailure();
fServerConnection.Log("PARSER", ("Internal Syntax Error: <no line>"), nsnull); fServerConnection.Log("PARSER", ("Internal Syntax Error: <no line>"), nsnull);
} }
else else
{ {
if (!nsCRT::strcmp(fSyntaxErrorLine, CRLF)) if (!nsCRT::strcmp(fCurrentLine, CRLF))
fServerConnection.Log("PARSER", "Internal Syntax Error: <CRLF>", nsnull); fServerConnection.Log("PARSER", "Internal Syntax Error: <CRLF>", nsnull);
else else
fServerConnection.Log("PARSER", "Internal Syntax Error: %s", fSyntaxErrorLine); fServerConnection.Log("PARSER", "Internal Syntax Error: %s", fCurrentLine);
} }
} }
} }