diff --git a/mozilla/configure.in b/mozilla/configure.in index 9d55de162dc..90d894a2c60 100644 --- a/mozilla/configure.in +++ b/mozilla/configure.in @@ -2538,6 +2538,10 @@ dnl make sure that we compile in multi-processor support NS_MT_SUPPORTED=1 AC_DEFINE(NS_MT_SUPPORTED) +MOZ_ARG_ENABLE_BOOL(new-strings, +[ --enable-new-strings blah blah blah], + AC_DEFINE(NEW_STRING_APIS)) + dnl build the tests by default ENABLE_TESTS=1 MOZ_ARG_DISABLE_BOOL(tests, diff --git a/mozilla/intl/locale/src/nsLocaleService.cpp b/mozilla/intl/locale/src/nsLocaleService.cpp index 67ce6b2516f..64a568893b6 100644 --- a/mozilla/intl/locale/src/nsLocaleService.cpp +++ b/mozilla/intl/locale/src/nsLocaleService.cpp @@ -250,7 +250,7 @@ nsLocaleService::nsLocaleService(void) posixConverter->Release(); } else { if (lang==nsnull) { - xpLocale = "en-US"; + xpLocale.AssignWithConversion("en-US"); PRUnichar* loc = xpLocale.ToNewUnicode(); result = NewLocale(loc, &mSystemLocale); nsCRT::free(loc); @@ -265,9 +265,9 @@ nsLocaleService::nsLocaleService(void) if (resultLocale==NULL) { posixConverter->Release(); return; } for(i=0;iAddCategory(cat, loc); @@ -302,7 +302,7 @@ nsLocaleService::nsLocaleService(void) os2Converter->Release(); } else { if (lang==nsnull) { - xpLocale = "en-US"; + xpLocale.AssignWithConversion("en-US"); PRUnichar* loc = xpLocale.ToNewUnicode(); result = NewLocale(loc, &mSystemLocale); nsCRT::free(loc); @@ -318,7 +318,7 @@ nsLocaleService::nsLocaleService(void) for(i=0;i posixLocale = do_GetService(kPosixLocaleFactoryCID, &res); @@ -129,7 +130,7 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale) char platformLocale[kPlatformLocaleLength+1]; res = posixLocale->GetPlatformLocale(&aLocale, platformLocale, kPlatformLocaleLength+1); if (NS_SUCCEEDED(res)) { - mLocale.SetString(platformLocale); + mLocale.AssignWithConversion(platformLocale); } } @@ -138,7 +139,7 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale) PRUnichar* mappedCharset = NULL; res = platformCharset->GetDefaultCharsetForLocale(aLocale.GetUnicode(), &mappedCharset); if (NS_SUCCEEDED(res) && mappedCharset) { - mCharset.SetString(mappedCharset); + mCharset = mappedCharset; nsAllocator::Free(mappedCharset); } } @@ -166,7 +167,7 @@ nsresult nsCollationUnix::GetSortKeyLen(const nsCollationStrength strength, // this may not necessary because collation key length // probably will not change by this normalization - nsAutoString stringNormalized(stringIn); + nsString stringNormalized = stringIn; if (strength != kCollationCaseSensitive) { res = mCollation->NormalizeString(stringNormalized); } @@ -192,7 +193,7 @@ nsresult nsCollationUnix::CreateRawSortKey(const nsCollationStrength strength, { nsresult res = NS_OK; - nsAutoString stringNormalized(stringIn); + nsString stringNormalized = stringIn; if (strength != kCollationCaseSensitive) { res = mCollation->NormalizeString(stringNormalized); } diff --git a/mozilla/intl/locale/src/unix/nsDateTimeFormatUnix.cpp b/mozilla/intl/locale/src/unix/nsDateTimeFormatUnix.cpp index 5efbcc80ba8..1092faf4132 100644 --- a/mozilla/intl/locale/src/unix/nsDateTimeFormatUnix.cpp +++ b/mozilla/intl/locale/src/unix/nsDateTimeFormatUnix.cpp @@ -47,7 +47,8 @@ NS_IMPL_ISUPPORTS(nsDateTimeFormatUnix, kIDateTimeFormatIID); nsresult nsDateTimeFormatUnix::Initialize(nsILocale* locale) { PRUnichar *aLocaleUnichar = NULL; - nsString aCategory("NSILOCALE_TIME"); + nsString aCategory; + aCategory.AssignWithConversion("NSILOCALE_TIME"); nsresult res = NS_OK; // use cached info if match with stored locale @@ -67,7 +68,7 @@ nsresult nsDateTimeFormatUnix::Initialize(nsILocale* locale) } } - mCharset.SetString("ISO-8859-1"); + mCharset.AssignWithConversion("ISO-8859-1"); PL_strncpy(mPlatformLocale, "en_US", kPlatformLocaleLength+1); // get locale name string, use app default if no locale specified @@ -79,7 +80,7 @@ nsresult nsDateTimeFormatUnix::Initialize(nsILocale* locale) if (NS_SUCCEEDED(res)) { res = appLocale->GetCategory(aCategory.GetUnicode(), &aLocaleUnichar); if (NS_SUCCEEDED(res) && NULL != aLocaleUnichar) { - mAppLocale.SetString(aLocaleUnichar); // cache app locale name + mAppLocale = aLocaleUnichar; // cache app locale name } appLocale->Release(); } @@ -90,7 +91,7 @@ nsresult nsDateTimeFormatUnix::Initialize(nsILocale* locale) } if (NS_SUCCEEDED(res) && NULL != aLocaleUnichar) { - mLocale.SetString(aLocaleUnichar); // cache locale name + mLocale = aLocaleUnichar; // cache locale name nsAllocator::Free(aLocaleUnichar); nsCOMPtr posixLocale = do_GetService(kPosixLocaleFactoryCID, &res); @@ -103,7 +104,7 @@ nsresult nsDateTimeFormatUnix::Initialize(nsILocale* locale) PRUnichar* mappedCharset = NULL; res = platformCharset->GetDefaultCharsetForLocale(mLocale.GetUnicode(), &mappedCharset); if (NS_SUCCEEDED(res) && mappedCharset) { - mCharset.SetString(mappedCharset); + mCharset = mappedCharset; nsAllocator::Free(mappedCharset); } } @@ -245,7 +246,7 @@ nsresult nsDateTimeFormatUnix::FormatTMTime(nsILocale* locale, res = decoder->Convert(strOut, &srcLength, unichars, &unicharLength); if (NS_SUCCEEDED(res)) { - stringOut.SetString(unichars, unicharLength); + stringOut.Assign(unichars, unicharLength); } } delete [] unichars; diff --git a/mozilla/intl/locale/src/unix/nsDateTimeFormatUnix.h b/mozilla/intl/locale/src/unix/nsDateTimeFormatUnix.h index 8cacc16644d..63f1261e993 100644 --- a/mozilla/intl/locale/src/unix/nsDateTimeFormatUnix.h +++ b/mozilla/intl/locale/src/unix/nsDateTimeFormatUnix.h @@ -63,7 +63,7 @@ public: nsDateTimeFormatUnix() {NS_INIT_REFCNT(); - mLocale.SetString("");mAppLocale.SetString("");} + mLocale.AssignWithConversion("");mAppLocale.AssignWithConversion("");} virtual ~nsDateTimeFormatUnix() {} diff --git a/mozilla/intl/locale/src/unix/nsPosixLocale.cpp b/mozilla/intl/locale/src/unix/nsPosixLocale.cpp index b81b8f2a2c4..74a09b3d005 100644 --- a/mozilla/intl/locale/src/unix/nsPosixLocale.cpp +++ b/mozilla/intl/locale/src/unix/nsPosixLocale.cpp @@ -95,12 +95,12 @@ nsPosixLocale::GetXPLocale(const char* posixLocale, nsString* locale) if (posixLocale!=nsnull) { if (strcmp(posixLocale,"C")==0 || strcmp(posixLocale,"POSIX")==0) { - *locale = "en-US"; + locale->AssignWithConversion("en-US"); return NS_OK; } if (!ParseLocaleString(posixLocale,lang_code,country_code,extra,'_')) { // * locale = "x-user-defined"; - locale->SetString(posixLocale); // use posix if parse failed + locale->AssignWithConversion(posixLocale); // use posix if parse failed return NS_OK; } @@ -121,7 +121,7 @@ nsPosixLocale::GetXPLocale(const char* posixLocale, nsString* locale) } } - *locale = posix_locale; + locale->AssignWithConversion(posix_locale); return NS_OK; } diff --git a/mozilla/intl/strres/tests/StringBundleTest.cpp b/mozilla/intl/strres/tests/StringBundleTest.cpp index 7944471364a..d721d03148f 100644 --- a/mozilla/intl/strres/tests/StringBundleTest.cpp +++ b/mozilla/intl/strres/tests/StringBundleTest.cpp @@ -105,7 +105,8 @@ get_applocale(void) // locale->AddRef(); - category = new nsString("NSILOCALE_MESSAGES"); + category = new nsString(); + category->AssignWithConversion("NSILOCALE_MESSAGES"); value = new nsString(); result = locale->GetCategory(category->GetUnicode(),&lc_name_unichar); @@ -189,7 +190,8 @@ main(int argc, char *argv[]) return 1; } - nsAutoString v(""); + nsAutoString v; + v.AssignWithConversion(""); PRUnichar *ptrv = nsnull; char *value = nsnull; @@ -204,7 +206,8 @@ main(int argc, char *argv[]) cout << "123=\"" << value << "\"" << endl; // file - nsString strfile("file"); + nsString strfile; + strfile.AssignWithConversion("file"); const PRUnichar *ptrFile = strfile.GetUnicode(); ret = bundle->GetStringFromName(ptrFile, &ptrv); if (NS_FAILED(ret)) { diff --git a/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp b/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp index 63150e8fe64..1c36e55c519 100644 --- a/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp +++ b/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp @@ -456,7 +456,7 @@ nsresult nsCharsetConverterManager::GetBundleValue(nsIStringBundle * aBundle, { nsresult res = NS_OK; - nsAutoString key(*aName); + nsString key(*aName); if (aProp != NULL) key.Append(*aProp); // yes, this parameter may be NULL PRUnichar * value = NULL; @@ -475,7 +475,7 @@ nsresult nsCharsetConverterManager::GetBundleValue(nsIStringBundle * aBundle, { nsresult res = NS_OK; - nsAutoString key(*aName); + nsString key(*aName); if (aProp != NULL) key.Append(*aProp); // yes, this parameter may be NULL PRUnichar * value = NULL; diff --git a/mozilla/intl/uconv/src/nsUNIXCharset.cpp b/mozilla/intl/uconv/src/nsUNIXCharset.cpp index 7d3709bfbfa..24ad3800315 100644 --- a/mozilla/intl/uconv/src/nsUNIXCharset.cpp +++ b/mozilla/intl/uconv/src/nsUNIXCharset.cpp @@ -66,7 +66,8 @@ nsUNIXCharset::nsUNIXCharset() // XXX we should make the following block critical section if(nsnull == gInfo) { - nsAutoString propertyURL("resource:/res/unixcharset.properties"); + nsAutoString propertyURL; + propertyURL.AssignWithConversion("resource:/res/unixcharset.properties"); nsURLProperties *info = new nsURLProperties( propertyURL ); NS_ASSERTION( info, "cannot create nsURLProperties"); gInfo = info; @@ -74,21 +75,23 @@ nsUNIXCharset::nsUNIXCharset() if(gInfo && locale) { - nsAutoString platformLocaleKey("locale." OSTYPE "."); - platformLocaleKey.Append(locale); + nsAutoString platformLocaleKey; + platformLocaleKey.AssignWithConversion("locale." OSTYPE "."); + platformLocaleKey.AppendWithConversion(locale); nsresult res = gInfo->Get(platformLocaleKey, mCharset); if(NS_FAILED(res)) { - nsAutoString localeKey("locale.all."); - localeKey.Append(locale); + nsAutoString localeKey; + localeKey.AssignWithConversion("locale.all."); + localeKey.AppendWithConversion(locale); res = gInfo->Get(localeKey, mCharset); if(NS_SUCCEEDED(res)) { return; // succeeded } } } - mCharset = "ISO-8859-1"; + mCharset.AssignWithConversion("ISO-8859-1"); return; // failed } nsUNIXCharset::~nsUNIXCharset() @@ -112,7 +115,8 @@ NS_IMETHODIMP nsUNIXCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar** _retValue) { nsCOMPtr pPosixLocale; - nsString charset("ISO-8859-1"), localeNameAsString(localeName); + nsString charset, localeNameAsString(localeName); + charset.AssignWithConversion("ISO-8859-1"); char posix_locale[128]; // @@ -133,15 +137,16 @@ nsUNIXCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar if (!gInfo) { *_retValue=charset.ToNewUnicode(); return NS_ERROR_OUT_OF_MEMORY; } - nsAutoString locale_key("locale." OSTYPE "."); - locale_key.Append(posix_locale); + nsAutoString locale_key; + locale_key.AssignWithConversion("locale." OSTYPE "."); + locale_key.AppendWithConversion(posix_locale); rv = gInfo->Get(locale_key,charset); if(NS_FAILED(rv)) { - locale_key="locale.all."; - locale_key.Append(posix_locale); - rv = gInfo->Get(locale_key,charset); - if(NS_FAILED(rv)) { charset="ISO-8859-1";} + locale_key.AssignWithConversion("locale.all."); + locale_key.AppendWithConversion(posix_locale); + rv = gInfo->Get(locale_key,charset); + if(NS_FAILED(rv)) { charset.AssignWithConversion("ISO-8859-1"); } } *_retValue = charset.ToNewUnicode(); diff --git a/mozilla/intl/uconv/src/nsURLProperties.cpp b/mozilla/intl/uconv/src/nsURLProperties.cpp index fc561ef61cd..08f2ce93822 100644 --- a/mozilla/intl/uconv/src/nsURLProperties.cpp +++ b/mozilla/intl/uconv/src/nsURLProperties.cpp @@ -47,7 +47,8 @@ nsURLProperties::nsURLProperties(nsString& aUrl) gRefCnt++; } - nsCAutoString aUrlCString(aUrl); + nsCAutoString aUrlCString; + aUrlCString.AssignWithConversion(aUrl); res = gIOService->NewURI(aUrlCString.GetBuffer(), nsnull, &url); if (NS_FAILED(res)) return; diff --git a/mozilla/intl/unicharutil/tests/UnicharSelfTest.cpp b/mozilla/intl/unicharutil/tests/UnicharSelfTest.cpp index a03aa3719e1..bcd63483704 100644 --- a/mozilla/intl/unicharutil/tests/UnicharSelfTest.cpp +++ b/mozilla/intl/unicharutil/tests/UnicharSelfTest.cpp @@ -371,7 +371,7 @@ static void TestEntityConversion(PRUint32 version) nsresult res; - inString.Assign("\xA0\xA1\xA2\xA3"); + inString.AssignWithConversion("\xA0\xA1\xA2\xA3"); uChar = (PRUnichar) 8364; //euro inString.Append(&uChar, 1); uChar = (PRUnichar) 9830; // @@ -417,7 +417,8 @@ static void TestSaveAsCharset() nsresult res; - nsString inString("\x61\x62\x80\xA0\x63"); + nsString inString; + inString.AssignWithConversion("\x61\x62\x80\xA0\x63"); char *outString; // first, dump input string diff --git a/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp b/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp index 1ecbd58dd5d..c93f2ea99c2 100644 --- a/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp +++ b/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp @@ -878,7 +878,8 @@ nsFTPDirListingConv::DigestBufferLines(char *aBuffer, nsCAutoString &aString) { return nsnull; } - nsCAutoString theDate(lDate); + nsCAutoString theDate; + theDate.AssignWithConversion(lDate); char *escapedDate = nsEscape(theDate.GetBuffer(), url_Path); aString.Append(escapedDate); diff --git a/mozilla/netwerk/streamconv/test/Converters.cpp b/mozilla/netwerk/streamconv/test/Converters.cpp index 8bd07b594ad..7fb2ecfa455 100644 --- a/mozilla/netwerk/streamconv/test/Converters.cpp +++ b/mozilla/netwerk/streamconv/test/Converters.cpp @@ -34,7 +34,8 @@ TestConverter::Convert(nsIInputStream *aFromStream, for (PRUint32 i = 0; i < read; i++) buf[i] = toChar; - nsString convDataStr(buf); + nsString convDataStr; + convDataStr.AssignWithConversion(buf); nsIInputStream *inputData = nsnull; nsISupports *inputDataSup = nsnull; diff --git a/mozilla/netwerk/streamconv/test/TestStreamConv.cpp b/mozilla/netwerk/streamconv/test/TestStreamConv.cpp index ac7e7d88e15..a56a636f2d0 100644 --- a/mozilla/netwerk/streamconv/test/TestStreamConv.cpp +++ b/mozilla/netwerk/streamconv/test/TestStreamConv.cpp @@ -120,7 +120,8 @@ NS_IMPL_ISUPPORTS(EndListener, NS_GET_IID(nsIStreamListener)); nsresult SendData(const char * aData, nsIStreamListener* aListener, nsIChannel* aChannel) { - nsString data = aData; + nsString data; + data.AssignWithConversion(aData); nsCOMPtr dataStream; nsCOMPtr sup; nsresult rv = NS_NewStringInputStream(getter_AddRefs(sup), data); @@ -257,8 +258,11 @@ main(int argc, char* argv[]) NS_WITH_SERVICE(nsIStreamConverterService, StreamConvService, kStreamConverterServiceCID, &rv); if (NS_FAILED(rv)) return rv; - nsString fromStr("multipart/x-mixed-replace"); - nsString toStr ("text/html"); + nsString fromStr; + fromStr.AssignWithConversion("multipart/x-mixed-replace"); + nsString toStr; + toStr.AssignWithConversion("text/html"); + #ifdef ASYNC_TEST // ASYNCRONOUS conversion diff --git a/mozilla/netwerk/test/TestProtocols.cpp b/mozilla/netwerk/test/TestProtocols.cpp index fb12dab90c6..a042d9187f4 100644 --- a/mozilla/netwerk/test/TestProtocols.cpp +++ b/mozilla/netwerk/test/TestProtocols.cpp @@ -164,7 +164,8 @@ TestHTTPEventSink::OnHeadersAvailable(nsISupports* context) nsAutoString field; header->GetField(getter_AddRefs(key)); key->ToString(field); - nsCAutoString theField(field); + nsCAutoString theField; + theField.AssignWithConversion(field); printf("\t%s: ", theField.GetBuffer()); header->GetValue(getter_Copies(value)); @@ -191,7 +192,8 @@ TestHTTPEventSink::OnHeadersAvailable(nsISupports* context) header->GetField(getter_AddRefs(key)); key->ToString(field); - nsCAutoString theField(field); + nsCAutoString theField; + theField.AssignWithConversion(field); printf("\t%s: ", theField.GetBuffer()); header->GetValue(getter_Copies(value)); diff --git a/mozilla/netwerk/test/urltest.cpp b/mozilla/netwerk/test/urltest.cpp index e4e84982849..45c842de400 100644 --- a/mozilla/netwerk/test/urltest.cpp +++ b/mozilla/netwerk/test/urltest.cpp @@ -94,7 +94,7 @@ int writeoutto(const char* i_pURL, char** o_Result, PRBool bUseStd = PR_TRUE) output += temp ? (const char*)temp : ""; output += ','; tURL->GetPort(&port); - output += port; + output.AppendInt(port); output += ','; tURL->GetQuery(getter_Copies(temp)); output += temp ? (const char*)temp : ""; diff --git a/mozilla/uriloader/base/nsDocLoader.cpp b/mozilla/uriloader/base/nsDocLoader.cpp index 3f2c5d31b78..ee46dce5fcb 100644 --- a/mozilla/uriloader/base/nsDocLoader.cpp +++ b/mozilla/uriloader/base/nsDocLoader.cpp @@ -563,7 +563,7 @@ void nsDocLoaderImpl::FireOnStartDocumentLoad(nsDocLoaderImpl* aLoadInitiator, ClearInternalProgress(); // only clear our progress if we are starting a new load.... nsCOMPtr parentProgressListener; GetParentWebProgressListener(this, getter_AddRefs(parentProgressListener)); - if (parentProgressListener && parentProgressListener != mProgressListener) + if (parentProgressListener && parentProgressListener.get() != mProgressListener.get()) { #if defined(DEBUG) PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, @@ -637,7 +637,7 @@ void nsDocLoaderImpl::FireOnEndDocumentLoad(nsDocLoaderImpl* aLoadInitiator, { nsCOMPtr parentProgressListener; GetParentWebProgressListener(this, getter_AddRefs(parentProgressListener)); - if (parentProgressListener && parentProgressListener != mProgressListener) + if (parentProgressListener && (parentProgressListener.get() != mProgressListener.get())) { #if defined(DEBUG) PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, diff --git a/mozilla/xpcom/components/nsCategoryManager.cpp b/mozilla/xpcom/components/nsCategoryManager.cpp index e292847b5e7..5088d58ac58 100644 --- a/mozilla/xpcom/components/nsCategoryManager.cpp +++ b/mozilla/xpcom/components/nsCategoryManager.cpp @@ -59,7 +59,9 @@ ExtractKeyString( nsHashKey* key, void*, void*, nsISupports** _retval ) // BULLSHIT ALERT: use |nsCAutoString| to deflate to single-byte until I can add, e.g., // |nsCStringKey| to hashtable const nsString& s = NS_STATIC_CAST(nsStringKey*, key)->GetString(); - status = obj->SetDataWithLength(s.Length(), nsCAutoString(s)); + nsCAutoString tmpStr; + tmpStr.AssignWithConversion(s); + status = obj->SetDataWithLength(tmpStr.Length(), tmpStr); } *_retval = obj;