Backed out changeset 66a7359f9be2 (bug 791546) because it broke the build
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 03 Jan 2013 18:36:16 -0500
changeset 126631 652b044f22d6e0722673c929c85842c8acb4c677
parent 126630 3553adfc7a6c9bbde2346c290870cb6c0031a8a2
child 126632 b33bd9f6bd697bdc8d69d3bf19c3e8af4667ad6f
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs791546
milestone20.0a1
backs out66a7359f9be20cd36b9743501e173d1a193b2205
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 66a7359f9be2 (bug 791546) because it broke the build
docshell/base/nsDocShell.cpp
dom/src/storage/nsDOMStorage.cpp
editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp
extensions/cookie/nsPermissionManager.cpp
intl/locale/src/nsLocale.cpp
modules/libpref/src/Preferences.cpp
netwerk/cookie/nsCookieService.cpp
netwerk/protocol/http/nsHttpAuthCache.cpp
netwerk/protocol/http/nsHttpChannelAuthProvider.cpp
parser/htmlparser/src/nsHTMLTags.cpp
rdf/base/src/nsRDFService.cpp
security/manager/ssl/src/nsCertOverrideService.cpp
toolkit/components/filepicker/nsFileView.cpp
xpcom/ds/nsCRT.cpp
xpcom/ds/nsCRT.h
xpcom/io/nsLocalFileCommon.cpp
xpcom/tests/TestCRT.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -11544,18 +11544,18 @@ nsDocShell::GetAuthPrompt(uint32_t aProm
 //*****************************************************************************
 
 NS_IMETHODIMP
 nsDocShell::Observe(nsISupports *aSubject, const char *aTopic,
                     const PRUnichar *aData)
 {
     nsresult rv = NS_OK;
     if (mObserveErrorPages &&
-        !nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) && aData &&
-        !NS_strcmp(aData,
+        !nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) &&
+        !nsCRT::strcmp(aData,
           NS_LITERAL_STRING("browser.xul.error_pages.enabled").get())) {
 
         bool tmpbool;
         rv = Preferences::GetBool("browser.xul.error_pages.enabled", &tmpbool);
         if (NS_SUCCEEDED(rv))
             mUseErrorPages = tmpbool;
 
     } else {
--- a/dom/src/storage/nsDOMStorage.cpp
+++ b/dom/src/storage/nsDOMStorage.cpp
@@ -213,18 +213,18 @@ ClearStorageIfDomainMatches(nsDOMStorage
 }
 
 nsresult
 nsDOMStorageManager::Observe(nsISupports *aSubject,
                              const char *aTopic,
                              const PRUnichar *aData)
 {
   if (!strcmp(aTopic, "profile-after-change")) {
-  } else if (!strcmp(aTopic, "cookie-changed") && aData &&
-             !NS_strcmp(aData, NS_LITERAL_STRING("cleared").get())) {
+  } else if (!strcmp(aTopic, "cookie-changed") &&
+             !nsCRT::strcmp(aData, NS_LITERAL_STRING("cleared").get())) {
     mStorages.EnumerateEntries(ClearStorage, nullptr);
 
     nsresult rv = DOMStorageImpl::InitDB();
     NS_ENSURE_SUCCESS(rv, rv);
 
     return DOMStorageImpl::gStorageDB->RemoveAll();
   } else if (!strcmp(aTopic, "perm-changed")) {
     // Check for cookie permission change
--- a/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp
+++ b/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp
@@ -62,17 +62,17 @@ ChangeCSSInlineStyleTxn::ValueIncludes(c
 
     while ((kNullCh != *end) && (false == nsCRT::IsAsciiSpace(*end))) { // look for space or end
       end++;
     }
     *end = kNullCh; // end string here
 
     if (start < end) {
       if (aCaseSensitive) {
-        if (value && !NS_strcmp(value, start)) {
+        if (!nsCRT::strcmp(value, start)) {
           result = true;
           break;
         }
       }
       else {
         if (nsDependentString(value).Equals(nsDependentString(start),
                                             nsCaseInsensitiveStringComparator())) {
           result = true;
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -1101,17 +1101,17 @@ NS_IMETHODIMP nsPermissionManager::GetEn
 NS_IMETHODIMP nsPermissionManager::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
 {
   ENSURE_NOT_CHILD_PROCESS;
 
   if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
     // The profile is about to change,
     // or is going away because the application is shutting down.
     mIsShuttingDown = true;
-    if (someData && !NS_strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
+    if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
       // Clear the permissions file and close the db asynchronously
       RemoveAllInternal(false);
     } else {
       RemoveAllFromMemory();
       CloseDB(false);
     }
   }
   else if (!nsCRT::strcmp(aTopic, "profile-do-change")) {
--- a/intl/locale/src/nsLocale.cpp
+++ b/intl/locale/src/nsLocale.cpp
@@ -93,26 +93,17 @@ nsLocale::Hash_HashFunction(const void* 
 
   return hash;
 }
 
 
 int
 nsLocale::Hash_CompareNSString(const void* s1, const void* 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;
+  return !nsCRT::strcmp((const PRUnichar *) s1, (const PRUnichar *) s2);
 }
 
 
 int
 nsLocale::Hash_EnumerateDelete(PLHashEntry *he, int hashIndex, void *arg)
 {
   // delete an entry
   nsMemory::Free((PRUnichar *)he->key);
--- a/modules/libpref/src/Preferences.cpp
+++ b/modules/libpref/src/Preferences.cpp
@@ -387,17 +387,17 @@ Preferences::Observe(nsISupports *aSubje
                      const PRUnichar *someData)
 {
   if (XRE_GetProcessType() == GeckoProcessType_Content)
     return NS_ERROR_NOT_AVAILABLE;
 
   nsresult rv = NS_OK;
 
   if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
-    if (someData && !NS_strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
+    if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
       if (mCurrentFile) {
         mCurrentFile->Remove(false);
         mCurrentFile = nullptr;
       }
     } else {
       rv = SavePrefFile(nullptr);
     }
   } else if (!strcmp(aTopic, "load-extension-defaults")) {
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -1437,18 +1437,18 @@ NS_IMETHODIMP
 nsCookieService::Observe(nsISupports     *aSubject,
                          const char      *aTopic,
                          const PRUnichar *aData)
 {
   // check the topic
   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 && aData &&
-        !NS_strcmp(aData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
+    if (mDBState && mDBState->dbConn &&
+        !nsCRT::strcmp(aData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
       // Clear the cookie db if we're in the default DBState.
       RemoveAll();
     }
 
     // Close the default DB connection and null out our DBStates before
     // changing.
     CloseDBStates();
 
--- a/netwerk/protocol/http/nsHttpAuthCache.cpp
+++ b/netwerk/protocol/http/nsHttpAuthCache.cpp
@@ -36,17 +36,17 @@ StrEquivalent(const PRUnichar *a, const 
 {
     static const PRUnichar emptyStr[] = {0};
 
     if (!a)
         a = emptyStr;
     if (!b)
         b = emptyStr;
 
-    return NS_strcmp(a, b) == 0;
+    return nsCRT::strcmp(a, b) == 0;
 }
 
 //-----------------------------------------------------------------------------
 // nsHttpAuthCache <public>
 //-----------------------------------------------------------------------------
 
 nsHttpAuthCache::nsHttpAuthCache()
     : mDB(nullptr)
--- a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp
+++ b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp
@@ -763,17 +763,17 @@ nsHttpChannelAuthProvider::GetCredential
                     authCache->ClearAuthEntry(scheme.get(), host,
                                               port, realm.get(),
                                               appId, isInBrowserElement);
                     entry = nullptr;
                     ident->Clear();
                 }
             }
             else if (!identFromURI ||
-                     (NS_strcmp(ident->User(),
+                     (nsCRT::strcmp(ident->User(),
                                     entry->Identity().User()) == 0 &&
                      !(loadFlags &
                        (nsIChannel::LOAD_ANONYMOUS |
                         nsIChannel::LOAD_EXPLICIT_CREDENTIALS)))) {
                 LOG(("  taking identity from auth cache\n"));
                 // the password from the auth cache is more likely to be
                 // correct than the one in the URL.  at least, we know that it
                 // works with the given username.  it is possible for a server
@@ -1345,17 +1345,17 @@ nsHttpChannelAuthProvider::SetAuthorizat
         // the username from the cache, then we should prefer the password
         // stored in the cache since that is most likely to be valid.
         if (header == nsHttp::Authorization && entry->Domain()[0] == '\0') {
             GetIdentityFromURI(0, ident);
             // if the usernames match, then clear the ident so we will pick
             // up the one from the auth cache instead.
             // when this is undesired, specify LOAD_EXPLICIT_CREDENTIALS load
             // flag.
-            if (NS_strcmp(ident.User(), entry->User()) == 0) {
+            if (nsCRT::strcmp(ident.User(), entry->User()) == 0) {
                 uint32_t loadFlags;
                 if (NS_SUCCEEDED(mAuthChannel->GetLoadFlags(&loadFlags)) &&
                     !(loadFlags && nsIChannel::LOAD_EXPLICIT_CREDENTIALS)) {
                     ident.Clear();
                 }
             }
         }
         bool identFromURI;
--- a/parser/htmlparser/src/nsHTMLTags.cpp
+++ b/parser/htmlparser/src/nsHTMLTags.cpp
@@ -300,17 +300,17 @@ HTMLTagsHashCodeUCPtr(const void *key)
 }
 
 static int
 HTMLTagsKeyCompareUCPtr(const void *key1, const void *key2)
 {
   const PRUnichar *str1 = (const PRUnichar *)key1;
   const PRUnichar *str2 = (const PRUnichar *)key2;
 
-  return str1 && str2 && NS_strcmp(str1, str2) == 0;
+  return nsCRT::strcmp(str1, str2) == 0;
 }
 
 // nsIAtom* -> id hash
 static PLHashNumber
 HTMLTagsHashCodeAtom(const void *key)
 {
   return NS_PTR_TO_INT32(key) >> 2;
 }
@@ -471,17 +471,17 @@ nsHTMLTags::TestTagTable()
 
      nsHTMLTags::AddRefTable();
      // Make sure we can find everything we are supposed to
      for (int i = 0; i < NS_HTML_TAG_MAX; ++i) {
        tag = sTagUnicodeTable[i];
        id = LookupTag(nsDependentString(tag));
        NS_ASSERTION(id != eHTMLTag_userdefined, "can't find tag id");
        const PRUnichar* check = GetStringValue(id);
-       NS_ASSERTION(0 == NS_strcmp(check, tag), "can't map id back to tag");
+       NS_ASSERTION(0 == nsCRT::strcmp(check, tag), "can't map id back to tag");
 
        nsAutoString uname(tag);
        ToUpperCase(uname);
        NS_ASSERTION(id == LookupTag(uname), "wrong id");
 
        NS_ASSERTION(id == CaseSensitiveLookupTag(tag), "wrong id");
 
        atom = do_GetAtom(tag);
--- a/rdf/base/src/nsRDFService.cpp
+++ b/rdf/base/src/nsRDFService.cpp
@@ -168,17 +168,18 @@ struct LiteralHashEntry : public PLDHash
 
     static bool
     MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
                const void *key)
     {
         const LiteralHashEntry *entry =
             static_cast<const LiteralHashEntry *>(hdr);
 
-        return 0 == NS_strcmp(static_cast<const PRUnichar *>(key), entry->mKey);
+        return 0 == nsCRT::strcmp(static_cast<const PRUnichar *>(key),
+                                  entry->mKey);
     }
 };
 
 static PLDHashTableOps gLiteralTableOps = {
     PL_DHashAllocTable,
     PL_DHashFreeTable,
     LiteralHashEntry::HashKey,
     LiteralHashEntry::MatchEntry,
--- a/security/manager/ssl/src/nsCertOverrideService.cpp
+++ b/security/manager/ssl/src/nsCertOverrideService.cpp
@@ -141,17 +141,17 @@ nsCertOverrideService::Observe(nsISuppor
 {
   // check the topic
   if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
     // The profile is about to change,
     // or is going away because the application is shutting down.
 
     ReentrantMonitorAutoEnter lock(monitor);
 
-    if (aData && !NS_strcmp(aData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
+    if (!nsCRT::strcmp(aData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
       RemoveAllFromMemory();
       // delete the storage file
       if (mSettingsFile) {
         mSettingsFile->Remove(false);
       }
     } else {
       RemoveAllFromMemory();
     }
--- a/toolkit/components/filepicker/nsFileView.cpp
+++ b/toolkit/components/filepicker/nsFileView.cpp
@@ -851,17 +851,17 @@ nsFileView::FilterFiles()
     if(NS_FAILED(file->GetLeafName(ucsLeafName))) {
       // need to check return value for GetLeafName()
       continue;
     }
     
     if (!isHidden) {
       for (uint32_t j = 0; j < filterCount; ++j) {
         bool matched = false;
-        if (!NS_strcmp(mCurrentFilters.ElementAt(j),
+        if (!nsCRT::strcmp(mCurrentFilters.ElementAt(j),
                            NS_LITERAL_STRING("..apps").get()))
         {
           file->IsExecutable(&matched);
         } else
           matched = (NS_WildCardMatch(ucsLeafName.get(),
                                       mCurrentFilters.ElementAt(j),
                                       true) == MATCH);
 
--- a/xpcom/ds/nsCRT.cpp
+++ b/xpcom/ds/nsCRT.cpp
@@ -68,16 +68,46 @@ char* nsCRT::strtok(char* string, const 
   *newStr = str;
 
   return str == result ? NULL : result;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 /**
+ * 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.
  * NOTE: We DO NOT terminate the search upon encountering NULL's before N
  *
  * @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
  */
--- a/xpcom/ds/nsCRT.h
+++ b/xpcom/ds/nsCRT.h
@@ -131,16 +131,18 @@ public:
       }
     }
     * WARNING - STRTOK WHACKS str THE FIRST TIME IT IS CALLED *
     * MAKE A COPY OF str IF YOU NEED TO USE IT AFTER strtok() *
   */
   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);
 
   // The GNU libc has memmem, which is strstr except for binary data
   // This is our own implementation that uses memmem on platforms
   // where it's available.
   static const char* memmem(const char* haystack, uint32_t haystackLen,
                             const char* needle, uint32_t needleLen);
--- a/xpcom/io/nsLocalFileCommon.cpp
+++ b/xpcom/io/nsLocalFileCommon.cpp
@@ -219,17 +219,17 @@ nsLocalFile::GetRelativeDescriptor(nsIFi
     if (thisNodeCnt < 0 || fromNodeCnt < 0)
       return NS_ERROR_FAILURE;
     
     for (nodeIndex = 0; nodeIndex < thisNodeCnt && nodeIndex < fromNodeCnt; ++nodeIndex) {
 #ifdef XP_WIN
       if (_wcsicmp(thisNodes[nodeIndex], fromNodes[nodeIndex]))
         break;
 #else
-      if (NS_strcmp(thisNodes[nodeIndex], fromNodes[nodeIndex]))
+      if (nsCRT::strcmp(thisNodes[nodeIndex], fromNodes[nodeIndex]))
         break;
 #endif
     }
     
     int32_t branchIndex = nodeIndex;
     for (nodeIndex = branchIndex; nodeIndex < fromNodeCnt; nodeIndex++) 
       _retval.AppendLiteral("../");
     for (nodeIndex = branchIndex; nodeIndex < thisNodeCnt; nodeIndex++) {
--- a/xpcom/tests/TestCRT.cpp
+++ b/xpcom/tests/TestCRT.cpp
@@ -41,19 +41,19 @@ static void Check(const char* s1, const 
 
   nsAutoString t1,t2; 
   t1.AssignWithConversion(s1);
   t2.AssignWithConversion(s2);
   const PRUnichar* us1 = t1.get();
   const PRUnichar* us2 = t2.get();
 
 #ifdef DEBUG
-  int u2 = us1 && us2 &&
+  int u2 =
 #endif
-    NS_strcmp(us1, us2);
+    nsCRT::strcmp(us1, us2);
 
 #ifdef DEBUG
   int u2_n =
 #endif
     nsCRT::strncmp(us1, us2, n);
 
   NS_ASSERTION(sign(clib) == sign(u2), "strcmp");
   NS_ASSERTION(sign(clib_n) == sign(u2_n), "strncmp");