diff --git a/mozilla/string/obsolete/nsString.cpp b/mozilla/string/obsolete/nsString.cpp index 5ff611de647..78e901c9589 100644 --- a/mozilla/string/obsolete/nsString.cpp +++ b/mozilla/string/obsolete/nsString.cpp @@ -1881,6 +1881,12 @@ nsCAutoString::nsCAutoString( const nsCString& aString ) : nsCString(){ } +nsCAutoString::nsCAutoString(const char* aCString) : nsCString() { + Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); + AddNullTerminator(*this); + Append(aCString); +} + /** * Copy construct from ascii c-string * @param aCString is a ptr to a 1-byte cstr diff --git a/mozilla/string/obsolete/nsString.h b/mozilla/string/obsolete/nsString.h index 7752c072204..34a9f2fa788 100644 --- a/mozilla/string/obsolete/nsString.h +++ b/mozilla/string/obsolete/nsString.h @@ -815,7 +815,8 @@ public: nsCAutoString(); nsCAutoString(const nsCString& ); - nsCAutoString(const char* aString,PRInt32 aLength=-1); + nsCAutoString(const char* aString); + nsCAutoString(const char* aString,PRInt32 aLength); nsCAutoString(const CBufDescriptor& aBuffer); #ifndef NEW_STRING_APIS diff --git a/mozilla/string/obsolete/nsString2.cpp b/mozilla/string/obsolete/nsString2.cpp index 74b69994554..ec2550ee8cd 100644 --- a/mozilla/string/obsolete/nsString2.cpp +++ b/mozilla/string/obsolete/nsString2.cpp @@ -2281,6 +2281,12 @@ nsAutoString::nsAutoString() : nsString() { AddNullTerminator(*this); } +nsAutoString::nsAutoString(const PRUnichar* aString) : nsString() { + Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + AddNullTerminator(*this); + Append(aString); +} + /** * Copy construct from uni-string * @param aString is a ptr to a unistr diff --git a/mozilla/string/obsolete/nsString2.h b/mozilla/string/obsolete/nsString2.h index 15b7e27379d..4ff21f6c9e8 100644 --- a/mozilla/string/obsolete/nsString2.h +++ b/mozilla/string/obsolete/nsString2.h @@ -908,7 +908,8 @@ public: nsAutoString(); nsAutoString(const nsAutoString& aString); nsAutoString(const nsString& aString); - nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1); + nsAutoString(const PRUnichar* aString); + nsAutoString(const PRUnichar* aString,PRInt32 aLength); nsAutoString(PRUnichar aChar); nsAutoString(const CBufDescriptor& aBuffer); diff --git a/mozilla/string/public/nsAReadableString.h b/mozilla/string/public/nsAReadableString.h index 83cceeabcf8..510623aff25 100644 --- a/mozilla/string/public/nsAReadableString.h +++ b/mozilla/string/public/nsAReadableString.h @@ -656,7 +656,7 @@ class basic_nsLiteralString if ( aLength == PRUint32(-1) ) { // NS_WARNING("Tell scc: Caller constructing a string doesn't know the real length. Please use the other constructor."); - mEnd = mStart + nsCharTraits::length(mStart); + mEnd = mStart ? (mStart + nsCharTraits::length(mStart)) : mStart; } } @@ -1093,7 +1093,7 @@ copy_string_backward( InputIterator first, InputIterator last, OutputIterator re NS_ASSERTION(lengthToCopy, "|copy_string_backward| will never terminate"); - nsCharTraits::move(result.operator->()-lengthToCopy, last.operator->()-lengthToCopy, lengthToCopy); + nsCharTraits::move(result.operator->()-lengthToCopy, last.operator->()-lengthToCopy, lengthToCopy); last -= PRInt32(lengthToCopy); result -= PRInt32(lengthToCopy); diff --git a/mozilla/xpcom/ds/nsAReadableString.h b/mozilla/xpcom/ds/nsAReadableString.h index 83cceeabcf8..510623aff25 100644 --- a/mozilla/xpcom/ds/nsAReadableString.h +++ b/mozilla/xpcom/ds/nsAReadableString.h @@ -656,7 +656,7 @@ class basic_nsLiteralString if ( aLength == PRUint32(-1) ) { // NS_WARNING("Tell scc: Caller constructing a string doesn't know the real length. Please use the other constructor."); - mEnd = mStart + nsCharTraits::length(mStart); + mEnd = mStart ? (mStart + nsCharTraits::length(mStart)) : mStart; } } @@ -1093,7 +1093,7 @@ copy_string_backward( InputIterator first, InputIterator last, OutputIterator re NS_ASSERTION(lengthToCopy, "|copy_string_backward| will never terminate"); - nsCharTraits::move(result.operator->()-lengthToCopy, last.operator->()-lengthToCopy, lengthToCopy); + nsCharTraits::move(result.operator->()-lengthToCopy, last.operator->()-lengthToCopy, lengthToCopy); last -= PRInt32(lengthToCopy); result -= PRInt32(lengthToCopy); diff --git a/mozilla/xpcom/ds/nsString.cpp b/mozilla/xpcom/ds/nsString.cpp index 5ff611de647..78e901c9589 100644 --- a/mozilla/xpcom/ds/nsString.cpp +++ b/mozilla/xpcom/ds/nsString.cpp @@ -1881,6 +1881,12 @@ nsCAutoString::nsCAutoString( const nsCString& aString ) : nsCString(){ } +nsCAutoString::nsCAutoString(const char* aCString) : nsCString() { + Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); + AddNullTerminator(*this); + Append(aCString); +} + /** * Copy construct from ascii c-string * @param aCString is a ptr to a 1-byte cstr diff --git a/mozilla/xpcom/ds/nsString.h b/mozilla/xpcom/ds/nsString.h index 7752c072204..34a9f2fa788 100644 --- a/mozilla/xpcom/ds/nsString.h +++ b/mozilla/xpcom/ds/nsString.h @@ -815,7 +815,8 @@ public: nsCAutoString(); nsCAutoString(const nsCString& ); - nsCAutoString(const char* aString,PRInt32 aLength=-1); + nsCAutoString(const char* aString); + nsCAutoString(const char* aString,PRInt32 aLength); nsCAutoString(const CBufDescriptor& aBuffer); #ifndef NEW_STRING_APIS diff --git a/mozilla/xpcom/ds/nsString2.cpp b/mozilla/xpcom/ds/nsString2.cpp index 74b69994554..ec2550ee8cd 100644 --- a/mozilla/xpcom/ds/nsString2.cpp +++ b/mozilla/xpcom/ds/nsString2.cpp @@ -2281,6 +2281,12 @@ nsAutoString::nsAutoString() : nsString() { AddNullTerminator(*this); } +nsAutoString::nsAutoString(const PRUnichar* aString) : nsString() { + Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + AddNullTerminator(*this); + Append(aString); +} + /** * Copy construct from uni-string * @param aString is a ptr to a unistr diff --git a/mozilla/xpcom/ds/nsString2.h b/mozilla/xpcom/ds/nsString2.h index 15b7e27379d..4ff21f6c9e8 100644 --- a/mozilla/xpcom/ds/nsString2.h +++ b/mozilla/xpcom/ds/nsString2.h @@ -908,7 +908,8 @@ public: nsAutoString(); nsAutoString(const nsAutoString& aString); nsAutoString(const nsString& aString); - nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1); + nsAutoString(const PRUnichar* aString); + nsAutoString(const PRUnichar* aString,PRInt32 aLength); nsAutoString(PRUnichar aChar); nsAutoString(const CBufDescriptor& aBuffer); diff --git a/mozilla/xpcom/string/obsolete/nsString.cpp b/mozilla/xpcom/string/obsolete/nsString.cpp index 5ff611de647..78e901c9589 100644 --- a/mozilla/xpcom/string/obsolete/nsString.cpp +++ b/mozilla/xpcom/string/obsolete/nsString.cpp @@ -1881,6 +1881,12 @@ nsCAutoString::nsCAutoString( const nsCString& aString ) : nsCString(){ } +nsCAutoString::nsCAutoString(const char* aCString) : nsCString() { + Initialize(*this,mBuffer,sizeof(mBuffer)-1,0,eOneByte,PR_FALSE); + AddNullTerminator(*this); + Append(aCString); +} + /** * Copy construct from ascii c-string * @param aCString is a ptr to a 1-byte cstr diff --git a/mozilla/xpcom/string/obsolete/nsString.h b/mozilla/xpcom/string/obsolete/nsString.h index 7752c072204..34a9f2fa788 100644 --- a/mozilla/xpcom/string/obsolete/nsString.h +++ b/mozilla/xpcom/string/obsolete/nsString.h @@ -815,7 +815,8 @@ public: nsCAutoString(); nsCAutoString(const nsCString& ); - nsCAutoString(const char* aString,PRInt32 aLength=-1); + nsCAutoString(const char* aString); + nsCAutoString(const char* aString,PRInt32 aLength); nsCAutoString(const CBufDescriptor& aBuffer); #ifndef NEW_STRING_APIS diff --git a/mozilla/xpcom/string/obsolete/nsString2.cpp b/mozilla/xpcom/string/obsolete/nsString2.cpp index 74b69994554..ec2550ee8cd 100644 --- a/mozilla/xpcom/string/obsolete/nsString2.cpp +++ b/mozilla/xpcom/string/obsolete/nsString2.cpp @@ -2281,6 +2281,12 @@ nsAutoString::nsAutoString() : nsString() { AddNullTerminator(*this); } +nsAutoString::nsAutoString(const PRUnichar* aString) : nsString() { + Initialize(*this,mBuffer,(sizeof(mBuffer)>>eTwoByte)-1,0,eTwoByte,PR_FALSE); + AddNullTerminator(*this); + Append(aString); +} + /** * Copy construct from uni-string * @param aString is a ptr to a unistr diff --git a/mozilla/xpcom/string/obsolete/nsString2.h b/mozilla/xpcom/string/obsolete/nsString2.h index 15b7e27379d..4ff21f6c9e8 100644 --- a/mozilla/xpcom/string/obsolete/nsString2.h +++ b/mozilla/xpcom/string/obsolete/nsString2.h @@ -908,7 +908,8 @@ public: nsAutoString(); nsAutoString(const nsAutoString& aString); nsAutoString(const nsString& aString); - nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1); + nsAutoString(const PRUnichar* aString); + nsAutoString(const PRUnichar* aString,PRInt32 aLength); nsAutoString(PRUnichar aChar); nsAutoString(const CBufDescriptor& aBuffer); diff --git a/mozilla/xpcom/string/public/nsAReadableString.h b/mozilla/xpcom/string/public/nsAReadableString.h index 83cceeabcf8..510623aff25 100644 --- a/mozilla/xpcom/string/public/nsAReadableString.h +++ b/mozilla/xpcom/string/public/nsAReadableString.h @@ -656,7 +656,7 @@ class basic_nsLiteralString if ( aLength == PRUint32(-1) ) { // NS_WARNING("Tell scc: Caller constructing a string doesn't know the real length. Please use the other constructor."); - mEnd = mStart + nsCharTraits::length(mStart); + mEnd = mStart ? (mStart + nsCharTraits::length(mStart)) : mStart; } } @@ -1093,7 +1093,7 @@ copy_string_backward( InputIterator first, InputIterator last, OutputIterator re NS_ASSERTION(lengthToCopy, "|copy_string_backward| will never terminate"); - nsCharTraits::move(result.operator->()-lengthToCopy, last.operator->()-lengthToCopy, lengthToCopy); + nsCharTraits::move(result.operator->()-lengthToCopy, last.operator->()-lengthToCopy, lengthToCopy); last -= PRInt32(lengthToCopy); result -= PRInt32(lengthToCopy);