зеркало из https://github.com/mozilla/gecko-dev.git
for nsMsgLineStreamBuffer, let caller choose if they want CRLFs at the end of the new lines or not.
This commit is contained in:
Родитель
e9042ccc29
Коммит
9c2d889626
|
@ -245,7 +245,7 @@ PRInt32 nsMsgLineBuffer::FlushLastLine()
|
|||
// read but unprocessed stream data in a buffer.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsMsgLineStreamBuffer::nsMsgLineStreamBuffer(PRUint32 aBufferSize)
|
||||
nsMsgLineStreamBuffer::nsMsgLineStreamBuffer(PRUint32 aBufferSize, PRBool aEatCRLFs) : m_eatCRLFs(aEatCRLFs)
|
||||
{
|
||||
NS_PRECONDITION(aBufferSize > 0, "invalid buffer size!!!");
|
||||
m_dataBuffer = nsnull;
|
||||
|
@ -326,7 +326,9 @@ char * nsMsgLineStreamBuffer::ReadNextLine(nsIInputStream * aInputStream, PRBool
|
|||
// okay, now check again for endOfLine.
|
||||
if (endOfLine)
|
||||
{
|
||||
endOfLine += 2; // count for CRLF
|
||||
if (!m_eatCRLFs)
|
||||
endOfLine += 2; // count for CRLF
|
||||
|
||||
// PR_CALLOC zeros out the allocated line
|
||||
char* newLine = (char*) PR_CALLOC(endOfLine-m_startPos+1);
|
||||
if (!newLine)
|
||||
|
@ -334,6 +336,9 @@ char * nsMsgLineStreamBuffer::ReadNextLine(nsIInputStream * aInputStream, PRBool
|
|||
|
||||
nsCRT::memcpy(newLine, m_startPos, endOfLine-m_startPos); // copy the string into the new line buffer
|
||||
|
||||
if (m_eatCRLFs)
|
||||
endOfLine += 2; // advance past CRLF if we haven't already done so...
|
||||
|
||||
// now we need to update the data buffer to go past the line we just read out.
|
||||
if (PL_strlen(endOfLine) <= 0) // if no more data in the buffer, then just zero out the buffer...
|
||||
m_startPos[0] = '\0';
|
||||
|
|
|
@ -81,13 +81,13 @@ class nsIInputStream;
|
|||
class nsMsgLineStreamBuffer
|
||||
{
|
||||
public:
|
||||
nsMsgLineStreamBuffer(PRUint32 aBufferSize); // specify the size of the buffer you want the class to use....
|
||||
nsMsgLineStreamBuffer(PRUint32 aBufferSize, 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
|
||||
char * ReadNextLine(nsIInputStream * aInputStream, PRBool &aPauseForMoreData);
|
||||
protected:
|
||||
|
||||
PRBool m_eatCRLFs;
|
||||
char * m_dataBuffer;
|
||||
char * m_startPos;
|
||||
PRUint32 m_dataBufferSize;
|
||||
|
|
Загрузка…
Ссылка в новой задаче