This commit is contained in:
pavlov%netscape.com 2000-04-25 05:40:45 +00:00
Родитель 3252f7edaf
Коммит 03d4675682
18 изменённых файлов: 84 добавлений и 58 удалений

Просмотреть файл

@ -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,

Просмотреть файл

@ -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;i<LocaleListLength;i++) {
char* lc_temp = setlocale(posix_locale_category[i],"");
category = LocaleList[i];
if (lc_temp==nsnull) xpLocale = "en-US";
else xpLocale = lc_temp;
category.AssignWithConversion(LocaleList[i]);
if (lc_temp==nsnull) xpLocale.AssignWithConversion("en-US");
else xpLocale.AssignWithConversion(lc_temp);
PRUnichar* loc = xpLocale.ToNewUnicode();
PRUnichar* cat = category.ToNewUnicode();
resultLocale->AddCategory(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<LocaleListLength;i++) {
char* lc_temp = setlocale(os2_locale_category[i],"");
category = LocaleList[i];
if (lc_temp==nsnull) xpLocale = "en-US";
if (lc_temp==nsnull) xpLocale.AssignWithConversion("en-US");
else xpLocale = lc_temp;
PRUnichar* loc = xpLocale.ToNewUnicode();
PRUnichar* cat = category.ToNewUnicode();

Просмотреть файл

@ -46,7 +46,7 @@ NS_IMPL_ISUPPORTS(nsCollationUnix, kICollationIID);
inline void nsCollationUnix::DoSetLocale()
{
char *locale = setlocale(LC_COLLATE, NULL);
mSavedLocale.SetString(locale ? locale : "");
mSavedLocale.AssignWithConversion(locale ? locale : "");
if (!mSavedLocale.EqualsIgnoreCase(mLocale)) {
char newLocale[128];
(void) setlocale(LC_COLLATE, mLocale.ToCString(newLocale, 128));
@ -87,13 +87,14 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale)
}
// default local charset name
mCharset.SetString("ISO-8859-1");
mCharset.AssignWithConversion("ISO-8859-1");
// default platform locale
mLocale.SetString("C");
mLocale.AssignWithConversion("C");
PRUnichar *aLocaleUnichar = NULL;
nsString aCategory("NSILOCALE_COLLATE");
nsString aCategory;
aCategory.AssignWithConversion("NSILOCALE_COLLATE");
// get locale string, use app default if no locale specified
if (locale == nsnull) {
@ -114,14 +115,14 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale)
// Get platform locale and charset name from locale, if available
if (NS_SUCCEEDED(res)) {
nsString aLocale;
aLocale.SetString(aLocaleUnichar);
aLocale = aLocaleUnichar;
if (NULL != aLocaleUnichar) {
nsAllocator::Free(aLocaleUnichar);
}
// keep the same behavior as 4.x as well as avoiding Linux collation key problem
if (aLocale.EqualsIgnoreCase("en-US")) {
aLocale.SetString("C");
aLocale.AssignWithConversion("C");
}
nsCOMPtr <nsIPosixLocale> 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);
}

Просмотреть файл

@ -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 <nsIPosixLocale> 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;

Просмотреть файл

@ -63,7 +63,7 @@ public:
nsDateTimeFormatUnix() {NS_INIT_REFCNT();
mLocale.SetString("");mAppLocale.SetString("");}
mLocale.AssignWithConversion("");mAppLocale.AssignWithConversion("");}
virtual ~nsDateTimeFormatUnix() {}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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)) {

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<nsIPosixLocale> 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();

Просмотреть файл

@ -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;

Просмотреть файл

@ -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

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<nsIInputStream> dataStream;
nsCOMPtr<nsISupports> 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

Просмотреть файл

@ -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));

Просмотреть файл

@ -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 : "";

Просмотреть файл

@ -563,7 +563,7 @@ void nsDocLoaderImpl::FireOnStartDocumentLoad(nsDocLoaderImpl* aLoadInitiator,
ClearInternalProgress(); // only clear our progress if we are starting a new load....
nsCOMPtr<nsIWebProgressListener> 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<nsIWebProgressListener> 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,

Просмотреть файл

@ -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;