fix for #89052. certain imap searches were failing (and popup up alerts)

because we were forming bad search queries.  r=naving, sr=bienvenu
This commit is contained in:
sspitzer%netscape.com 2001-07-25 05:09:51 +00:00
Родитель 719f9fd116
Коммит a1b2b6a787
2 изменённых файлов: 13 добавлений и 16 удалений

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

@ -97,8 +97,7 @@ public:
// fills pre-allocated
// memory in buffer with
// the IMAP/NNTP encoding for the expression
// returns # bytes added to the buffer
PRInt32 GenerateEncodeStr(nsCString * buffer);
void GenerateEncodeStr(nsCString * buffer);
protected:
// if we are a leaf node, all we have is a search term
// and a Evaluation value for that search term

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

@ -195,44 +195,42 @@ PRInt32 nsMsgSearchBoolExpression::CalcEncodeStrSize()
}
PRInt32 nsMsgSearchBoolExpression::GenerateEncodeStr(nsCString * buffer)
void nsMsgSearchBoolExpression::GenerateEncodeStr(nsCString * buffer)
// recurively combine sub expressions to form a single IMAP/NNTP encoded string
{
if ((!m_term && (!m_leftChild || !m_rightChild))) // is expression empty?
return 0;
return;
if (m_term) // are we a leaf expression?
{
*buffer += m_encodingStr;
return m_encodingStr.Length();
return;
}
// add encode strings of each sub expression
PRInt32 numBytesAdded = 0;
if (m_boolOp == nsMsgSearchBooleanOp::BooleanOR)
{
*buffer += " (OR";
numBytesAdded = m_leftChild->GenerateEncodeStr(buffer); // insert left expression into the buffer
numBytesAdded = m_rightChild->GenerateEncodeStr(buffer); // insert right expression into the buffer
m_leftChild->GenerateEncodeStr(buffer); // insert left expression into the buffer
m_rightChild->GenerateEncodeStr(buffer); // insert right expression into the buffer
// HACK ALERT!!! if last returned character in the buffer is now a ' ' then we need to remove it because we don't want
// a ' ' to preceded the closing paren in the OR encoding.
if (buffer->CharAt(numBytesAdded-1) == ' ')
PRUint32 lastCharPos = buffer->Length() - 1;
if (buffer->CharAt(lastCharPos) == ' ')
{
buffer->Truncate(buffer->Length() - 1);
buffer->Truncate(lastCharPos);
}
*buffer += ')';
}
if (m_boolOp == nsMsgSearchBooleanOp::BooleanAND)
else if (m_boolOp == nsMsgSearchBooleanOp::BooleanAND)
{
numBytesAdded = m_leftChild->GenerateEncodeStr(buffer); // insert left expression
numBytesAdded = m_rightChild->GenerateEncodeStr(buffer);
m_leftChild->GenerateEncodeStr(buffer); // insert left expression
m_rightChild->GenerateEncodeStr(buffer);
}
return 0;
return;
}