98650 r/sr=mscott. Look for only '\n' as endOfLine char. This will fix

the problem of not getting mail from one specific account. At the same time
it should increase performance where ever reading buffer is involved in
mailnews because PL_strstr is changed to PL_strchr.
This commit is contained in:
naving%netscape.com 2001-09-16 23:55:32 +00:00
Родитель 63fffd961d
Коммит 4d40a4c3aa
8 изменённых файлов: 16 добавлений и 15 удалений

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

@ -271,10 +271,8 @@ PRInt32 nsMsgLineBuffer::FlushLastLine()
// read but unprocessed stream data in a buffer.
///////////////////////////////////////////////////////////////////////////////////////////////////
nsMsgLineStreamBuffer::nsMsgLineStreamBuffer(PRUint32 aBufferSize, const char * aEndOfLineToken,
PRBool aAllocateNewLines, PRBool aEatCRLFs)
: m_eatCRLFs(aEatCRLFs), m_allocateNewLines(aAllocateNewLines),
m_endOfLineToken(aEndOfLineToken)
nsMsgLineStreamBuffer::nsMsgLineStreamBuffer(PRUint32 aBufferSize, PRBool aAllocateNewLines, PRBool aEatCRLFs)
: m_eatCRLFs(aEatCRLFs), m_allocateNewLines(aAllocateNewLines)
{
NS_PRECONDITION(aBufferSize > 0, "invalid buffer size!!!");
m_dataBuffer = nsnull;
@ -326,7 +324,7 @@ char * nsMsgLineStreamBuffer::ReadNextLine(nsIInputStream * aInputStream, PRUint
char * startOfLine = m_dataBuffer+m_startPos;
if (m_numBytesInBuffer > 0) // any data in our internal buffer?
endOfLine = PL_strstr(startOfLine, m_endOfLineToken); // see if we already have a line ending...
endOfLine = PL_strchr(startOfLine, '\n'); // see if we already have a line ending...
// it's possible that we got here before the first time we receive data from the server
// so aInputStream will be nsnull...
@ -394,7 +392,7 @@ char * nsMsgLineStreamBuffer::ReadNextLine(nsIInputStream * aInputStream, PRUint
// okay, now that we've tried to read in more data from the stream, look for another end of line
// character
endOfLine = PL_strstr(startOfLine, m_endOfLineToken);
endOfLine = PL_strchr(startOfLine, '\n');
}
@ -402,10 +400,13 @@ char * nsMsgLineStreamBuffer::ReadNextLine(nsIInputStream * aInputStream, PRUint
if (endOfLine)
{
if (!m_eatCRLFs)
endOfLine += PL_strlen(m_endOfLineToken); // count for CRLF
endOfLine += 1; // count for LF
aNumBytesInLine = endOfLine - startOfLine;
if (startOfLine[aNumBytesInLine-1] == '\r')
aNumBytesInLine--;
// PR_CALLOC zeros out the allocated line
char* newLine = (char*) PR_CALLOC(aNumBytesInLine+1);
if (!newLine)
@ -418,7 +419,7 @@ char * nsMsgLineStreamBuffer::ReadNextLine(nsIInputStream * aInputStream, PRUint
nsCRT::memcpy(newLine, startOfLine, aNumBytesInLine); // copy the string into the new line buffer
if (m_eatCRLFs)
endOfLine += PL_strlen(m_endOfLineToken); // advance past CRLF if we haven't already done so...
endOfLine += 1; // advance past LF if we haven't already done so...
// now we need to update the data buffer to go past the line we just read out.
m_numBytesInBuffer -= (endOfLine - startOfLine);

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

@ -96,7 +96,7 @@ public:
// ReadNextLine will alter the data so your ptr only has a life time of a per call.
// aEatCRLFs -- PR_TRUE if you don't want to see the CRLFs on the lines returned by ReadNextLine.
// PR_FALSE if you do want to see them.
nsMsgLineStreamBuffer(PRUint32 aBufferSize, const char * aEndOfLineToken, PRBool aAllocateNewLines, PRBool aEatCRLFs = PR_TRUE); // specify the size of the buffer you want the class to use....
nsMsgLineStreamBuffer(PRUint32 aBufferSize, PRBool aAllocateNewLines, PRBool aEatCRLFs = PR_TRUE); // specify the size of the buffer you want the class to use....
virtual ~nsMsgLineStreamBuffer();
// Caller must free the line returned using PR_Free
@ -109,7 +109,6 @@ protected:
PRBool m_eatCRLFs;
PRBool m_allocateNewLines;
char * m_dataBuffer;
const char * m_endOfLineToken;
PRUint32 m_dataBufferSize;
PRUint32 m_startPos;
PRUint32 m_numBytesInBuffer;

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

@ -273,7 +273,7 @@ nsImapProtocol::nsImapProtocol() :
m_allocatedSize = OUTPUT_BUFFER_SIZE;
// used to buffer incoming data by ReadNextLineFromInput
m_inputStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, CRLF, PR_TRUE /* allocate new lines */, PR_FALSE /* leave CRLFs on the returned string */);
m_inputStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, PR_TRUE /* allocate new lines */, PR_FALSE /* leave CRLFs on the returned string */);
m_currentBiffState = nsIMsgFolder::nsMsgBiffState_Unknown;
m_userName = nsnull;

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

@ -2139,7 +2139,7 @@ nsresult nsImapService::OfflineAppendFromFile(nsIFileSpec* aFileSpec,
{
// now, copy the temp file to the offline store for the dest folder.
PRInt32 inputBufferSize = 10240;
nsMsgLineStreamBuffer *inputStreamBuffer = new nsMsgLineStreamBuffer(inputBufferSize, CRLF, PR_TRUE /* allocate new lines */, PR_FALSE /* leave CRLFs on the returned string */);
nsMsgLineStreamBuffer *inputStreamBuffer = new nsMsgLineStreamBuffer(inputBufferSize, PR_TRUE /* allocate new lines */, PR_FALSE /* leave CRLFs on the returned string */);
PRUint32 fileSize;
aFileSpec->GetFileSize(&fileSize);
PRUint32 bytesWritten;

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

@ -197,7 +197,7 @@ void nsMailboxProtocol::Initialize(nsIURI * aURL)
}
}
m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, MSG_LINEBREAK, PR_TRUE);
m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, PR_TRUE);
m_nextState = MAILBOX_READ_FOLDER;
m_initialState = MAILBOX_READ_FOLDER;

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

@ -476,7 +476,7 @@ nsresult nsPop3Protocol::Initialize(nsIURI * aURL)
if (!POP3LOGMODULE)
POP3LOGMODULE = PR_NewLogModule("POP3");
m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, CRLF, PR_TRUE);
m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, PR_TRUE);
if(!m_lineStreamBuffer)
return NS_ERROR_OUT_OF_MEMORY;

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

@ -62,6 +62,7 @@ nsPop3Sink::~nsPop3Sink()
PR_FREEIF(m_accountUrl);
PR_FREEIF(m_outputBuffer);
NS_IF_RELEASE(m_popServer);
ReleaseFolderLock();
NS_IF_RELEASE(m_folder);
NS_IF_RELEASE(m_newMailParser);
}

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

@ -538,7 +538,7 @@ NS_IMETHODIMP nsNNTPProtocol::Initialize(nsIURI * aURL, nsIMsgWindow *aMsgWindow
m_dataBufSize = OUTPUT_BUFFER_SIZE;
if (!m_lineStreamBuffer)
m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, CRLF, PR_TRUE /* create new lines */);
m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, PR_TRUE /* create new lines */);
m_typeWanted = 0;
m_responseCode = 0;