fixed PDT+ bug27954; r=buster;a=jar; precheckins ok

git-svn-id: svn://10.0.0.236/trunk@61291 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rickg%netscape.com
2000-02-18 07:47:47 +00:00
parent 13f16c5fc7
commit 98fb84c278
4 changed files with 50 additions and 26 deletions

View File

@@ -383,10 +383,14 @@ nsCString& nsCString::StripWhitespace() {
*/
nsCString& nsCString::ReplaceChar(PRUnichar aOldChar, PRUnichar aNewChar) {
PRUint32 theIndex=0;
for(theIndex=0;theIndex<mLength;theIndex++){
if(mStr[theIndex]==(char)aOldChar) {
mStr[theIndex]=(char)aNewChar;
}//if
if((aOldChar<256) && (aNewChar<256)){
//only execute this if oldchar and newchar are within legal ascii range
for(theIndex=0;theIndex<mLength;theIndex++){
if(mStr[theIndex]==(char)aOldChar) {
mStr[theIndex]=(char)aNewChar;
}//if
}
}
return *this;
}
@@ -399,7 +403,9 @@ nsCString& nsCString::ReplaceChar(PRUnichar aOldChar, PRUnichar aNewChar) {
* @return *this
*/
nsCString& nsCString::ReplaceChar(const char* aSet, PRUnichar aNewChar){
if(aSet){
if(aSet && (aNewChar<256)){
//only execute this if newchar is valid ascii, and aset isn't null.
PRInt32 theIndex=FindCharInSet(aSet,0);
while(kNotFound<theIndex) {
mStr[theIndex]=(char)aNewChar;
@@ -589,7 +595,7 @@ nsCString* nsCString::ToNewString() const {
* @return ptr to new ascii string
*/
char* nsCString::ToNewCString() const {
nsCString temp(mStr);
nsCString temp(*this);
temp.SetCapacity(8);
char* result=temp.mStr;
temp.mStr=0;
@@ -603,7 +609,7 @@ char* nsCString::ToNewCString() const {
* @return ptr to new ascii string
*/
PRUnichar* nsCString::ToNewUnicode() const {
nsString temp(mStr);
nsString temp(mStr,mLength);
temp.SetCapacity(8);
PRUnichar* result=temp.mUStr;
temp.mStr=0;