fix opening attachments after frozen linkage patch, r/sr=bienvenu
authorneil@parkwaycc.co.uk <neil@httl.net>
Mon, 28 Jun 2010 14:02:45 -0700
changeset 5906 30d7f2e796c0ceff2db4b0bbc7105bf4ea4aa261
parent 5905 74ccec25e4a9a7c5817b368657ec18c208a5df9a
child 5907 8b1b4701dbab7dcc3432ffc2742437428ecf6e75
push idunknown
push userunknown
push dateunknown
fix opening attachments after frozen linkage patch, r/sr=bienvenu
mailnews/base/util/nsMsgUtils.cpp
--- a/mailnews/base/util/nsMsgUtils.cpp
+++ b/mailnews/base/util/nsMsgUtils.cpp
@@ -315,47 +315,57 @@ static PRUint32 StringHash(const char *u
 }
 
 inline PRUint32 StringHash(const nsAutoString& str)
 {
     return StringHash(reinterpret_cast<const char*>(str.get()),
                       str.Length() * 2);
 }
 
+#ifndef MOZILLA_INTERNAL_API
+static int GetFindInSetFilter(const char* aChars)
+{
+  PRUint8 filter = 0;
+  while (*aChars)
+    filter |= *aChars++;
+  return ~filter;
+}
+#endif
+
 /* Utility functions used in a few places in mailnews */
 PRInt32
 MsgFindCharInSet(const nsCString &aString,
                  const char* aChars, PRUint32 aOffset)
 {
-#ifdef MOZILLA_INTENAL_API
-  return FindCharInSet(aChars, aOffset)
+#ifdef MOZILLA_INTERNAL_API
+  return aString.FindCharInSet(aChars, aOffset);
 #else
-  PRInt32 len = strlen(aChars);
-  PRInt32 index = -1;
-  for (int i = aOffset; i < len; i++) {
-    index = aString.FindChar(aChars[i]);
-    if (index != -1)
+  const char *str;
+  PRUint32 len = aString.BeginReading(&str);
+  int filter = GetFindInSetFilter(aChars);
+  for (PRUint32 index = aOffset; index < len; index++) {
+    if (!(str[index] & filter) && strchr(aChars, str[index]))
       return index;
   }
   return -1;
 #endif
 }
 
 PRInt32
 MsgFindCharInSet(const nsString &aString,
                  const char* aChars, PRUint32 aOffset)
 {
-#ifdef MOZILLA_INTENAL_API
-  return FindCharInSet(aChars, aOffset)
+#ifdef MOZILLA_INTERNAL_API
+  return aString.FindCharInSet(aChars, aOffset);
 #else
-  PRInt32 len = strlen(aChars);
-  PRInt32 index = -1;
-  for (int i = aOffset; i < len; i++) {
-    index = aString.FindChar(aChars[i]);
-    if (index != -1)
+  const PRUnichar *str;
+  PRUint32 len = aString.BeginReading(&str);
+  int filter = GetFindInSetFilter(aChars);
+  for (PRUint32 index = aOffset; index < len; index++) {
+    if (!(str[index] & filter) && strchr(aChars, str[index]))
       return index;
   }
   return -1;
 #endif
 }
 
 // XXX : this may have other clients, in which case we'd better move it to
 //       xpcom/io/nsNativeCharsetUtils with nsAString in place of nsAutoString