Bug 791546: Removes nsCRT::strcmp(const PRUnichar* s) from nsCRT.h and replaces it occurrences with NS_strcmp; r=bsmedberg

This commit is contained in:
Shriram Kunchanapalli 2012-12-24 08:47:18 +05:30
parent 7e58a50c01
commit 25d2ca6bd4
17 changed files with 30 additions and 54 deletions

View File

@ -11572,8 +11572,8 @@ nsDocShell::Observe(nsISupports *aSubject, const char *aTopic,
{
nsresult rv = NS_OK;
if (mObserveErrorPages &&
!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) &&
!nsCRT::strcmp(aData,
!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) && aData &&
!NS_strcmp(aData,
NS_LITERAL_STRING("browser.xul.error_pages.enabled").get())) {
bool tmpbool;

View File

@ -218,8 +218,8 @@ nsDOMStorageManager::Observe(nsISupports *aSubject,
const PRUnichar *aData)
{
if (!strcmp(aTopic, "profile-after-change")) {
} else if (!strcmp(aTopic, "cookie-changed") &&
!nsCRT::strcmp(aData, NS_LITERAL_STRING("cleared").get())) {
} else if (!strcmp(aTopic, "cookie-changed") && aData &&
!NS_strcmp(aData, NS_LITERAL_STRING("cleared").get())) {
mStorages.EnumerateEntries(ClearStorage, nullptr);
nsresult rv = DOMStorageImpl::InitDB();

View File

@ -67,7 +67,7 @@ ChangeCSSInlineStyleTxn::ValueIncludes(const nsAString &aValueList, const nsAStr
if (start < end) {
if (aCaseSensitive) {
if (!nsCRT::strcmp(value, start)) {
if (value && !NS_strcmp(value, start)) {
result = true;
break;
}

View File

@ -1106,7 +1106,7 @@ NS_IMETHODIMP nsPermissionManager::Observe(nsISupports *aSubject, const char *aT
// The profile is about to change,
// or is going away because the application is shutting down.
mIsShuttingDown = true;
if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
if (someData && !NS_strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
// Clear the permissions file and close the db asynchronously
RemoveAllInternal(false);
} else {

View File

@ -98,7 +98,16 @@ nsLocale::Hash_HashFunction(const void* key)
int
nsLocale::Hash_CompareNSString(const void* s1, const void* s2)
{
return !nsCRT::strcmp((const PRUnichar *) s1, (const PRUnichar *) s2);
if (s1 && s2) {
return !NS_strcmp((const PRUnichar *) s1, (const PRUnichar *) s2);
}
if (s1) { //s2 must have been null
return -1;
}
if (s2) { //s1 must have been null
return 1;
}
return 0;
}

View File

@ -392,7 +392,7 @@ Preferences::Observe(nsISupports *aSubject, const char *aTopic,
nsresult rv = NS_OK;
if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
if (someData && !NS_strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
if (mCurrentFile) {
mCurrentFile->Remove(false);
mCurrentFile = nullptr;

View File

@ -1442,8 +1442,8 @@ nsCookieService::Observe(nsISupports *aSubject,
if (!strcmp(aTopic, "profile-before-change")) {
// The profile is about to change,
// or is going away because the application is shutting down.
if (mDBState && mDBState->dbConn &&
!nsCRT::strcmp(aData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
if (mDBState && mDBState->dbConn && aData &&
!NS_strcmp(aData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
// Clear the cookie db if we're in the default DBState.
RemoveAll();
}

View File

@ -41,7 +41,7 @@ StrEquivalent(const PRUnichar *a, const PRUnichar *b)
if (!b)
b = emptyStr;
return nsCRT::strcmp(a, b) == 0;
return NS_strcmp(a, b) == 0;
}
//-----------------------------------------------------------------------------

View File

@ -768,7 +768,7 @@ nsHttpChannelAuthProvider::GetCredentialsForChallenge(const char *challenge,
}
}
else if (!identFromURI ||
(nsCRT::strcmp(ident->User(),
(NS_strcmp(ident->User(),
entry->Identity().User()) == 0 &&
!(loadFlags &
(nsIChannel::LOAD_ANONYMOUS |
@ -1350,7 +1350,7 @@ nsHttpChannelAuthProvider::SetAuthorizationHeader(nsHttpAuthCache *authCache,
// up the one from the auth cache instead.
// when this is undesired, specify LOAD_EXPLICIT_CREDENTIALS load
// flag.
if (nsCRT::strcmp(ident.User(), entry->User()) == 0) {
if (NS_strcmp(ident.User(), entry->User()) == 0) {
uint32_t loadFlags;
if (NS_SUCCEEDED(mAuthChannel->GetLoadFlags(&loadFlags)) &&
!(loadFlags && nsIChannel::LOAD_EXPLICIT_CREDENTIALS)) {

View File

@ -305,7 +305,7 @@ HTMLTagsKeyCompareUCPtr(const void *key1, const void *key2)
const PRUnichar *str1 = (const PRUnichar *)key1;
const PRUnichar *str2 = (const PRUnichar *)key2;
return nsCRT::strcmp(str1, str2) == 0;
return str1 && str2 && NS_strcmp(str1, str2) == 0;
}
// nsIAtom* -> id hash
@ -476,7 +476,7 @@ nsHTMLTags::TestTagTable()
id = LookupTag(nsDependentString(tag));
NS_ASSERTION(id != eHTMLTag_userdefined, "can't find tag id");
const PRUnichar* check = GetStringValue(id);
NS_ASSERTION(0 == nsCRT::strcmp(check, tag), "can't map id back to tag");
NS_ASSERTION(0 == NS_strcmp(check, tag), "can't map id back to tag");
nsAutoString uname(tag);
ToUpperCase(uname);

View File

@ -173,8 +173,7 @@ struct LiteralHashEntry : public PLDHashEntryHdr {
const LiteralHashEntry *entry =
static_cast<const LiteralHashEntry *>(hdr);
return 0 == nsCRT::strcmp(static_cast<const PRUnichar *>(key),
entry->mKey);
return 0 == NS_strcmp(static_cast<const PRUnichar *>(key), entry->mKey);
}
};

View File

@ -146,7 +146,7 @@ nsCertOverrideService::Observe(nsISupports *,
ReentrantMonitorAutoEnter lock(monitor);
if (!nsCRT::strcmp(aData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
if (aData && !NS_strcmp(aData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
RemoveAllFromMemory();
// delete the storage file
if (mSettingsFile) {

View File

@ -856,7 +856,7 @@ nsFileView::FilterFiles()
if (!isHidden) {
for (uint32_t j = 0; j < filterCount; ++j) {
bool matched = false;
if (!nsCRT::strcmp(mCurrentFilters.ElementAt(j),
if (!NS_strcmp(mCurrentFilters.ElementAt(j),
NS_LITERAL_STRING("..apps").get()))
{
file->IsExecutable(&matched);

View File

@ -72,36 +72,6 @@ char* nsCRT::strtok(char* string, const char* delims, char* *newStr)
////////////////////////////////////////////////////////////////////////////////
/**
* Compare unichar string ptrs, stopping at the 1st null
* NOTE: If both are null, we return 0.
* NOTE: We terminate the search upon encountering a NULL
*
* @update gess 11/10/99
* @param s1 and s2 both point to unichar strings
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
*/
int32_t nsCRT::strcmp(const PRUnichar* s1, const PRUnichar* s2) {
if(s1 && s2) {
for (;;) {
PRUnichar c1 = *s1++;
PRUnichar c2 = *s2++;
if (c1 != c2) {
if (c1 < c2) return -1;
return 1;
}
if ((0==c1) || (0==c2)) break;
}
}
else {
if (s1) // s2 must have been null
return -1;
if (s2) // s1 must have been null
return 1;
}
return 0;
}
/**
* Compare unichar string ptrs, stopping at the 1st null or nth char.
* NOTE: If either is null, we return 0.

View File

@ -135,8 +135,6 @@ public:
*/
static char* strtok(char* str, const char* delims, char* *newStr);
/// Like strcmp except for ucs2 strings
static int32_t strcmp(const PRUnichar* s1, const PRUnichar* s2);
/// Like strcmp except for ucs2 strings
static int32_t strncmp(const PRUnichar* s1, const PRUnichar* s2,
uint32_t aMaxLen);

View File

@ -224,7 +224,7 @@ nsLocalFile::GetRelativeDescriptor(nsIFile *fromFile, nsACString& _retval)
if (_wcsicmp(thisNodes[nodeIndex], fromNodes[nodeIndex]))
break;
#else
if (nsCRT::strcmp(thisNodes[nodeIndex], fromNodes[nodeIndex]))
if (NS_strcmp(thisNodes[nodeIndex], fromNodes[nodeIndex]))
break;
#endif
}

View File

@ -46,9 +46,9 @@ static void Check(const char* s1, const char* s2, int n)
const PRUnichar* us2 = t2.get();
#ifdef DEBUG
int u2 =
int u2 = us1 && us2 &&
#endif
nsCRT::strcmp(us1, us2);
NS_strcmp(us1, us2);
#ifdef DEBUG
int u2_n =