зеркало из https://github.com/mozilla/pjs.git
removed bug from deque, and added replaceChar call to string
This commit is contained in:
Родитель
896c28ad84
Коммит
e2e2dfc7e9
|
@ -67,7 +67,9 @@ PRInt32 nsDeque::GetSize(void) const {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
nsDeque& nsDeque::Empty() {
|
nsDeque& nsDeque::Empty() {
|
||||||
nsCRT::zero(mData,mCapacity*sizeof(mData));
|
if((0<mCapacity) && (mData)) {
|
||||||
|
nsCRT::zero(mData,mCapacity*sizeof(mData));
|
||||||
|
}
|
||||||
mSize=0;
|
mSize=0;
|
||||||
mOrigin=0;
|
mOrigin=0;
|
||||||
return *this;
|
return *this;
|
||||||
|
|
|
@ -1400,6 +1400,28 @@ nsString& nsString::StripWhitespace()
|
||||||
return StripChars("\r\t\n");
|
return StripChars("\r\t\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to replace all occurances of the
|
||||||
|
* given source char with the given dest char
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
nsString& nsString::ReplaceChar(PRUnichar aSourceChar, PRUnichar aDestChar) {
|
||||||
|
PRUnichar* from = mStr;
|
||||||
|
PRUnichar* end = mStr + mLength;
|
||||||
|
|
||||||
|
while (from < end) {
|
||||||
|
PRUnichar ch = *from;
|
||||||
|
if(ch==aSourceChar) {
|
||||||
|
*from = aDestChar;
|
||||||
|
}
|
||||||
|
from++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for given character within this string.
|
* Search for given character within this string.
|
||||||
* This method does so by using a binary search,
|
* This method does so by using a binary search,
|
||||||
|
|
|
@ -499,6 +499,15 @@ nsString& Cut(PRInt32 anOffset,PRInt32 aCount);
|
||||||
*/
|
*/
|
||||||
nsString& StripChars(const char* aSet);
|
nsString& StripChars(const char* aSet);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to replace all occurances of the
|
||||||
|
* given source char with the given dest char
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
nsString& ReplaceChar(PRUnichar aSourceChar, PRUnichar aDestChar);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method strips whitespace throughout the string
|
* This method strips whitespace throughout the string
|
||||||
*
|
*
|
||||||
|
|
|
@ -1400,6 +1400,28 @@ nsString& nsString::StripWhitespace()
|
||||||
return StripChars("\r\t\n");
|
return StripChars("\r\t\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to replace all occurances of the
|
||||||
|
* given source char with the given dest char
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
nsString& nsString::ReplaceChar(PRUnichar aSourceChar, PRUnichar aDestChar) {
|
||||||
|
PRUnichar* from = mStr;
|
||||||
|
PRUnichar* end = mStr + mLength;
|
||||||
|
|
||||||
|
while (from < end) {
|
||||||
|
PRUnichar ch = *from;
|
||||||
|
if(ch==aSourceChar) {
|
||||||
|
*from = aDestChar;
|
||||||
|
}
|
||||||
|
from++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for given character within this string.
|
* Search for given character within this string.
|
||||||
* This method does so by using a binary search,
|
* This method does so by using a binary search,
|
||||||
|
|
|
@ -499,6 +499,15 @@ nsString& Cut(PRInt32 anOffset,PRInt32 aCount);
|
||||||
*/
|
*/
|
||||||
nsString& StripChars(const char* aSet);
|
nsString& StripChars(const char* aSet);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to replace all occurances of the
|
||||||
|
* given source char with the given dest char
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
nsString& ReplaceChar(PRUnichar aSourceChar, PRUnichar aDestChar);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method strips whitespace throughout the string
|
* This method strips whitespace throughout the string
|
||||||
*
|
*
|
||||||
|
|
|
@ -67,7 +67,9 @@ PRInt32 nsDeque::GetSize(void) const {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
nsDeque& nsDeque::Empty() {
|
nsDeque& nsDeque::Empty() {
|
||||||
nsCRT::zero(mData,mCapacity*sizeof(mData));
|
if((0<mCapacity) && (mData)) {
|
||||||
|
nsCRT::zero(mData,mCapacity*sizeof(mData));
|
||||||
|
}
|
||||||
mSize=0;
|
mSize=0;
|
||||||
mOrigin=0;
|
mOrigin=0;
|
||||||
return *this;
|
return *this;
|
||||||
|
|
|
@ -1400,6 +1400,28 @@ nsString& nsString::StripWhitespace()
|
||||||
return StripChars("\r\t\n");
|
return StripChars("\r\t\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to replace all occurances of the
|
||||||
|
* given source char with the given dest char
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
nsString& nsString::ReplaceChar(PRUnichar aSourceChar, PRUnichar aDestChar) {
|
||||||
|
PRUnichar* from = mStr;
|
||||||
|
PRUnichar* end = mStr + mLength;
|
||||||
|
|
||||||
|
while (from < end) {
|
||||||
|
PRUnichar ch = *from;
|
||||||
|
if(ch==aSourceChar) {
|
||||||
|
*from = aDestChar;
|
||||||
|
}
|
||||||
|
from++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for given character within this string.
|
* Search for given character within this string.
|
||||||
* This method does so by using a binary search,
|
* This method does so by using a binary search,
|
||||||
|
|
|
@ -499,6 +499,15 @@ nsString& Cut(PRInt32 anOffset,PRInt32 aCount);
|
||||||
*/
|
*/
|
||||||
nsString& StripChars(const char* aSet);
|
nsString& StripChars(const char* aSet);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to replace all occurances of the
|
||||||
|
* given source char with the given dest char
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
nsString& ReplaceChar(PRUnichar aSourceChar, PRUnichar aDestChar);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method strips whitespace throughout the string
|
* This method strips whitespace throughout the string
|
||||||
*
|
*
|
||||||
|
|
|
@ -1400,6 +1400,28 @@ nsString& nsString::StripWhitespace()
|
||||||
return StripChars("\r\t\n");
|
return StripChars("\r\t\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to replace all occurances of the
|
||||||
|
* given source char with the given dest char
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
nsString& nsString::ReplaceChar(PRUnichar aSourceChar, PRUnichar aDestChar) {
|
||||||
|
PRUnichar* from = mStr;
|
||||||
|
PRUnichar* end = mStr + mLength;
|
||||||
|
|
||||||
|
while (from < end) {
|
||||||
|
PRUnichar ch = *from;
|
||||||
|
if(ch==aSourceChar) {
|
||||||
|
*from = aDestChar;
|
||||||
|
}
|
||||||
|
from++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for given character within this string.
|
* Search for given character within this string.
|
||||||
* This method does so by using a binary search,
|
* This method does so by using a binary search,
|
||||||
|
|
|
@ -499,6 +499,15 @@ nsString& Cut(PRInt32 anOffset,PRInt32 aCount);
|
||||||
*/
|
*/
|
||||||
nsString& StripChars(const char* aSet);
|
nsString& StripChars(const char* aSet);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to replace all occurances of the
|
||||||
|
* given source char with the given dest char
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return *this
|
||||||
|
*/
|
||||||
|
nsString& ReplaceChar(PRUnichar aSourceChar, PRUnichar aDestChar);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method strips whitespace throughout the string
|
* This method strips whitespace throughout the string
|
||||||
*
|
*
|
||||||
|
|
Загрузка…
Ссылка в новой задаче