From 5b842bedfd6be7f10b408967a2cc60284c6dc2c3 Mon Sep 17 00:00:00 2001 From: "harishd%netscape.com" Date: Wed, 28 Jul 1999 21:43:11 +0000 Subject: [PATCH] Fixing ToNewUnicode(). Checking in for rickg. approved: cyeh git-svn-id: svn://10.0.0.236/trunk@41489 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/string/obsolete/nsString2.cpp | 20 +++++++++++++++----- mozilla/xpcom/ds/nsString2.cpp | 20 +++++++++++++++----- mozilla/xpcom/string/obsolete/nsString2.cpp | 20 +++++++++++++++----- 3 files changed, 45 insertions(+), 15 deletions(-) diff --git a/mozilla/string/obsolete/nsString2.cpp b/mozilla/string/obsolete/nsString2.cpp index 15a7b39081f..9316e69df7a 100644 --- a/mozilla/string/obsolete/nsString2.cpp +++ b/mozilla/string/obsolete/nsString2.cpp @@ -573,11 +573,21 @@ char* nsString::ToNewCString() const { * @return ptr to new ascii string */ PRUnichar* nsString::ToNewUnicode() const { - nsString temp(mUStr); - temp.SetCapacity(8); - PRUnichar* result=temp.mUStr; - temp.mStr=0; - temp.mOwnsBuffer=PR_FALSE; + 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; } diff --git a/mozilla/xpcom/ds/nsString2.cpp b/mozilla/xpcom/ds/nsString2.cpp index 15a7b39081f..9316e69df7a 100644 --- a/mozilla/xpcom/ds/nsString2.cpp +++ b/mozilla/xpcom/ds/nsString2.cpp @@ -573,11 +573,21 @@ char* nsString::ToNewCString() const { * @return ptr to new ascii string */ PRUnichar* nsString::ToNewUnicode() const { - nsString temp(mUStr); - temp.SetCapacity(8); - PRUnichar* result=temp.mUStr; - temp.mStr=0; - temp.mOwnsBuffer=PR_FALSE; + 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; } diff --git a/mozilla/xpcom/string/obsolete/nsString2.cpp b/mozilla/xpcom/string/obsolete/nsString2.cpp index 15a7b39081f..9316e69df7a 100644 --- a/mozilla/xpcom/string/obsolete/nsString2.cpp +++ b/mozilla/xpcom/string/obsolete/nsString2.cpp @@ -573,11 +573,21 @@ char* nsString::ToNewCString() const { * @return ptr to new ascii string */ PRUnichar* nsString::ToNewUnicode() const { - nsString temp(mUStr); - temp.SetCapacity(8); - PRUnichar* result=temp.mUStr; - temp.mStr=0; - temp.mOwnsBuffer=PR_FALSE; + 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; }