Bug 1407624 - Make nsEscape.cpp build in non-unified mode. r=froydnj
authorChris Pearce <cpearce@mozilla.com>
Wed, 11 Oct 2017 16:32:23 +0200
changeset 679099 44335b8d480b841dd85b54ac22fd9de835f3c0be
parent 679098 2f3dd84d4d228a6a52f47164eabd1298ed26ebe9
child 679100 1ac7fce0b369889c60010e66085d2bf0eb8bc250
push id84141
push userbmo:schien@mozilla.com
push dateThu, 12 Oct 2017 11:13:04 +0000
reviewersfroydnj
bugs1407624
milestone58.0a1
Bug 1407624 - Make nsEscape.cpp build in non-unified mode. r=froydnj nsEscape.cpp doesn't build in non-unified mode, as it uses mozilla::fallible, mozilla::CheckedInt and mozilla::ASCIIMask::IsMasked without prefixing them with the mozilla namespace. I suspect this file is usually included in unified_cpp file which includes a "using namespace mozilla" directive. MozReview-Commit-ID: GwlsK8kytLj
xpcom/io/nsEscape.cpp
--- a/xpcom/io/nsEscape.cpp
+++ b/xpcom/io/nsEscape.cpp
@@ -211,17 +211,17 @@ nsUnescapeCount(char* aStr)
 } /* NET_UnEscapeCnt */
 
 void
 nsAppendEscapedHTML(const nsACString& aSrc, nsACString& aDst)
 {
   // Preparation: aDst's length will increase by at least aSrc's length. If the
   // addition overflows, we skip this, which is fine, and we'll likely abort
   // while (infallibly) appending due to aDst becoming too large.
-  CheckedInt<nsACString::size_type> newCapacity = aDst.Length();
+  mozilla::CheckedInt<nsACString::size_type> newCapacity = aDst.Length();
   newCapacity += aSrc.Length();
   if (newCapacity.isValid()) {
     aDst.SetCapacity(newCapacity.value());
   }
 
   for (auto cur = aSrc.BeginReading(); cur != aSrc.EndReading(); cur++) {
     if (*cur == '<') {
       aDst.AppendLiteral("&lt;");
@@ -323,19 +323,19 @@ T_EscapeURL(const typename T::char_type*
 
   bool previousIsNonASCII = false;
   for (size_t i = 0; i < aPartLen; ++i) {
     unsigned_char_type c = *src++;
 
     // If there is a filter, we wish to skip any characters which match it.
     // This is needed so we don't perform an extra pass just to extract the
     // filtered characters.
-    if (aFilterMask && ASCIIMask::IsMasked(*aFilterMask, c)) {
+    if (aFilterMask && mozilla::ASCIIMask::IsMasked(*aFilterMask, c)) {
       if (!writing) {
-        if (!aResult.Append(aPart, i, fallible)) {
+        if (!aResult.Append(aPart, i, mozilla::fallible)) {
           return NS_ERROR_OUT_OF_MEMORY;
         }
         writing = true;
       }
       continue;
     }
 
     // if the char has not to be escaped or whatever follows % is
@@ -359,39 +359,39 @@ T_EscapeURL(const typename T::char_type*
          || (c > 0x20 && c < 0x7f && ignoreAscii))
         && !(c == ':' && colon)
         && !(previousIsNonASCII && c == '|' && !ignoreNonAscii)) {
       if (writing) {
         tempBuffer[tempBufferPos++] = c;
       }
     } else { /* do the escape magic */
       if (!writing) {
-        if (!aResult.Append(aPart, i, fallible)) {
+        if (!aResult.Append(aPart, i, mozilla::fallible)) {
           return NS_ERROR_OUT_OF_MEMORY;
         }
         writing = true;
       }
       uint32_t len = ::AppendPercentHex(tempBuffer + tempBufferPos, c);
       tempBufferPos += len;
       MOZ_ASSERT(len <= ENCODE_MAX_LEN, "potential buffer overflow");
     }
 
     // Flush the temp buffer if it doesnt't have room for another encoded char.
     if (tempBufferPos >= mozilla::ArrayLength(tempBuffer) - ENCODE_MAX_LEN) {
       NS_ASSERTION(writing, "should be writing");
-      if (!aResult.Append(tempBuffer, tempBufferPos, fallible)) {
+      if (!aResult.Append(tempBuffer, tempBufferPos, mozilla::fallible)) {
         return NS_ERROR_OUT_OF_MEMORY;
       }
       tempBufferPos = 0;
     }
 
     previousIsNonASCII = (c > 0x7f);
   }
   if (writing) {
-    if (!aResult.Append(tempBuffer, tempBufferPos, fallible)) {
+    if (!aResult.Append(tempBuffer, tempBufferPos, mozilla::fallible)) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
   }
   aDidAppend = writing;
   return NS_OK;
 }
 
 bool