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 48f7625971
commit ff3af78fae
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; nsresult rv = NS_OK;
if (mObserveErrorPages && if (mObserveErrorPages &&
!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) && !nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) && aData &&
!nsCRT::strcmp(aData, !NS_strcmp(aData,
NS_LITERAL_STRING("browser.xul.error_pages.enabled").get())) { NS_LITERAL_STRING("browser.xul.error_pages.enabled").get())) {
bool tmpbool; bool tmpbool;

View File

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

View File

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

View File

@@ -1106,7 +1106,7 @@ NS_IMETHODIMP nsPermissionManager::Observe(nsISupports *aSubject, const char *aT
// The profile is about to change, // The profile is about to change,
// or is going away because the application is shutting down. // or is going away because the application is shutting down.
mIsShuttingDown = true; 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 // Clear the permissions file and close the db asynchronously
RemoveAllInternal(false); RemoveAllInternal(false);
} else { } else {

View File

@@ -98,7 +98,16 @@ nsLocale::Hash_HashFunction(const void* key)
int int
nsLocale::Hash_CompareNSString(const void* s1, const void* s2) 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; nsresult rv = NS_OK;
if (!nsCRT::strcmp(aTopic, "profile-before-change")) { 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) { if (mCurrentFile) {
mCurrentFile->Remove(false); mCurrentFile->Remove(false);
mCurrentFile = nullptr; mCurrentFile = nullptr;

View File

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

View File

@@ -41,7 +41,7 @@ StrEquivalent(const PRUnichar *a, const PRUnichar *b)
if (!b) if (!b)
b = emptyStr; 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 || else if (!identFromURI ||
(nsCRT::strcmp(ident->User(), (NS_strcmp(ident->User(),
entry->Identity().User()) == 0 && entry->Identity().User()) == 0 &&
!(loadFlags & !(loadFlags &
(nsIChannel::LOAD_ANONYMOUS | (nsIChannel::LOAD_ANONYMOUS |
@@ -1350,7 +1350,7 @@ nsHttpChannelAuthProvider::SetAuthorizationHeader(nsHttpAuthCache *authCache,
// up the one from the auth cache instead. // up the one from the auth cache instead.
// when this is undesired, specify LOAD_EXPLICIT_CREDENTIALS load // when this is undesired, specify LOAD_EXPLICIT_CREDENTIALS load
// flag. // flag.
if (nsCRT::strcmp(ident.User(), entry->User()) == 0) { if (NS_strcmp(ident.User(), entry->User()) == 0) {
uint32_t loadFlags; uint32_t loadFlags;
if (NS_SUCCEEDED(mAuthChannel->GetLoadFlags(&loadFlags)) && if (NS_SUCCEEDED(mAuthChannel->GetLoadFlags(&loadFlags)) &&
!(loadFlags && nsIChannel::LOAD_EXPLICIT_CREDENTIALS)) { !(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 *str1 = (const PRUnichar *)key1;
const PRUnichar *str2 = (const PRUnichar *)key2; const PRUnichar *str2 = (const PRUnichar *)key2;
return nsCRT::strcmp(str1, str2) == 0; return str1 && str2 && NS_strcmp(str1, str2) == 0;
} }
// nsIAtom* -> id hash // nsIAtom* -> id hash
@@ -476,7 +476,7 @@ nsHTMLTags::TestTagTable()
id = LookupTag(nsDependentString(tag)); id = LookupTag(nsDependentString(tag));
NS_ASSERTION(id != eHTMLTag_userdefined, "can't find tag id"); NS_ASSERTION(id != eHTMLTag_userdefined, "can't find tag id");
const PRUnichar* check = GetStringValue(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); nsAutoString uname(tag);
ToUpperCase(uname); ToUpperCase(uname);

View File

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

View File

@@ -146,7 +146,7 @@ nsCertOverrideService::Observe(nsISupports *,
ReentrantMonitorAutoEnter lock(monitor); 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(); RemoveAllFromMemory();
// delete the storage file // delete the storage file
if (mSettingsFile) { if (mSettingsFile) {

View File

@@ -856,7 +856,7 @@ nsFileView::FilterFiles()
if (!isHidden) { if (!isHidden) {
for (uint32_t j = 0; j < filterCount; ++j) { for (uint32_t j = 0; j < filterCount; ++j) {
bool matched = false; bool matched = false;
if (!nsCRT::strcmp(mCurrentFilters.ElementAt(j), if (!NS_strcmp(mCurrentFilters.ElementAt(j),
NS_LITERAL_STRING("..apps").get())) NS_LITERAL_STRING("..apps").get()))
{ {
file->IsExecutable(&matched); 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. * Compare unichar string ptrs, stopping at the 1st null or nth char.
* NOTE: If either is null, we return 0. * 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); 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 /// Like strcmp except for ucs2 strings
static int32_t strncmp(const PRUnichar* s1, const PRUnichar* s2, static int32_t strncmp(const PRUnichar* s1, const PRUnichar* s2,
uint32_t aMaxLen); uint32_t aMaxLen);

View File

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

View File

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