зеркало из https://github.com/mozilla/pjs.git
fixed bug28837 (r=troy; a=jar). Removed warnings (r=troy)
This commit is contained in:
Родитель
592170ea93
Коммит
39a604256b
|
@ -481,7 +481,7 @@ inline void Recycle( PRUnichar* aBuffer) { nsAllocator::Free(aBuffer); }
|
|||
*/
|
||||
inline PRUnichar GetCharAt(const nsStr& aDest,PRUint32 anIndex){
|
||||
if(anIndex<aDest.mLength) {
|
||||
return (eTwoByte==aDest.mCharSize) ? aDest.mUStr[anIndex] : aDest.mStr[anIndex];
|
||||
return (eTwoByte==aDest.mCharSize) ? aDest.mUStr[anIndex] : (PRUnichar)aDest.mStr[anIndex];
|
||||
}//if
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ void nsCString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
|
|||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void nsCString::Truncate(PRInt32 anIndex) {
|
||||
void nsCString::Truncate(PRUint32 anIndex) {
|
||||
nsStr::Truncate(*this,anIndex);
|
||||
}
|
||||
|
||||
|
@ -591,15 +591,15 @@ nsCString* nsCString::ToNewString() const {
|
|||
/**
|
||||
* Creates an ascii clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @update gess 01/04/99
|
||||
* @update gess 02/24/00
|
||||
* @return ptr to new ascii string
|
||||
*/
|
||||
char* nsCString::ToNewCString() const {
|
||||
nsCString temp(*this);
|
||||
temp.SetCapacity(8);
|
||||
char* result=temp.mStr;
|
||||
temp.mStr=0;
|
||||
return result;
|
||||
nsCString temp(*this); //construct nsCString with alloc on heap (which we'll steal in a moment)
|
||||
temp.SetCapacity(8); //force it to have an allocated buffer, even if this is empty.
|
||||
char* result=temp.mStr; //steal temp's buffer
|
||||
temp.mStr=0; //clear temp's buffer to prevent deallocation
|
||||
return result; //and return the char*
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -609,11 +609,11 @@ char* nsCString::ToNewCString() const {
|
|||
* @return ptr to new ascii string
|
||||
*/
|
||||
PRUnichar* nsCString::ToNewUnicode() const {
|
||||
nsString temp(mStr,mLength);
|
||||
temp.SetCapacity(8);
|
||||
PRUnichar* result=temp.mUStr;
|
||||
temp.mStr=0;
|
||||
temp.mOwnsBuffer=PR_FALSE;
|
||||
nsString temp(*this); //construct nsCString with alloc on heap (which we'll steal in a moment)
|
||||
temp.SetCapacity(8); //force temp to have an allocated buffer, even if this is empty.
|
||||
PRUnichar* result=temp.mUStr; //steal temp's buffer
|
||||
temp.mStr=0; //now clear temp's buffer to prevent deallocation
|
||||
temp.mOwnsBuffer=PR_FALSE; //and return the PRUnichar*
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ public:
|
|||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void Truncate(PRInt32 anIndex=0);
|
||||
void Truncate(PRUint32 anIndex=0);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -400,7 +400,7 @@ public:
|
|||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsCString& operator+=(const nsCString& aString){return Append(aString,aString.mLength);}
|
||||
nsCString& operator+=(const nsCString& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsCString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
nsCString& operator+=(const PRUnichar aChar){return Append(aChar);}
|
||||
nsCString& operator+=(const char aChar){return Append(aChar);}
|
||||
|
@ -413,7 +413,7 @@ public:
|
|||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsCString& Append(const nsCString& aString) {return Append(aString,aString.mLength);}
|
||||
nsCString& Append(const nsCString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -149,7 +149,7 @@ void nsString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
|
|||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void nsString::Truncate(PRInt32 anIndex) {
|
||||
void nsString::Truncate(PRUint32 anIndex) {
|
||||
nsStr::Truncate(*this,anIndex);
|
||||
}
|
||||
|
||||
|
@ -661,23 +661,19 @@ nsString* nsString::ToNewString() const {
|
|||
/**
|
||||
* Creates an ascii clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @update gess 01/04/99
|
||||
* @update gess 02/24/00
|
||||
* @WARNING! Potential i18n issue here, since we're stepping down from 2byte chars to 1byte chars!
|
||||
* @return ptr to new ascii string
|
||||
*/
|
||||
char* nsString::ToNewCString() const {
|
||||
nsCString temp(*this);
|
||||
temp.SetCapacity(8); //ensure that we get an allocated buffer instead of the common empty one.
|
||||
char* result=temp.mStr;
|
||||
temp.mStr=0;
|
||||
temp.mOwnsBuffer=PR_FALSE;
|
||||
|
||||
#ifdef RICKG_DEBUG
|
||||
// fstream& theStream=GetLogStream();
|
||||
// theStream << "tonewcString() " << result << endl;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
nsCString temp(*this); //construct nsCString with alloc on heap (which we'll steal in a moment)
|
||||
temp.SetCapacity(8); //force it to have an allocated buffer, even if this is empty.
|
||||
char* result=temp.mStr; //steal temp's buffer
|
||||
temp.mStr=0; //clear temp's buffer to prevent deallocation
|
||||
return result; //and return the char*
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an UTF8 clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
|
@ -761,26 +757,17 @@ char* nsString::ToNewUTF8String() const {
|
|||
/**
|
||||
* Creates an ascii clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @update gess 01/04/99
|
||||
* @update gess 02/24/00
|
||||
* @return ptr to new ascii string
|
||||
*/
|
||||
PRUnichar* nsString::ToNewUnicode() const {
|
||||
PRUnichar* result=0;
|
||||
if(eOneByte==mCharSize) {
|
||||
nsString temp(mStr);
|
||||
temp.SetCapacity(8);
|
||||
result=temp.mUStr;
|
||||
temp.mStr=0;
|
||||
temp.mOwnsBuffer=PR_FALSE;
|
||||
}
|
||||
else{
|
||||
nsString temp(mUStr);
|
||||
temp.SetCapacity(8);
|
||||
result=temp.mUStr;
|
||||
temp.mStr=0;
|
||||
temp.mOwnsBuffer=PR_FALSE;
|
||||
}
|
||||
return result;
|
||||
|
||||
nsString temp(*this); //construct nsString with alloc on heap (which we'll steal in a moment)
|
||||
temp.SetCapacity(8); //force it to have an allocated buffer, even if this is empty.
|
||||
PRUnichar* result=temp.mUStr; //steal temp's buffer
|
||||
temp.mStr=0; //clear temp's buffer to prevent deallocation
|
||||
temp.mOwnsBuffer=PR_FALSE;
|
||||
return result; //and return the PRUnichar* to the caller
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -141,7 +141,7 @@ public:
|
|||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void Truncate(PRInt32 anIndex=0);
|
||||
void Truncate(PRUint32 anIndex=0);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -443,8 +443,8 @@ public:
|
|||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsString& operator+=(const nsStr& aString){return Append(aString,aString.mLength);}
|
||||
nsString& operator+=(const nsString& aString){return Append(aString,aString.mLength);}
|
||||
nsString& operator+=(const nsStr& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const nsString& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
nsString& operator+=(const char aChar) {
|
||||
return Append((PRUnichar) (unsigned char)aChar);
|
||||
|
@ -461,8 +461,8 @@ public:
|
|||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsString& Append(const nsStr& aString) {return Append(aString,aString.mLength);}
|
||||
nsString& Append(const nsString& aString) {return Append(aString,aString.mLength);}
|
||||
nsString& Append(const nsStr& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& Append(const nsString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -481,7 +481,7 @@ inline void Recycle( PRUnichar* aBuffer) { nsAllocator::Free(aBuffer); }
|
|||
*/
|
||||
inline PRUnichar GetCharAt(const nsStr& aDest,PRUint32 anIndex){
|
||||
if(anIndex<aDest.mLength) {
|
||||
return (eTwoByte==aDest.mCharSize) ? aDest.mUStr[anIndex] : aDest.mStr[anIndex];
|
||||
return (eTwoByte==aDest.mCharSize) ? aDest.mUStr[anIndex] : (PRUnichar)aDest.mStr[anIndex];
|
||||
}//if
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ void nsCString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
|
|||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void nsCString::Truncate(PRInt32 anIndex) {
|
||||
void nsCString::Truncate(PRUint32 anIndex) {
|
||||
nsStr::Truncate(*this,anIndex);
|
||||
}
|
||||
|
||||
|
@ -591,15 +591,15 @@ nsCString* nsCString::ToNewString() const {
|
|||
/**
|
||||
* Creates an ascii clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @update gess 01/04/99
|
||||
* @update gess 02/24/00
|
||||
* @return ptr to new ascii string
|
||||
*/
|
||||
char* nsCString::ToNewCString() const {
|
||||
nsCString temp(*this);
|
||||
temp.SetCapacity(8);
|
||||
char* result=temp.mStr;
|
||||
temp.mStr=0;
|
||||
return result;
|
||||
nsCString temp(*this); //construct nsCString with alloc on heap (which we'll steal in a moment)
|
||||
temp.SetCapacity(8); //force it to have an allocated buffer, even if this is empty.
|
||||
char* result=temp.mStr; //steal temp's buffer
|
||||
temp.mStr=0; //clear temp's buffer to prevent deallocation
|
||||
return result; //and return the char*
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -609,11 +609,11 @@ char* nsCString::ToNewCString() const {
|
|||
* @return ptr to new ascii string
|
||||
*/
|
||||
PRUnichar* nsCString::ToNewUnicode() const {
|
||||
nsString temp(mStr,mLength);
|
||||
temp.SetCapacity(8);
|
||||
PRUnichar* result=temp.mUStr;
|
||||
temp.mStr=0;
|
||||
temp.mOwnsBuffer=PR_FALSE;
|
||||
nsString temp(*this); //construct nsCString with alloc on heap (which we'll steal in a moment)
|
||||
temp.SetCapacity(8); //force temp to have an allocated buffer, even if this is empty.
|
||||
PRUnichar* result=temp.mUStr; //steal temp's buffer
|
||||
temp.mStr=0; //now clear temp's buffer to prevent deallocation
|
||||
temp.mOwnsBuffer=PR_FALSE; //and return the PRUnichar*
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ public:
|
|||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void Truncate(PRInt32 anIndex=0);
|
||||
void Truncate(PRUint32 anIndex=0);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -400,7 +400,7 @@ public:
|
|||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsCString& operator+=(const nsCString& aString){return Append(aString,aString.mLength);}
|
||||
nsCString& operator+=(const nsCString& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsCString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
nsCString& operator+=(const PRUnichar aChar){return Append(aChar);}
|
||||
nsCString& operator+=(const char aChar){return Append(aChar);}
|
||||
|
@ -413,7 +413,7 @@ public:
|
|||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsCString& Append(const nsCString& aString) {return Append(aString,aString.mLength);}
|
||||
nsCString& Append(const nsCString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -149,7 +149,7 @@ void nsString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
|
|||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void nsString::Truncate(PRInt32 anIndex) {
|
||||
void nsString::Truncate(PRUint32 anIndex) {
|
||||
nsStr::Truncate(*this,anIndex);
|
||||
}
|
||||
|
||||
|
@ -661,23 +661,19 @@ nsString* nsString::ToNewString() const {
|
|||
/**
|
||||
* Creates an ascii clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @update gess 01/04/99
|
||||
* @update gess 02/24/00
|
||||
* @WARNING! Potential i18n issue here, since we're stepping down from 2byte chars to 1byte chars!
|
||||
* @return ptr to new ascii string
|
||||
*/
|
||||
char* nsString::ToNewCString() const {
|
||||
nsCString temp(*this);
|
||||
temp.SetCapacity(8); //ensure that we get an allocated buffer instead of the common empty one.
|
||||
char* result=temp.mStr;
|
||||
temp.mStr=0;
|
||||
temp.mOwnsBuffer=PR_FALSE;
|
||||
|
||||
#ifdef RICKG_DEBUG
|
||||
// fstream& theStream=GetLogStream();
|
||||
// theStream << "tonewcString() " << result << endl;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
nsCString temp(*this); //construct nsCString with alloc on heap (which we'll steal in a moment)
|
||||
temp.SetCapacity(8); //force it to have an allocated buffer, even if this is empty.
|
||||
char* result=temp.mStr; //steal temp's buffer
|
||||
temp.mStr=0; //clear temp's buffer to prevent deallocation
|
||||
return result; //and return the char*
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an UTF8 clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
|
@ -761,26 +757,17 @@ char* nsString::ToNewUTF8String() const {
|
|||
/**
|
||||
* Creates an ascii clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @update gess 01/04/99
|
||||
* @update gess 02/24/00
|
||||
* @return ptr to new ascii string
|
||||
*/
|
||||
PRUnichar* nsString::ToNewUnicode() const {
|
||||
PRUnichar* result=0;
|
||||
if(eOneByte==mCharSize) {
|
||||
nsString temp(mStr);
|
||||
temp.SetCapacity(8);
|
||||
result=temp.mUStr;
|
||||
temp.mStr=0;
|
||||
temp.mOwnsBuffer=PR_FALSE;
|
||||
}
|
||||
else{
|
||||
nsString temp(mUStr);
|
||||
temp.SetCapacity(8);
|
||||
result=temp.mUStr;
|
||||
temp.mStr=0;
|
||||
temp.mOwnsBuffer=PR_FALSE;
|
||||
}
|
||||
return result;
|
||||
|
||||
nsString temp(*this); //construct nsString with alloc on heap (which we'll steal in a moment)
|
||||
temp.SetCapacity(8); //force it to have an allocated buffer, even if this is empty.
|
||||
PRUnichar* result=temp.mUStr; //steal temp's buffer
|
||||
temp.mStr=0; //clear temp's buffer to prevent deallocation
|
||||
temp.mOwnsBuffer=PR_FALSE;
|
||||
return result; //and return the PRUnichar* to the caller
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -141,7 +141,7 @@ public:
|
|||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void Truncate(PRInt32 anIndex=0);
|
||||
void Truncate(PRUint32 anIndex=0);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -443,8 +443,8 @@ public:
|
|||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsString& operator+=(const nsStr& aString){return Append(aString,aString.mLength);}
|
||||
nsString& operator+=(const nsString& aString){return Append(aString,aString.mLength);}
|
||||
nsString& operator+=(const nsStr& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const nsString& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
nsString& operator+=(const char aChar) {
|
||||
return Append((PRUnichar) (unsigned char)aChar);
|
||||
|
@ -461,8 +461,8 @@ public:
|
|||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsString& Append(const nsStr& aString) {return Append(aString,aString.mLength);}
|
||||
nsString& Append(const nsString& aString) {return Append(aString,aString.mLength);}
|
||||
nsString& Append(const nsStr& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& Append(const nsString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -481,7 +481,7 @@ inline void Recycle( PRUnichar* aBuffer) { nsAllocator::Free(aBuffer); }
|
|||
*/
|
||||
inline PRUnichar GetCharAt(const nsStr& aDest,PRUint32 anIndex){
|
||||
if(anIndex<aDest.mLength) {
|
||||
return (eTwoByte==aDest.mCharSize) ? aDest.mUStr[anIndex] : aDest.mStr[anIndex];
|
||||
return (eTwoByte==aDest.mCharSize) ? aDest.mUStr[anIndex] : (PRUnichar)aDest.mStr[anIndex];
|
||||
}//if
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ void nsCString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
|
|||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void nsCString::Truncate(PRInt32 anIndex) {
|
||||
void nsCString::Truncate(PRUint32 anIndex) {
|
||||
nsStr::Truncate(*this,anIndex);
|
||||
}
|
||||
|
||||
|
@ -591,15 +591,15 @@ nsCString* nsCString::ToNewString() const {
|
|||
/**
|
||||
* Creates an ascii clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @update gess 01/04/99
|
||||
* @update gess 02/24/00
|
||||
* @return ptr to new ascii string
|
||||
*/
|
||||
char* nsCString::ToNewCString() const {
|
||||
nsCString temp(*this);
|
||||
temp.SetCapacity(8);
|
||||
char* result=temp.mStr;
|
||||
temp.mStr=0;
|
||||
return result;
|
||||
nsCString temp(*this); //construct nsCString with alloc on heap (which we'll steal in a moment)
|
||||
temp.SetCapacity(8); //force it to have an allocated buffer, even if this is empty.
|
||||
char* result=temp.mStr; //steal temp's buffer
|
||||
temp.mStr=0; //clear temp's buffer to prevent deallocation
|
||||
return result; //and return the char*
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -609,11 +609,11 @@ char* nsCString::ToNewCString() const {
|
|||
* @return ptr to new ascii string
|
||||
*/
|
||||
PRUnichar* nsCString::ToNewUnicode() const {
|
||||
nsString temp(mStr,mLength);
|
||||
temp.SetCapacity(8);
|
||||
PRUnichar* result=temp.mUStr;
|
||||
temp.mStr=0;
|
||||
temp.mOwnsBuffer=PR_FALSE;
|
||||
nsString temp(*this); //construct nsCString with alloc on heap (which we'll steal in a moment)
|
||||
temp.SetCapacity(8); //force temp to have an allocated buffer, even if this is empty.
|
||||
PRUnichar* result=temp.mUStr; //steal temp's buffer
|
||||
temp.mStr=0; //now clear temp's buffer to prevent deallocation
|
||||
temp.mOwnsBuffer=PR_FALSE; //and return the PRUnichar*
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ public:
|
|||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void Truncate(PRInt32 anIndex=0);
|
||||
void Truncate(PRUint32 anIndex=0);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -400,7 +400,7 @@ public:
|
|||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsCString& operator+=(const nsCString& aString){return Append(aString,aString.mLength);}
|
||||
nsCString& operator+=(const nsCString& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsCString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
nsCString& operator+=(const PRUnichar aChar){return Append(aChar);}
|
||||
nsCString& operator+=(const char aChar){return Append(aChar);}
|
||||
|
@ -413,7 +413,7 @@ public:
|
|||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsCString& Append(const nsCString& aString) {return Append(aString,aString.mLength);}
|
||||
nsCString& Append(const nsCString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -149,7 +149,7 @@ void nsString::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const {
|
|||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void nsString::Truncate(PRInt32 anIndex) {
|
||||
void nsString::Truncate(PRUint32 anIndex) {
|
||||
nsStr::Truncate(*this,anIndex);
|
||||
}
|
||||
|
||||
|
@ -661,23 +661,19 @@ nsString* nsString::ToNewString() const {
|
|||
/**
|
||||
* Creates an ascii clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @update gess 01/04/99
|
||||
* @update gess 02/24/00
|
||||
* @WARNING! Potential i18n issue here, since we're stepping down from 2byte chars to 1byte chars!
|
||||
* @return ptr to new ascii string
|
||||
*/
|
||||
char* nsString::ToNewCString() const {
|
||||
nsCString temp(*this);
|
||||
temp.SetCapacity(8); //ensure that we get an allocated buffer instead of the common empty one.
|
||||
char* result=temp.mStr;
|
||||
temp.mStr=0;
|
||||
temp.mOwnsBuffer=PR_FALSE;
|
||||
|
||||
#ifdef RICKG_DEBUG
|
||||
// fstream& theStream=GetLogStream();
|
||||
// theStream << "tonewcString() " << result << endl;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
nsCString temp(*this); //construct nsCString with alloc on heap (which we'll steal in a moment)
|
||||
temp.SetCapacity(8); //force it to have an allocated buffer, even if this is empty.
|
||||
char* result=temp.mStr; //steal temp's buffer
|
||||
temp.mStr=0; //clear temp's buffer to prevent deallocation
|
||||
return result; //and return the char*
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an UTF8 clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
|
@ -761,26 +757,17 @@ char* nsString::ToNewUTF8String() const {
|
|||
/**
|
||||
* Creates an ascii clone of this string
|
||||
* Note that calls to this method should be matched with calls to Recycle().
|
||||
* @update gess 01/04/99
|
||||
* @update gess 02/24/00
|
||||
* @return ptr to new ascii string
|
||||
*/
|
||||
PRUnichar* nsString::ToNewUnicode() const {
|
||||
PRUnichar* result=0;
|
||||
if(eOneByte==mCharSize) {
|
||||
nsString temp(mStr);
|
||||
temp.SetCapacity(8);
|
||||
result=temp.mUStr;
|
||||
temp.mStr=0;
|
||||
temp.mOwnsBuffer=PR_FALSE;
|
||||
}
|
||||
else{
|
||||
nsString temp(mUStr);
|
||||
temp.SetCapacity(8);
|
||||
result=temp.mUStr;
|
||||
temp.mStr=0;
|
||||
temp.mOwnsBuffer=PR_FALSE;
|
||||
}
|
||||
return result;
|
||||
|
||||
nsString temp(*this); //construct nsString with alloc on heap (which we'll steal in a moment)
|
||||
temp.SetCapacity(8); //force it to have an allocated buffer, even if this is empty.
|
||||
PRUnichar* result=temp.mUStr; //steal temp's buffer
|
||||
temp.mStr=0; //clear temp's buffer to prevent deallocation
|
||||
temp.mOwnsBuffer=PR_FALSE;
|
||||
return result; //and return the PRUnichar* to the caller
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -141,7 +141,7 @@ public:
|
|||
* @param anIndex -- new length of string
|
||||
* @return nada
|
||||
*/
|
||||
void Truncate(PRInt32 anIndex=0);
|
||||
void Truncate(PRUint32 anIndex=0);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -443,8 +443,8 @@ public:
|
|||
* @param various...
|
||||
* @return this
|
||||
*/
|
||||
nsString& operator+=(const nsStr& aString){return Append(aString,aString.mLength);}
|
||||
nsString& operator+=(const nsString& aString){return Append(aString,aString.mLength);}
|
||||
nsString& operator+=(const nsStr& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const nsString& aString){return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& operator+=(const char* aCString) {return Append(aCString);}
|
||||
nsString& operator+=(const char aChar) {
|
||||
return Append((PRUnichar) (unsigned char)aChar);
|
||||
|
@ -461,8 +461,8 @@ public:
|
|||
* @param aString is the source to be appended to this
|
||||
* @return number of chars copied
|
||||
*/
|
||||
nsString& Append(const nsStr& aString) {return Append(aString,aString.mLength);}
|
||||
nsString& Append(const nsString& aString) {return Append(aString,aString.mLength);}
|
||||
nsString& Append(const nsStr& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
nsString& Append(const nsString& aString) {return Append(aString,(PRInt32)aString.mLength);}
|
||||
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче