remove some tabs and trailing white space from several mailnews files.

git-svn-id: svn://10.0.0.236/trunk@236399 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
scott%scott-macgregor.org
2007-09-20 22:42:03 +00:00
parent 974d32710b
commit 4cedd8d466
17 changed files with 313 additions and 313 deletions

View File

@@ -113,7 +113,7 @@ nsresult nsImapMoveCoalescer::PlaybackMoves(PRBool doNewMailNotification /* = PR
PRUint32 numFolders;
nsresult rv = NS_OK;
if (!m_destFolders)
return NS_OK; // nothing to do.
return NS_OK; // nothing to do.
m_hasPendingMoves = PR_FALSE;
m_doNewMailNotification = doNewMailNotification;
m_destFolders->Count(&numFolders);

View File

@@ -198,22 +198,22 @@ nsresult nsMsgI18NConvertToUnicode(const char* aCharset,
// Charset used by the file system.
const char * nsMsgI18NFileSystemCharset()
{
/* Get a charset used for the file. */
static nsCAutoString fileSystemCharset;
/* Get a charset used for the file. */
static nsCAutoString fileSystemCharset;
if (fileSystemCharset.IsEmpty())
{
nsresult rv;
nsCOMPtr <nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
if (fileSystemCharset.IsEmpty())
{
nsresult rv;
nsCOMPtr <nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName,
fileSystemCharset);
}
if (NS_FAILED(rv))
fileSystemCharset.Assign("ISO-8859-1");
}
return fileSystemCharset.get();
if (NS_FAILED(rv))
fileSystemCharset.Assign("ISO-8859-1");
}
return fileSystemCharset.get();
}
// Charset used by the text file.

View File

@@ -448,52 +448,52 @@ NS_IMETHODIMP nsMsgIdentity::GetIntAttribute(const char *aName, PRInt32 *val)
return NS_OK;
}
#define COPY_IDENTITY_FILE_VALUE(SRC_ID,MACRO_GETTER,MACRO_SETTER) \
{ \
nsresult macro_rv; \
nsCOMPtr <nsILocalFile>macro_spec; \
macro_rv = SRC_ID->MACRO_GETTER(getter_AddRefs(macro_spec)); \
if (NS_SUCCEEDED(macro_rv)) \
this->MACRO_SETTER(macro_spec); \
}
#define COPY_IDENTITY_FILE_VALUE(SRC_ID,MACRO_GETTER,MACRO_SETTER) \
{ \
nsresult macro_rv; \
nsCOMPtr <nsILocalFile>macro_spec; \
macro_rv = SRC_ID->MACRO_GETTER(getter_AddRefs(macro_spec)); \
if (NS_SUCCEEDED(macro_rv)) \
this->MACRO_SETTER(macro_spec); \
}
#define COPY_IDENTITY_INT_VALUE(SRC_ID,MACRO_GETTER,MACRO_SETTER) \
{ \
nsresult macro_rv; \
PRInt32 macro_oldInt; \
macro_rv = SRC_ID->MACRO_GETTER(&macro_oldInt); \
if (NS_SUCCEEDED(macro_rv)) \
this->MACRO_SETTER(macro_oldInt); \
}
#define COPY_IDENTITY_INT_VALUE(SRC_ID,MACRO_GETTER,MACRO_SETTER) \
{ \
nsresult macro_rv; \
PRInt32 macro_oldInt; \
macro_rv = SRC_ID->MACRO_GETTER(&macro_oldInt); \
if (NS_SUCCEEDED(macro_rv)) \
this->MACRO_SETTER(macro_oldInt); \
}
#define COPY_IDENTITY_BOOL_VALUE(SRC_ID,MACRO_GETTER,MACRO_SETTER) \
{ \
nsresult macro_rv; \
PRBool macro_oldBool; \
macro_rv = SRC_ID->MACRO_GETTER(&macro_oldBool); \
if (NS_SUCCEEDED(macro_rv)) \
this->MACRO_SETTER(macro_oldBool); \
}
#define COPY_IDENTITY_BOOL_VALUE(SRC_ID,MACRO_GETTER,MACRO_SETTER) \
{ \
nsresult macro_rv; \
PRBool macro_oldBool; \
macro_rv = SRC_ID->MACRO_GETTER(&macro_oldBool); \
if (NS_SUCCEEDED(macro_rv)) \
this->MACRO_SETTER(macro_oldBool); \
}
#define COPY_IDENTITY_STR_VALUE(SRC_ID,MACRO_GETTER,MACRO_SETTER) \
{ \
nsCString macro_oldStr; \
nsresult macro_rv; \
macro_rv = SRC_ID->MACRO_GETTER(macro_oldStr); \
#define COPY_IDENTITY_STR_VALUE(SRC_ID,MACRO_GETTER,MACRO_SETTER) \
{ \
nsCString macro_oldStr; \
nsresult macro_rv; \
macro_rv = SRC_ID->MACRO_GETTER(macro_oldStr); \
if (NS_SUCCEEDED(macro_rv)) { \
this->MACRO_SETTER(macro_oldStr); \
this->MACRO_SETTER(macro_oldStr); \
} \
}
}
#define COPY_IDENTITY_WSTR_VALUE(SRC_ID,MACRO_GETTER,MACRO_SETTER) \
{ \
nsString macro_oldStr; \
nsresult macro_rv; \
macro_rv = SRC_ID->MACRO_GETTER(macro_oldStr); \
if (NS_SUCCEEDED(macro_rv)) { \
this->MACRO_SETTER(macro_oldStr); \
} \
}
#define COPY_IDENTITY_WSTR_VALUE(SRC_ID,MACRO_GETTER,MACRO_SETTER) \
{ \
nsString macro_oldStr; \
nsresult macro_rv; \
macro_rv = SRC_ID->MACRO_GETTER(macro_oldStr); \
if (NS_SUCCEEDED(macro_rv)) { \
this->MACRO_SETTER(macro_oldStr); \
} \
}
NS_IMETHODIMP
nsMsgIdentity::Copy(nsIMsgIdentity *identity)

View File

@@ -60,8 +60,8 @@ void nsMsgKeyArray::SetArray(nsMsgKey* pData, int numElements, int numAllocated)
NS_ASSERTION(numElements >= 0, "negative number of elements");
NS_ASSERTION(numAllocated >= numElements, "num elements more than array size");
delete [] m_pData; // delete previous array
m_pData = pData; // set new array
m_nMaxSize = numAllocated; // set size
m_nSize = numElements; // set allocated length
delete [] m_pData; // delete previous array
m_pData = pData; // set new array
m_nMaxSize = numAllocated; // set size
m_nSize = numElements; // set allocated length
}

View File

@@ -50,51 +50,51 @@ class NS_MSG_BASE nsMsgKeyArray : public nsUInt32Array
{
// constructors
public:
nsMsgKeyArray() : nsUInt32Array() {}
nsMsgKeyArray() : nsUInt32Array() {}
// Public Operations on the nsMsgKey array - typesafe overrides
public:
nsMsgKey operator[](PRUint32 nIndex) const {
return((nsMsgKey)nsUInt32Array::operator[](nIndex));
}
nsMsgKey GetKeyFromIndex(PRUint32 nIndex) {
return(operator[](nIndex));
}
nsMsgKey GetAt(PRUint32 nIndex) const {
return(operator[](nIndex));
}
void SetAt(PRUint32 nIndex, nsMsgKey key) {
nsUInt32Array::SetAt(nIndex, (PRUint32)key);
}
void SetAtGrow(PRUint32 nIndex, nsMsgKey key) {
nsUInt32Array::SetAtGrow(nIndex, (uint32)key);
}
void InsertAt(PRUint32 nIndex, nsMsgKey key, int nCount = 1) {
nsUInt32Array::InsertAt(nIndex, (PRUint32)key, nCount);
}
void InsertAt(PRUint32 nIndex, const nsMsgKeyArray *idArray) {
nsUInt32Array::InsertAt(nIndex, idArray);
}
PRUint32 Add(nsMsgKey key) {
return(nsUInt32Array::Add((uint32)key));
}
PRUint32 Add(nsMsgKey *elementPtr, PRUint32 numElements) {
return nsUInt32Array::Add((PRUint32 *) elementPtr, numElements);
}
void CopyArray(nsMsgKeyArray *oldA) { nsUInt32Array::CopyArray((nsUInt32Array*) oldA); }
void CopyArray(nsMsgKeyArray &oldA) { nsUInt32Array::CopyArray(oldA); }
nsMsgKey operator[](PRUint32 nIndex) const {
return((nsMsgKey)nsUInt32Array::operator[](nIndex));
}
nsMsgKey GetKeyFromIndex(PRUint32 nIndex) {
return(operator[](nIndex));
}
nsMsgKey GetAt(PRUint32 nIndex) const {
return(operator[](nIndex));
}
void SetAt(PRUint32 nIndex, nsMsgKey key) {
nsUInt32Array::SetAt(nIndex, (PRUint32)key);
}
void SetAtGrow(PRUint32 nIndex, nsMsgKey key) {
nsUInt32Array::SetAtGrow(nIndex, (uint32)key);
}
void InsertAt(PRUint32 nIndex, nsMsgKey key, int nCount = 1) {
nsUInt32Array::InsertAt(nIndex, (PRUint32)key, nCount);
}
void InsertAt(PRUint32 nIndex, const nsMsgKeyArray *idArray) {
nsUInt32Array::InsertAt(nIndex, idArray);
}
PRUint32 Add(nsMsgKey key) {
return(nsUInt32Array::Add((uint32)key));
}
PRUint32 Add(nsMsgKey *elementPtr, PRUint32 numElements) {
return nsUInt32Array::Add((PRUint32 *) elementPtr, numElements);
}
void CopyArray(nsMsgKeyArray *oldA) { nsUInt32Array::CopyArray((nsUInt32Array*) oldA); }
void CopyArray(nsMsgKeyArray &oldA) { nsUInt32Array::CopyArray(oldA); }
// new operations
public:
nsMsgViewIndex FindIndex(nsMsgKey key, PRUint32 startIndex = 0); // returns -1 if not found
// use these next two carefully
nsMsgKey* GetArray(void) {
return((nsMsgKey*)m_pData); // only valid until another function
// called on the array (like
// GetBuffer() in CString)
}
void SetArray(nsMsgKey* pData, int numElements,
int numAllocated);
nsMsgViewIndex FindIndex(nsMsgKey key, PRUint32 startIndex = 0); // returns -1 if not found
// use these next two carefully
nsMsgKey* GetArray(void) {
return((nsMsgKey*)m_pData); // only valid until another function
// called on the array (like
// GetBuffer() in CString)
}
void SetArray(nsMsgKey* pData, int numElements,
int numAllocated);
};
///////////////////////////////////////////////////////
#endif // _IDARRAY_H_

View File

@@ -68,7 +68,7 @@ public:
// Output() converts to a string representation suitable for writing to a
// .newsrc file.
nsresult Output(char **outputStr);
nsresult Output(char **outputStr);
// IsMember() returns whether the given article is a member of this set.
PRBool IsMember(PRInt32 art);
@@ -127,14 +127,14 @@ protected:
static void test_member(PRBool with_cache);
#endif
PRInt32 *m_data; /* the numbers composing the `chunks' */
PRInt32 m_data_size; /* size of that malloc'ed block */
PRInt32 m_length; /* active area */
PRInt32 *m_data; /* the numbers composing the `chunks' */
PRInt32 m_data_size; /* size of that malloc'ed block */
PRInt32 m_length; /* active area */
PRInt32 m_cached_value; /* a potential set member, or -1 if unset*/
PRInt32 m_cached_value_index; /* the index into `data' at which a search
to determine whether `cached_value' was
a member of the set ended. */
PRInt32 m_cached_value; /* a potential set member, or -1 if unset*/
PRInt32 m_cached_value_index; /* the index into `data' at which a search
to determine whether `cached_value' was
a member of the set ended. */
#ifdef NEWSRC_DOES_HOST_STUFF
MSG_NewsHost* m_host;
#endif

View File

@@ -116,7 +116,7 @@ nsMsgLineBuffer::SetLookingForCRLF(PRBool b)
m_lookingForCRLF = b;
}
PRInt32 nsMsgLineBuffer::BufferInput(const char *net_buffer, PRInt32 net_buffer_size)
PRInt32 nsMsgLineBuffer::BufferInput(const char *net_buffer, PRInt32 net_buffer_size)
{
int status = 0;
if (m_bufferPos > 0 && m_buffer && m_buffer[m_bufferPos - 1] == '\r' &&
@@ -210,8 +210,8 @@ PRInt32 nsMsgLineBuffer::BufferInput(const char *net_buffer, PRInt32 net_buffer_
PRInt32 nsMsgLineBuffer::HandleLine(char *line, PRUint32 line_length)
{
NS_ASSERTION(PR_FALSE, "must override this method if you don't provide a handler");
return 0;
NS_ASSERTION(PR_FALSE, "must override this method if you don't provide a handler");
return 0;
}
PRInt32 nsMsgLineBuffer::ConvertAndSendBuffer()
@@ -267,12 +267,12 @@ PRInt32 nsMsgLineBuffer::ConvertAndSendBuffer()
// If there's still some data (non CRLF terminated) flush it out
PRInt32 nsMsgLineBuffer::FlushLastLine()
{
char *buf = m_buffer + m_bufferPos;
PRInt32 length = m_bufferPos - 1;
if (length > 0)
return (m_handler) ? m_handler->HandleLine(buf, length) : HandleLine(buf, length);
else
return 0;
char *buf = m_buffer + m_bufferPos;
PRInt32 length = m_bufferPos - 1;
if (length > 0)
return (m_handler) ? m_handler->HandleLine(buf, length) : HandleLine(buf, length);
else
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -281,20 +281,20 @@ PRInt32 nsMsgLineBuffer::FlushLastLine()
///////////////////////////////////////////////////////////////////////////////////////////////////
nsMsgLineStreamBuffer::nsMsgLineStreamBuffer(PRUint32 aBufferSize, PRBool aAllocateNewLines, PRBool aEatCRLFs, char aLineToken)
: m_eatCRLFs(aEatCRLFs), m_allocateNewLines(aAllocateNewLines), m_lineToken(aLineToken)
: m_eatCRLFs(aEatCRLFs), m_allocateNewLines(aAllocateNewLines), m_lineToken(aLineToken)
{
NS_PRECONDITION(aBufferSize > 0, "invalid buffer size!!!");
m_dataBuffer = nsnull;
m_startPos = 0;
NS_PRECONDITION(aBufferSize > 0, "invalid buffer size!!!");
m_dataBuffer = nsnull;
m_startPos = 0;
m_numBytesInBuffer = 0;
// used to buffer incoming data by ReadNextLineFromInput
if (aBufferSize > 0)
{
m_dataBuffer = (char *) PR_CALLOC(sizeof(char) * aBufferSize);
}
// used to buffer incoming data by ReadNextLineFromInput
if (aBufferSize > 0)
{
m_dataBuffer = (char *) PR_CALLOC(sizeof(char) * aBufferSize);
}
m_dataBufferSize = aBufferSize;
m_dataBufferSize = aBufferSize;
}
nsMsgLineStreamBuffer::~nsMsgLineStreamBuffer()

View File

@@ -48,17 +48,17 @@ class NS_MSG_BASE nsByteArray
public:
nsByteArray();
virtual ~nsByteArray();
PRUint32 GetSize() {return m_bufferSize;}
PRUint32 GetBufferPos() {return m_bufferPos;}
nsresult GrowBuffer(PRUint32 desired_size, PRUint32 quantum = 1024);
nsresult AppendString(const char *string);
nsresult AppendBuffer(const char *buffer, PRUint32 length);
void ResetWritePos() {m_bufferPos = 0;}
char *GetBuffer() {return m_buffer;}
PRUint32 GetSize() {return m_bufferSize;}
PRUint32 GetBufferPos() {return m_bufferPos;}
nsresult GrowBuffer(PRUint32 desired_size, PRUint32 quantum = 1024);
nsresult AppendString(const char *string);
nsresult AppendBuffer(const char *buffer, PRUint32 length);
void ResetWritePos() {m_bufferPos = 0;}
char *GetBuffer() {return m_buffer;}
protected:
char *m_buffer;
PRUint32 m_bufferSize;
PRUint32 m_bufferPos; // write Pos in m_buffer - where the next byte should go.
char *m_buffer;
PRUint32 m_bufferSize;
PRUint32 m_bufferPos; // write Pos in m_buffer - where the next byte should go.
};
@@ -104,13 +104,13 @@ class NS_MSG_BASE nsMsgLineStreamBuffer
public:
// aBufferSize -- size of the buffer you want us to use for buffering stream data
// aEndOfLinetoken -- The delimiter string to be used for determining the end of line. This
// allows us to parse platform specific end of line endings by making it
// a parameter.
// allows us to parse platform specific end of line endings by making it
// a parameter.
// aAllocateNewLines -- PR_TRUE if you want calls to ReadNextLine to allocate new memory for the line.
// if false, the char * returned is just a ptr into the buffer. Subsequent calls to
// ReadNextLine will alter the data so your ptr only has a life time of a per call.
// if false, the char * returned is just a ptr into the buffer. Subsequent calls to
// 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.
// PR_FALSE if you do want to see them.
// aLineToken -- Specify the line token to look for, by default is LF ('\n') which cover as well CRLF. If
// lines are terminated with a CR only, you need to set aLineToken to CR ('\r')
nsMsgLineStreamBuffer(PRUint32 aBufferSize, PRBool aAllocateNewLines,

View File

@@ -270,7 +270,7 @@ nsresult nsMsgProtocol::OpenFileSocket(nsIURI * aURL, PRUint32 aStartPosition, P
getter_AddRefs(m_transport));
m_socketIsOpen = PR_FALSE;
return rv;
return rv;
}
nsresult nsMsgProtocol::SetupTransportState()
@@ -329,7 +329,7 @@ PRInt32 nsMsgProtocol::SendData(nsIURI * aURL, const char * dataBuffer, PRBool a
PRUint32 writeCount = 0;
PRInt32 status = 0;
// NS_PRECONDITION(m_outputStream, "oops....we don't have an output stream...how did that happen?");
// NS_PRECONDITION(m_outputStream, "oops....we don't have an output stream...how did that happen?");
if (dataBuffer && m_outputStream)
status = m_outputStream->Write(dataBuffer, PL_strlen(dataBuffer), &writeCount);
@@ -1386,9 +1386,9 @@ nsresult nsMsgAsyncWriteProtocol::SetupTransportState()
// wait for the output stream to become writable
rv = mAsyncOutStream->AsyncWait(mProvider, 0, 0, mProviderThread);
} // if m_transport
} // if m_transport
return rv;
return rv;
}
nsresult nsMsgAsyncWriteProtocol::CloseSocket()
@@ -1408,7 +1408,7 @@ nsresult nsMsgAsyncWriteProtocol::CloseSocket()
mAsyncOutStream = 0;
mProvider = 0;
mProviderThread = 0;
return rv;
return rv;
}
void nsMsgAsyncWriteProtocol::UpdateProgress(PRUint32 aNewBytes)

View File

@@ -133,7 +133,7 @@ protected:
// As data arrives on the socket, OnDataAvailable calls ProcessProtocolState.
virtual nsresult ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream,
PRUint32 sourceOffset, PRUint32 length) = 0;
PRUint32 sourceOffset, PRUint32 length) = 0;
// SendData -- Writes the data contained in dataBuffer into the current output stream.
// It also informs the transport layer that this data is now available for transmission.
@@ -151,7 +151,7 @@ protected:
nsresult DoGSSAPIStep1(const char *service, const char *username, nsCString &response);
nsresult DoGSSAPIStep2(nsCString &commandResponse, nsCString &response);
// Ouput stream for writing commands to the socket
// Ouput stream for writing commands to the socket
nsCOMPtr<nsIOutputStream> m_outputStream; // this will be obtained from the transport interface
nsCOMPtr<nsIInputStream> m_inputStream;
@@ -162,7 +162,7 @@ protected:
PRBool m_socketIsOpen; // mscott: we should look into keeping this state in the nsSocketTransport...
// I'm using it to make sure I open the socket the first time a URL is loaded into the connection
PRUint32 m_flags; // used to store flag information
//PRUint32 m_startPosition;
//PRUint32 m_startPosition;
PRInt32 m_readCount;
nsCOMPtr<nsIFile> m_tempMsgFile; // we currently have a hack where displaying a msg involves writing it to a temp file first
@@ -174,7 +174,7 @@ protected:
nsCOMPtr<nsIURI> m_originalUrl; // the original url
nsCOMPtr<nsIURI> m_url; // the running url
nsCOMPtr<nsIStreamListener> m_channelListener;
nsCOMPtr<nsISupports> m_channelContext;
nsCOMPtr<nsISupports> m_channelContext;
nsCOMPtr<nsILoadGroup> m_loadGroup;
nsLoadFlags mLoadFlags;
nsCOMPtr<nsIProgressEventSink> mProgressEventSink;

View File

@@ -59,7 +59,7 @@ NS_IMETHODIMP nsMsgTxn::GetIsTransient(PRBool *aIsTransient)
if (nsnull!=aIsTransient)
*aIsTransient = PR_FALSE;
else
return NS_ERROR_NULL_POINTER;
return NS_ERROR_NULL_POINTER;
return NS_OK;
}

View File

@@ -47,7 +47,7 @@
#define NS_MESSAGETRANSACTION_IID \
{ /* da621b30-1efc-11d3-abe4-00805f8ac968 */ \
0xda621b30, 0x1efc, 0x11d3, \
{ 0xab, 0xe4, 0x00, 0x80, 0x5f, 0x8a, 0xc9, 0x68 } }
{ 0xab, 0xe4, 0x00, 0x80, 0x5f, 0x8a, 0xc9, 0x68 } }
/**
* base class for all message undo/redo transactions.
*/

View File

@@ -344,16 +344,16 @@ nsresult NS_MsgHashIfNecessary(nsCAutoString &name)
// Need to check the first ('.') and last ('.', '~' and ' ') char
if (illegalCharacterIndex == kNotFound)
{
NS_NAMED_LITERAL_CSTRING (illegalFirstChars, ILLEGAL_FOLDER_CHARS_AS_FIRST_LETTER);
NS_NAMED_LITERAL_CSTRING (illegalLastChars, ILLEGAL_FOLDER_CHARS_AS_LAST_LETTER);
NS_NAMED_LITERAL_CSTRING (illegalFirstChars, ILLEGAL_FOLDER_CHARS_AS_FIRST_LETTER);
NS_NAMED_LITERAL_CSTRING (illegalLastChars, ILLEGAL_FOLDER_CHARS_AS_LAST_LETTER);
PRInt32 lastIndex = str.Length() - 1;
if(str.FindCharInSet(illegalFirstChars) == 0)
illegalCharacterIndex = 0;
else if(str.RFindCharInSet(illegalLastChars) == lastIndex)
illegalCharacterIndex = lastIndex;
else
illegalCharacterIndex = -1;
illegalCharacterIndex = 0;
else if(str.RFindCharInSet(illegalLastChars) == lastIndex)
illegalCharacterIndex = lastIndex;
else
illegalCharacterIndex = -1;
}
char hashedname[MAX_LEN + 1];
@@ -398,16 +398,16 @@ nsresult NS_MsgHashIfNecessary(nsAutoString &name)
// Need to check the first ('.') and last ('.', '~' and ' ') char
if (illegalCharacterIndex == kNotFound)
{
NS_NAMED_LITERAL_STRING (illegalFirstChars, ILLEGAL_FOLDER_CHARS_AS_FIRST_LETTER);
NS_NAMED_LITERAL_STRING (illegalLastChars, ILLEGAL_FOLDER_CHARS_AS_LAST_LETTER);
NS_NAMED_LITERAL_STRING (illegalFirstChars, ILLEGAL_FOLDER_CHARS_AS_FIRST_LETTER);
NS_NAMED_LITERAL_STRING (illegalLastChars, ILLEGAL_FOLDER_CHARS_AS_LAST_LETTER);
PRInt32 lastIndex = name.Length() - 1;
if(name.FindCharInSet(illegalFirstChars) == 0)
illegalCharacterIndex = 0;
else if(name.RFindCharInSet(illegalLastChars) == lastIndex)
illegalCharacterIndex = lastIndex;
else
illegalCharacterIndex = -1;
illegalCharacterIndex = 0;
else if(name.RFindCharInSet(illegalLastChars) == lastIndex)
illegalCharacterIndex = lastIndex;
else
illegalCharacterIndex = -1;
}
char hashedname[9];
@@ -542,7 +542,7 @@ PRBool NS_MsgStripRE(const char **stringP, PRUint32 *lengthP, char **modifiedSub
AGAIN:
while (s < s_end && IS_SPACE(*s))
s++;
s++;
const char *tokPtr = checkString.get();
while (*tokPtr)
@@ -614,15 +614,15 @@ PRBool NS_MsgStripRE(const char **stringP, PRUint32 *lengthP, char **modifiedSub
/* Decrease length by difference between current ptr and original ptr.
Then store the current ptr back into the caller. */
Then store the current ptr back into the caller. */
if (lengthP)
*lengthP -= (s - (*stringP));
*lengthP -= (s - (*stringP));
*stringP = s;
return result;
}
/* Very similar to strdup except it free's too
/* Very similar to strdup except it free's too
*/
char * NS_MsgSACopy (char **destination, const char *source)
{

View File

@@ -177,8 +177,8 @@ PRUint32 nsUInt32Array::Add(PRUint32 newElement)
#ifdef MAX_ARR_ELEMS
if (nIndex >= MAX_ARR_ELEMS)
return -1;
#endif
return -1;
#endif
SetAtGrow(nIndex, newElement);
return nIndex;

View File

@@ -78,7 +78,7 @@ public:
// Insertion/deletion member functions
PRUint32 Add(PRUint32 newElement);
PRUint32 Add(PRUint32 *elementPtr, PRUint32 numElements);
void InsertAt(PRUint32 nIndex, PRUint32 newElement, PRUint32 nCount = 1);
void InsertAt(PRUint32 nIndex, PRUint32 newElement, PRUint32 nCount = 1);
void InsertAt(PRUint32 nStartIndex, const nsUInt32Array *pNewArray);
void RemoveAll();
void RemoveAt(PRUint32 nIndex, PRUint32 nCount = 1);

View File

@@ -40,102 +40,102 @@
nsUint8Array::nsUint8Array()
{
m_pData = nsnull;
m_nSize = m_nMaxSize = m_nGrowBy = 0;
m_pData = nsnull;
m_nSize = m_nMaxSize = m_nGrowBy = 0;
}
nsUint8Array::~nsUint8Array()
{
PR_Free(m_pData);
PR_Free(m_pData);
}
void nsUint8Array::SetSize(PRInt32 nNewSize, PRInt32 nGrowBy)
{
// AssertValid(this);
NS_ASSERTION(nNewSize >= 0, "can't set size to negative value");
// AssertValid(this);
NS_ASSERTION(nNewSize >= 0, "can't set size to negative value");
if (nGrowBy != -1)
m_nGrowBy = nGrowBy; // set new size
if (nGrowBy != -1)
m_nGrowBy = nGrowBy; // set new size
if (nNewSize == 0)
{
// shrink to nothing
PR_Free(m_pData);
m_pData = nsnull;
m_nSize = m_nMaxSize = 0;
}
else if (m_pData == nsnull)
{
// create one with exact size
m_pData = (PRUint8*)PR_Malloc(nNewSize * sizeof(PRUint8));
if (nNewSize == 0)
{
// shrink to nothing
PR_Free(m_pData);
m_pData = nsnull;
m_nSize = m_nMaxSize = 0;
}
else if (m_pData == nsnull)
{
// create one with exact size
m_pData = (PRUint8*)PR_Malloc(nNewSize * sizeof(PRUint8));
memset(m_pData, 0, nNewSize * sizeof(PRUint8)); // zero fill
memset(m_pData, 0, nNewSize * sizeof(PRUint8)); // zero fill
m_nSize = m_nMaxSize = nNewSize;
}
else if (nNewSize <= m_nMaxSize)
{
m_nSize = m_nMaxSize = nNewSize;
}
else if (nNewSize <= m_nMaxSize)
{
// it fits
if (nNewSize > m_nSize)
{
// initialize the new elements
// initialize the new elements
memset(&m_pData[m_nSize], 0, (nNewSize-m_nSize) * sizeof(PRUint8));
}
m_nSize = nNewSize;
}
else
{
// otherwise, grow array
PRInt32 nGrowBy = m_nGrowBy;
if (nGrowBy == 0)
{
nGrowBy = PR_MIN(1024, PR_MAX(4, m_nSize / 8));
}
PRInt32 nNewMax;
if (nNewSize < m_nMaxSize + nGrowBy)
nNewMax = m_nMaxSize + nGrowBy; // granularity
else
nNewMax = nNewSize; // no slush
m_nSize = nNewSize;
}
else
{
// otherwise, grow array
PRInt32 nGrowBy = m_nGrowBy;
if (nGrowBy == 0)
{
nGrowBy = PR_MIN(1024, PR_MAX(4, m_nSize / 8));
}
PRInt32 nNewMax;
if (nNewSize < m_nMaxSize + nGrowBy)
nNewMax = m_nMaxSize + nGrowBy; // granularity
else
nNewMax = nNewSize; // no slush
NS_ASSERTION(nNewMax >= m_nMaxSize, "no wraparound"); // no wrap around
PRUint8* pNewData = (PRUint8*)PR_Malloc(nNewMax * sizeof(PRUint8));
NS_ASSERTION(nNewMax >= m_nMaxSize, "no wraparound"); // no wrap around
PRUint8* pNewData = (PRUint8*)PR_Malloc(nNewMax * sizeof(PRUint8));
// copy new data from old
// copy new data from old
memcpy(pNewData, m_pData, m_nSize * sizeof(PRUint8));
NS_ASSERTION(nNewSize > m_nSize, "did't grow size");
NS_ASSERTION(nNewSize > m_nSize, "did't grow size");
memset(&pNewData[m_nSize], 0, (nNewSize-m_nSize) * sizeof(PRUint8));
memset(&pNewData[m_nSize], 0, (nNewSize-m_nSize) * sizeof(PRUint8));
PR_Free(m_pData);
m_pData = pNewData;
m_nSize = nNewSize;
m_nMaxSize = nNewMax;
}
PR_Free(m_pData);
m_pData = pNewData;
m_nSize = nNewSize;
m_nMaxSize = nNewMax;
}
}
void nsUint8Array::FreeExtra()
{
if (m_nSize != m_nMaxSize)
{
// shrink to desired size
PRUint8* pNewData = nsnull;
if (m_nSize != 0)
{
pNewData = (PRUint8*)PR_Malloc(m_nSize * sizeof(PRUint8));
// copy new data from old
memcpy(pNewData, m_pData, m_nSize * sizeof(PRUint8));
}
if (m_nSize != m_nMaxSize)
{
// shrink to desired size
PRUint8* pNewData = nsnull;
if (m_nSize != 0)
{
pNewData = (PRUint8*)PR_Malloc(m_nSize * sizeof(PRUint8));
// copy new data from old
memcpy(pNewData, m_pData, m_nSize * sizeof(PRUint8));
}
// get rid of old stuff (note: no destructors called)
PR_Free(m_pData);
m_pData = pNewData;
m_nMaxSize = m_nSize;
}
// get rid of old stuff (note: no destructors called)
PR_Free(m_pData);
m_pData = pNewData;
m_nMaxSize = m_nSize;
}
}
void nsUint8Array::CopyArray(nsUint8Array &aSrcArray)
@@ -152,42 +152,42 @@ void nsUint8Array::CopyArray(nsUint8Array &aSrcArray)
void nsUint8Array::SetAtGrow(PRInt32 nIndex, PRUint8 newElement)
{
NS_ASSERTION(nIndex >= 0, "can't insert at negative index");
NS_ASSERTION(nIndex >= 0, "can't insert at negative index");
if (nIndex >= m_nSize)
SetSize(nIndex+1);
m_pData[nIndex] = newElement;
if (nIndex >= m_nSize)
SetSize(nIndex+1);
m_pData[nIndex] = newElement;
}
nsresult nsUint8Array::InsertAt(PRInt32 nIndex, PRUint8 newElement, PRInt32 nCount)
{
NS_ASSERTION(nIndex >= 0, "can't insert at negative index");
NS_ASSERTION(nCount > 0, "have to insert something"); // zero or negative size not allowed
NS_ASSERTION(nIndex >= 0, "can't insert at negative index");
NS_ASSERTION(nCount > 0, "have to insert something"); // zero or negative size not allowed
if (nIndex >= m_nSize)
{
// adding after the end of the array
SetSize(nIndex + nCount); // grow so nIndex is valid
}
else
{
// inserting in the middle of the array
PRInt32 nOldSize = m_nSize;
SetSize(m_nSize + nCount); // grow it to new size
// shift old data up to fill gap
if (nIndex >= m_nSize)
{
// adding after the end of the array
SetSize(nIndex + nCount); // grow so nIndex is valid
}
else
{
// inserting in the middle of the array
PRInt32 nOldSize = m_nSize;
SetSize(m_nSize + nCount); // grow it to new size
// shift old data up to fill gap
memmove(&m_pData[nIndex+nCount], &m_pData[nIndex],
(nOldSize-nIndex) * sizeof(PRUint8));
// re-init slots we copied from
// re-init slots we copied from
memset(&m_pData[nIndex], 0, nCount * sizeof(PRUint8));
memset(&m_pData[nIndex], 0, nCount * sizeof(PRUint8));
}
}
// insert new value in the gap
NS_ASSERTION(nIndex + nCount <= m_nSize, "overflow");
while (nCount--)
m_pData[nIndex++] = newElement;
// insert new value in the gap
NS_ASSERTION(nIndex + nCount <= m_nSize, "overflow");
while (nCount--)
m_pData[nIndex++] = newElement;
return NS_OK;
}
@@ -199,54 +199,54 @@ void nsUint8Array::RemoveAt(PRInt32 nIndex, PRInt32 nCount)
return;
}
// just remove a range
PRInt32 nMoveCount = m_nSize - (nIndex + nCount);
// just remove a range
PRInt32 nMoveCount = m_nSize - (nIndex + nCount);
NS_ASSERTION(nMoveCount >= 0, "can't remove nothing");
if (nMoveCount >= 0)
NS_ASSERTION(nMoveCount >= 0, "can't remove nothing");
if (nMoveCount >= 0)
memmove(&m_pData[nIndex], &m_pData[nIndex + nCount],
nMoveCount * sizeof(PRUint8));
m_nSize -= nCount;
m_nSize -= nCount;
}
nsresult nsUint8Array::InsertAt(PRInt32 nStartIndex, nsUint8Array* pNewArray)
{
NS_ENSURE_ARG(pNewArray);
NS_ASSERTION(nStartIndex >= 0, "start index must be positive");
NS_ASSERTION(nStartIndex >= 0, "start index must be positive");
if (pNewArray->GetSize() > 0)
{
InsertAt(nStartIndex, pNewArray->GetAt(0), pNewArray->GetSize());
for (PRInt32 i = 0; i < pNewArray->GetSize(); i++)
SetAt(nStartIndex + i, pNewArray->GetAt(i));
}
if (pNewArray->GetSize() > 0)
{
InsertAt(nStartIndex, pNewArray->GetAt(0), pNewArray->GetSize());
for (PRInt32 i = 0; i < pNewArray->GetSize(); i++)
SetAt(nStartIndex + i, pNewArray->GetAt(i));
}
return NS_OK;
}
PRInt32 nsUint8Array::GetSize() const
{ return m_nSize; }
{ return m_nSize; }
PRInt32 nsUint8Array::GetUpperBound() const
{ return m_nSize-1; }
{ return m_nSize-1; }
void nsUint8Array::RemoveAll()
{ SetSize(0); }
{ SetSize(0); }
PRUint8 nsUint8Array::GetAt(PRInt32 nIndex) const
{ NS_ASSERTION(nIndex >= 0 && nIndex < m_nSize, "out of bounds");
return m_pData[nIndex]; }
{ NS_ASSERTION(nIndex >= 0 && nIndex < m_nSize, "out of bounds");
return m_pData[nIndex]; }
void nsUint8Array::SetAt(PRInt32 nIndex, PRUint8 newElement)
{ NS_ASSERTION(nIndex >= 0 && nIndex < m_nSize, "out of bounds");
m_pData[nIndex] = newElement; }
{ NS_ASSERTION(nIndex >= 0 && nIndex < m_nSize, "out of bounds");
m_pData[nIndex] = newElement; }
PRUint8& nsUint8Array::ElementAt(PRInt32 nIndex)
{ NS_ASSERTION(nIndex >= 0 && nIndex < m_nSize, "out of bounds");
return m_pData[nIndex]; }
{ NS_ASSERTION(nIndex >= 0 && nIndex < m_nSize, "out of bounds");
return m_pData[nIndex]; }
PRInt32 nsUint8Array::Add(PRUint8 newElement)
{ PRInt32 nIndex = m_nSize;
SetAtGrow(nIndex, newElement);
return nIndex; }
{ PRInt32 nIndex = m_nSize;
SetAtGrow(nIndex, newElement);
return nIndex; }
PRUint8 nsUint8Array::operator[](PRInt32 nIndex) const
{ return GetAt(nIndex); }
{ return GetAt(nIndex); }
PRUint8& nsUint8Array::operator[](PRInt32 nIndex)
{ return ElementAt(nIndex); }
{ return ElementAt(nIndex); }
/////////////////////////////////////////////////////////////////////////////

View File

@@ -47,53 +47,53 @@ class NS_MSG_BASE nsUint8Array
public:
// Construction
nsUint8Array();
nsUint8Array();
// Attributes
PRInt32 GetSize() const;
PRInt32 GetUpperBound() const;
void SetSize(PRInt32 nNewSize, PRInt32 nGrowBy = -1);
PRInt32 GetSize() const;
PRInt32 GetUpperBound() const;
void SetSize(PRInt32 nNewSize, PRInt32 nGrowBy = -1);
void AllocateSpace(PRUint32 nNewSize) { if (nNewSize == 0) return; PRInt32 saveSize = m_nSize; SetSize(nNewSize); m_nSize = saveSize;}
// Operations
// Clean up
void FreeExtra();
void RemoveAll();
// Clean up
void FreeExtra();
void RemoveAll();
// Accessing elements
PRUint8 GetAt(PRInt32 nIndex) const;
void SetAt(PRInt32 nIndex, PRUint8 newElement);
PRUint8& ElementAt(PRInt32 nIndex);
// Accessing elements
PRUint8 GetAt(PRInt32 nIndex) const;
void SetAt(PRInt32 nIndex, PRUint8 newElement);
PRUint8& ElementAt(PRInt32 nIndex);
// Potentially growing the array
void SetAtGrow(PRInt32 nIndex, PRUint8 newElement);
PRInt32 Add(PRUint8 newElement);
// Potentially growing the array
void SetAtGrow(PRInt32 nIndex, PRUint8 newElement);
PRInt32 Add(PRUint8 newElement);
// overloaded operator helpers
PRUint8 operator[](PRInt32 nIndex) const;
PRUint8& operator[](PRInt32 nIndex);
// overloaded operator helpers
PRUint8 operator[](PRInt32 nIndex) const;
PRUint8& operator[](PRInt32 nIndex);
// Operations that move elements around
nsresult InsertAt(PRInt32 nIndex, PRUint8 newElement, PRInt32 nCount = 1);
void RemoveAt(PRInt32 nIndex, PRInt32 nCount = 1);
nsresult InsertAt(PRInt32 nStartIndex, nsUint8Array* pNewArray);
void CopyArray(nsUint8Array &aSrcArray);
// Operations that move elements around
nsresult InsertAt(PRInt32 nIndex, PRUint8 newElement, PRInt32 nCount = 1);
void RemoveAt(PRInt32 nIndex, PRInt32 nCount = 1);
nsresult InsertAt(PRInt32 nStartIndex, nsUint8Array* pNewArray);
void CopyArray(nsUint8Array &aSrcArray);
// use carefully!
PRUint8* GetArray(void) {return((PRUint8*)m_pData);} // only valid until another function called on the array (like GetBuffer() in CString)
// use carefully!
PRUint8* GetArray(void) {return((PRUint8*)m_pData);} // only valid until another function called on the array (like GetBuffer() in CString)
// Implementation
protected:
PRUint8* m_pData; // the actual array of data
PRInt32 m_nSize; // # of elements (upperBound - 1)
PRInt32 m_nMaxSize; // max allocated
PRInt32 m_nGrowBy; // grow amount
PRUint8* m_pData; // the actual array of data
PRInt32 m_nSize; // # of elements (upperBound - 1)
PRInt32 m_nMaxSize; // max allocated
PRInt32 m_nGrowBy; // grow amount
public:
~nsUint8Array();
~nsUint8Array();
#ifdef _DEBUG
void AssertValid() const;
void AssertValid() const;
#endif
};