Bug 944905 - Fixed char16_t/wchar_t mismatch in xpcom/ r=bsmedberg
authorJacek Caban <jacek@codeweavers.com>
Wed, 04 Dec 2013 13:19:09 +0100
changeset 167945 28f646255d25df67c5bf0bd338bb37c9d8a2b34b
parent 167944 17aacd34982ceabe666f203c7edfdc5ccc364aac
child 167946 fc2b0e721cd13a69b9314c83ff73b571d6780028
push id4703
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 20:24:19 +0000
treeherdermozilla-aurora@20af7fbd96c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs944905
milestone28.0a1
Bug 944905 - Fixed char16_t/wchar_t mismatch in xpcom/ r=bsmedberg
xpcom/base/nsDebugImpl.cpp
xpcom/build/BinaryPath.h
xpcom/ds/nsHashtable.cpp
xpcom/ds/nsIAtom.idl
xpcom/ds/nsWindowsRegKey.cpp
xpcom/glue/nsVersionComparator.cpp
xpcom/io/SpecialSystemDirectory.cpp
xpcom/io/nsDirectoryService.cpp
xpcom/io/nsLocalFileCommon.cpp
xpcom/io/nsLocalFileWin.cpp
xpcom/io/nsNativeCharsetUtils.cpp
xpcom/string/src/nsStringObsolete.cpp
xpcom/string/src/nsTDependentString.cpp
xpcom/string/src/nsTDependentSubstring.cpp
xpcom/string/src/nsTPromiseFlatString.cpp
xpcom/string/src/nsTStringObsolete.cpp
xpcom/tests/TestBase64.cpp
xpcom/threads/nsProcessCommon.cpp
--- a/xpcom/base/nsDebugImpl.cpp
+++ b/xpcom/base/nsDebugImpl.cpp
@@ -473,33 +473,33 @@ Break(const char *aMsg)
 
     /* Create the debug dialog out of process to avoid the crashes caused by 
      * Windows events leaking into our event loop from an in process dialog.
      * We do this by launching windbgdlg.exe (built in xpcom/windbgdlg).
      * See http://bugzilla.mozilla.org/show_bug.cgi?id=54792
      */
     PROCESS_INFORMATION pi;
     STARTUPINFOW si;
-    PRUnichar executable[MAX_PATH];
-    PRUnichar* pName;
+    wchar_t executable[MAX_PATH];
+    wchar_t* pName;
 
     memset(&pi, 0, sizeof(pi));
 
     memset(&si, 0, sizeof(si));
     si.cb          = sizeof(si);
     si.wShowWindow = SW_SHOW;
 
     // 2nd arg of CreateProcess is in/out
-    PRUnichar *msgCopy = (PRUnichar*) _alloca((strlen(aMsg) + 1)*sizeof(PRUnichar));
-    wcscpy(msgCopy  , (PRUnichar*)NS_ConvertUTF8toUTF16(aMsg).get());
+    wchar_t *msgCopy = (wchar_t*) _alloca((strlen(aMsg) + 1)*sizeof(wchar_t));
+    wcscpy(msgCopy, NS_ConvertUTF8toUTF16(aMsg).get());
 
-    if(GetModuleFileNameW(GetModuleHandleW(L"xpcom.dll"), (LPWCH)executable, MAX_PATH) &&
+    if(GetModuleFileNameW(GetModuleHandleW(L"xpcom.dll"), executable, MAX_PATH) &&
        nullptr != (pName = wcsrchr(executable, '\\')) &&
-       nullptr != wcscpy((WCHAR*)pName + 1, L"windbgdlg.exe") &&
-       CreateProcessW((LPCWSTR)executable, (LPWSTR)msgCopy, nullptr, nullptr,
+       nullptr != wcscpy(pName + 1, L"windbgdlg.exe") &&
+       CreateProcessW(executable, msgCopy, nullptr, nullptr,
                       false, DETACHED_PROCESS | NORMAL_PRIORITY_CLASS,
                       nullptr, nullptr, &si, &pi)) {
       WaitForSingleObject(pi.hProcess, INFINITE);
       GetExitCodeProcess(pi.hProcess, &code);
       CloseHandle(pi.hProcess);
       CloseHandle(pi.hThread);
     }
 
--- a/xpcom/build/BinaryPath.h
+++ b/xpcom/build/BinaryPath.h
@@ -17,27 +17,27 @@
 
 namespace mozilla {
 
 class BinaryPath {
 public:
 #ifdef XP_WIN
   static nsresult Get(const char *argv0, char aResult[MAXPATHLEN])
   {
-    PRUnichar wide_path[MAXPATHLEN];
+    wchar_t wide_path[MAXPATHLEN];
     nsresult rv = GetW(argv0, wide_path);
     if (NS_FAILED(rv))
       return rv;
     WideCharToMultiByte(CP_UTF8, 0, wide_path, -1,
                         aResult, MAXPATHLEN, nullptr, nullptr);
     return NS_OK;
   }
 
 private:
-  static nsresult GetW(const char *argv0, PRUnichar aResult[MAXPATHLEN])
+  static nsresult GetW(const char *argv0, wchar_t aResult[MAXPATHLEN])
   {
     if (::GetModuleFileNameW(0, aResult, MAXPATHLEN))
       return NS_OK;
     return NS_ERROR_FAILURE;
   }
 
 #elif defined(XP_MACOSX)
   static nsresult Get(const char *argv0, char aResult[MAXPATHLEN])
@@ -133,17 +133,17 @@ private:
 #error Oops, you need platform-specific code here
 #endif
 
 public:
   static nsresult GetFile(const char *argv0, nsIFile* *aResult)
   {
     nsCOMPtr<nsIFile> lf;
 #ifdef XP_WIN
-    PRUnichar exePath[MAXPATHLEN];
+    wchar_t exePath[MAXPATHLEN];
     nsresult rv = GetW(argv0, exePath);
 #else
     char exePath[MAXPATHLEN];
     nsresult rv = Get(argv0, exePath);
 #endif
     if (NS_FAILED(rv))
       return rv;
 #ifdef XP_WIN
--- a/xpcom/ds/nsHashtable.cpp
+++ b/xpcom/ds/nsHashtable.cpp
@@ -581,17 +581,17 @@ nsStringKey::nsStringKey(const nsStringK
     }
 #ifdef DEBUG
     mKeyType = StringKey;
 #endif
     MOZ_COUNT_CTOR(nsStringKey);
 }
 
 nsStringKey::nsStringKey(const nsAFlatString& str)
-    : mStr(const_cast<PRUnichar*>(str.get())),
+    : mStr((PRUnichar*)str.get()),
       mStrLen(str.Length()),
       mOwnership(OWN_CLONE)
 {
     NS_ASSERTION(mStr, "null string key");
 #ifdef DEBUG
     mKeyType = StringKey;
 #endif
     MOZ_COUNT_CTOR(nsStringKey);
--- a/xpcom/ds/nsIAtom.idl
+++ b/xpcom/ds/nsIAtom.idl
@@ -39,17 +39,17 @@ interface nsIAtom : nsISupports
   [noscript, notxpcom] boolean isStaticAtom();
 
 %{C++
   // note this is NOT virtual so this won't muck with the vtable!
   inline bool Equals(const nsAString& aString) const {
     return aString.Equals(nsDependentString(mString, mLength));
   }
 
-  inline const PRUnichar* GetUTF16String() const {
+  inline char16ptr_t GetUTF16String() const {
     return mString;
   }
 
   inline const uint32_t GetLength() const {
     return mLength;
   }
 
   inline void ToString(nsAString& aBuf) {
--- a/xpcom/ds/nsWindowsRegKey.cpp
+++ b/xpcom/ds/nsWindowsRegKey.cpp
@@ -153,17 +153,17 @@ nsWindowsRegKey::GetChildCount(uint32_t 
 NS_IMETHODIMP
 nsWindowsRegKey::GetChildName(uint32_t index, nsAString &result)
 {
   if (NS_WARN_IF(!mKey))
     return NS_ERROR_NOT_INITIALIZED;
 
   FILETIME lastWritten;
 
-  PRUnichar nameBuf[MAX_KEY_NAME_LEN + 1];
+  wchar_t nameBuf[MAX_KEY_NAME_LEN + 1];
   DWORD nameLen = sizeof(nameBuf) / sizeof(nameBuf[0]);
 
   LONG rv = RegEnumKeyExW(mKey, index, nameBuf, &nameLen, nullptr, nullptr,
                           nullptr, &lastWritten);
   if (rv != ERROR_SUCCESS)
     return NS_ERROR_NOT_AVAILABLE;  // XXX what's the best error code here?
 
   result.Assign(nameBuf, nameLen);
@@ -208,17 +208,17 @@ nsWindowsRegKey::GetValueCount(uint32_t 
 }
 
 NS_IMETHODIMP
 nsWindowsRegKey::GetValueName(uint32_t index, nsAString &result)
 {
   if (NS_WARN_IF(!mKey))
     return NS_ERROR_NOT_INITIALIZED;
 
-  PRUnichar nameBuf[MAX_VALUE_NAME_LEN];
+  wchar_t nameBuf[MAX_VALUE_NAME_LEN];
   DWORD nameLen = sizeof(nameBuf) / sizeof(nameBuf[0]);
 
   LONG rv = RegEnumValueW(mKey, index, nameBuf, &nameLen, nullptr, nullptr,
                           nullptr, nullptr);
   if (rv != ERROR_SUCCESS)
     return NS_ERROR_NOT_AVAILABLE;  // XXX what's the best error code here?
 
   result.Assign(nameBuf, nameLen);
--- a/xpcom/glue/nsVersionComparator.cpp
+++ b/xpcom/glue/nsVersionComparator.cpp
@@ -22,22 +22,22 @@ struct VersionPart {
 
   char       *extraD;  // null-terminated
 };
 
 #ifdef XP_WIN
 struct VersionPartW {
   int32_t     numA;
 
-  const PRUnichar *strB;    // NOT null-terminated, can be a null pointer
+  wchar_t    *strB;    // NOT null-terminated, can be a null pointer
   uint32_t    strBlen;
 
   int32_t     numC;
 
-  PRUnichar       *extraD;  // null-terminated
+  wchar_t    *extraD;  // null-terminated
 
 };
 #endif
 
 /**
  * Parse a version part into a number and "extra text".
  *
  * @returns A pointer to the next versionpart, or null if none.
@@ -107,21 +107,21 @@ ParseVP(char *part, VersionPart &result)
 
 
 /**
  * Parse a version part into a number and "extra text".
  *
  * @returns A pointer to the next versionpart, or null if none.
  */
 #ifdef XP_WIN
-static PRUnichar*
-ParseVP(PRUnichar *part, VersionPartW &result)
+static wchar_t*
+ParseVP(wchar_t *part, VersionPartW &result)
 {
 
-  PRUnichar *dot;
+  wchar_t *dot;
 
   result.numA = 0;
   result.strB = nullptr;
   result.strBlen = 0;
   result.numC = 0;
   result.extraD = nullptr;
 
   if (!part)
@@ -131,33 +131,33 @@ ParseVP(PRUnichar *part, VersionPartW &r
   if (dot)
     *dot = '\0';
 
   if (part[0] == '*' && part[1] == '\0') {
     result.numA = INT32_MAX;
     result.strB = L"";
   }
   else {
-    result.numA = wcstol(part, const_cast<PRUnichar**>(&result.strB), 10);
+    result.numA = wcstol(part, const_cast<wchar_t**>(&result.strB), 10);
   }
 
   if (!*result.strB) {
     result.strB = nullptr;
     result.strBlen = 0;
   }
   else {
     if (result.strB[0] == '+') {
-      static const PRUnichar kPre[] = L"pre";
+      static wchar_t kPre[] = L"pre";
 
       ++result.numA;
       result.strB = kPre;
       result.strBlen = sizeof(kPre) - 1;
     }
     else {
-      const PRUnichar *numstart = wcspbrk(result.strB, L"0123456789+-");
+      const wchar_t *numstart = wcspbrk(result.strB, L"0123456789+-");
       if (!numstart) {
 	result.strBlen = wcslen(result.strB);
       }
       else {
 	result.strBlen = numstart - result.strB;
 
 	result.numC = wcstol(numstart, &result.extraD, 10);
 	if (!*result.extraD)
@@ -277,28 +277,28 @@ CompareVP(VersionPartW &v1, VersionPartW
 #endif
 
 namespace mozilla {
 
 #ifdef XP_WIN
 int32_t
 CompareVersions(const PRUnichar *A, const PRUnichar *B)
 {
-  PRUnichar *A2 = wcsdup(A);
+  wchar_t *A2 = wcsdup(char16ptr_t(A));
   if (!A2)
     return 1;
 
-  PRUnichar *B2 = wcsdup(B);
+  wchar_t *B2 = wcsdup(char16ptr_t(B));
   if (!B2) {
     free(A2);
     return 1;
   }
 
   int32_t result;
-  PRUnichar *a = A2, *b = B2;
+  wchar_t *a = A2, *b = B2;
 
   do {
     VersionPartW va, vb;
 
     a = ParseVP(a, va);
     b = ParseVP(b, vb);
 
     result = CompareVP(va, vb);
--- a/xpcom/io/SpecialSystemDirectory.cpp
+++ b/xpcom/io/SpecialSystemDirectory.cpp
@@ -165,17 +165,17 @@ GetLibrarySaveToPath(int aFallbackFolder
     nsRefPtr<IShellItem> savePath;
     HRESULT hr =
         SHLoadLibraryFromKnownFolder(aFolderId, STGM_READ,
                                      IID_IShellLibrary, getter_AddRefs(shellLib));
 
     if (shellLib &&
         SUCCEEDED(shellLib->GetDefaultSaveFolder(DSFT_DETECT, IID_IShellItem,
                                                  getter_AddRefs(savePath)))) {
-        PRUnichar* str = nullptr;
+        wchar_t* str = nullptr;
         if (SUCCEEDED(savePath->GetDisplayName(SIGDN_FILESYSPATH, &str))) {
             nsAutoString path;
             path.Assign(str);
             path.AppendLiteral("\\");
             nsresult rv =
                 NS_NewLocalFile(path, false, aFile);
             CoTaskMemFree(str);
             return rv;
--- a/xpcom/io/nsDirectoryService.cpp
+++ b/xpcom/io/nsDirectoryService.cpp
@@ -92,22 +92,22 @@ nsDirectoryService::GetCurrentProcessDir
 
     if (localFile == nullptr)
         return NS_ERROR_OUT_OF_MEMORY;
     NS_ADDREF(localFile);
 
 
 
 #ifdef XP_WIN
-    PRUnichar buf[MAX_PATH + 1];
+    wchar_t buf[MAX_PATH + 1];
     SetLastError(ERROR_SUCCESS);
     if (GetModuleFileNameW(0, buf, mozilla::ArrayLength(buf)) &&
         GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
         // chop off the executable name by finding the rightmost backslash
-        PRUnichar* lastSlash = wcsrchr(buf, L'\\');
+        wchar_t* lastSlash = wcsrchr(buf, L'\\');
         if (lastSlash)
             *(lastSlash + 1) = L'\0';
 
         localFile->InitWithPath(nsDependentString(buf));
         *aFile = localFile;
         return NS_OK;
     }
 
--- a/xpcom/io/nsLocalFileCommon.cpp
+++ b/xpcom/io/nsLocalFileCommon.cpp
@@ -218,17 +218,17 @@ nsLocalFile::GetRelativeDescriptor(nsIFi
     
     thisNodeCnt = SplitPath(thisPathPtr, thisNodes, kMaxNodesInPath);
     fromNodeCnt = SplitPath(fromPathPtr, fromNodes, kMaxNodesInPath);
     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]))
+      if (_wcsicmp(char16ptr_t(thisNodes[nodeIndex]), char16ptr_t(fromNodes[nodeIndex])))
         break;
 #else
       if (nsCRT::strcmp(thisNodes[nodeIndex], fromNodes[nodeIndex]))
         break;
 #endif
     }
     
     int32_t branchIndex = nodeIndex;
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -684,17 +684,17 @@ void FileTimeToPRTime(const FILETIME *fi
 
 // copied from nsprpub/pr/src/{io/prfile.c | md/windows/w95io.c} with some
 // changes : PR_GetFileInfo64, _PR_MD_GETFILEINFO64
 static nsresult
 GetFileInfo(const nsAFlatString &name, PRFileInfo64 *info)
 {
     WIN32_FILE_ATTRIBUTE_DATA fileData;
 
-    if (name.IsEmpty() || name.FindCharInSet(L"?*") != kNotFound)
+    if (name.IsEmpty() || name.FindCharInSet(MOZ_UTF16("?*")) != kNotFound)
         return NS_ERROR_INVALID_ARG;
 
     if (!::GetFileAttributesExW(name.get(), GetFileExInfoStandard, &fileData))
         return ConvertWinError(GetLastError());
 
     if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
         info->type = PR_FILE_DIRECTORY;
     } else {
@@ -777,17 +777,17 @@ ReadDir(nsDir *dir, PRDirFlags flags, ns
             dir->firstEntry = false;
             rv = 1;
         } else
             rv = ::FindNextFileW(dir->handle, &(dir->data));
 
         if (rv == 0)
             break;
 
-        const PRUnichar *fileName;
+        const wchar_t *fileName;
         nsString tmp;
         fileName = (dir)->data.cFileName;
 
         if ((flags & PR_SKIP_DOT) &&
             (fileName[0] == L'.') && (fileName[1] == L'\0'))
             continue;
         if ((flags & PR_SKIP_DOT_DOT) &&
             (fileName[0] == L'.') && (fileName[1] == L'.') &&
@@ -1263,17 +1263,17 @@ nsLocalFile::Create(uint32_t type, uint3
         // dealing with a UNC path here; skip past '\\machine\'
         path = wcschr(path + 2, L'\\');
         if (!path)
             return NS_ERROR_FILE_INVALID_PATH;
         ++path;
     }
 
     // search for first slash after the drive (or volume) name
-    PRUnichar* slash = wcschr(path, L'\\');
+    wchar_t* slash = wcschr(path, L'\\');
 
     nsresult directoryCreateError = NS_OK;
     if (slash)
     {
         // skip the first '\\'
         ++slash;
         slash = wcschr(slash, L'\\');
 
@@ -1632,18 +1632,17 @@ nsLocalFile::GetVersionInfoField(const c
     nsresult rv = ResolveAndStat();
     if (NS_FAILED(rv))
         return rv;
 
     rv = NS_ERROR_FAILURE;
 
     // Cast away const-ness here because WinAPI functions don't understand it, 
     // the path is used for [in] parameters only however so it's safe. 
-    WCHAR *path = const_cast<WCHAR*>(mFollowSymlinks ? mResolvedPath.get() 
-                                                        : mWorkingPath.get());
+    const WCHAR *path = mFollowSymlinks ? mResolvedPath.get() : mWorkingPath.get();
 
     DWORD dummy;
     DWORD size = ::GetFileVersionInfoSizeW(path, &dummy);
     if (!size)
         return rv;
 
     void* ver = calloc(size, 1);
     if (!ver)
@@ -1654,17 +1653,17 @@ nsLocalFile::GetVersionInfoField(const c
         LANGANDCODEPAGE* translate = nullptr;
         UINT pageCount;
         BOOL queryResult = ::VerQueryValueW(ver, L"\\VarFileInfo\\Translation", 
                                             (void**)&translate, &pageCount);
         if (queryResult && translate) 
         {
             for (int32_t i = 0; i < 2; ++i) 
             { 
-                PRUnichar subBlock[MAX_PATH];
+                wchar_t subBlock[MAX_PATH];
                 _snwprintf(subBlock, MAX_PATH,
                            L"\\StringFileInfo\\%04x%04x\\%s", 
                            (i == 0 ? translate[0].wLanguage 
                                    : ::GetUserDefaultLangID()),
                            translate[0].wCodePage,
                            NS_ConvertASCIItoUTF16(
                                nsDependentCString(aField)).get());
                 subBlock[MAX_PATH - 1] = 0;
@@ -1732,18 +1731,18 @@ nsLocalFile::SetShortcut(nsIFile* target
         }
         iconFilePath = iconPathAuto.get();
     }
 
     rv = gResolver->SetShortcut(exists,
                                 mWorkingPath.get(),
                                 targetFilePath,
                                 workingDirPath,
-                                args,
-                                description,
+                                char16ptr_t(args),
+                                char16ptr_t(description),
                                 iconFilePath,
                                 iconFilePath? iconIndex : 0);
     if (targetFilePath && NS_SUCCEEDED(rv)) {
       MakeDirty();
     }
 
     return rv;
 }
@@ -2343,17 +2342,17 @@ nsLocalFile::SetLastModifiedTimeOfLink(P
     return rv;
 }
 
 nsresult
 nsLocalFile::SetModDate(PRTime aLastModifiedTime, const PRUnichar *filePath)
 {
     // The FILE_FLAG_BACKUP_SEMANTICS is required in order to change the
     // modification time for directories.
-    HANDLE file = ::CreateFileW(filePath,          // pointer to name of the file
+    HANDLE file = ::CreateFileW(char16ptr_t(filePath), // pointer to name of the file
                                 GENERIC_WRITE,     // access (write) mode
                                 0,                 // share mode
                                 nullptr,           // pointer to security attributes
                                 OPEN_EXISTING,     // how to create
                                 FILE_FLAG_BACKUP_SEMANTICS,  // file attributes
                                 nullptr);
 
     if (file == INVALID_HANDLE_VALUE)
--- a/xpcom/io/nsNativeCharsetUtils.cpp
+++ b/xpcom/io/nsNativeCharsetUtils.cpp
@@ -909,17 +909,17 @@ NS_CopyNativeToUnicode(const nsACString 
 nsresult
 NS_CopyUnicodeToNative(const nsAString  &input, nsACString &output)
 {
     uint32_t inputLen = input.Length();
 
     nsAString::const_iterator iter;
     input.BeginReading(iter);
 
-    const PRUnichar *buf = iter.get();
+    char16ptr_t buf = iter.get();
 
     // determine length of result
     uint32_t resultLen = 0;
 
     int n = ::WideCharToMultiByte(CP_ACP, 0, buf, inputLen, nullptr, 0,
                                   nullptr, nullptr);
     if (n > 0)
         resultLen += n;
@@ -952,17 +952,17 @@ NS_ConvertAtoW(const char *aStrInA, int 
 
 int32_t 
 NS_ConvertWtoA(const PRUnichar *aStrInW, int aBufferSizeOut,
                char *aStrOutA, const char *aDefault)
 {
     if ((!aStrInW) || (!aStrOutA) || (aBufferSizeOut <= 0))
         return 0;
 
-    int numCharsConverted = WideCharToMultiByte(CP_ACP, 0, aStrInW, -1, 
+    int numCharsConverted = WideCharToMultiByte(CP_ACP, 0, char16ptr_t(aStrInW), -1,
                                                 aStrOutA, aBufferSizeOut,
                                                 aDefault, nullptr);
 
     if (!numCharsConverted) {
         if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
             // Overflow, add missing null termination but return 0
             aStrOutA[aBufferSizeOut-1] = '\0';
         }
--- a/xpcom/string/src/nsStringObsolete.cpp
+++ b/xpcom/string/src/nsStringObsolete.cpp
@@ -866,17 +866,17 @@ RFind_ComputeSearchRange( uint32_t bigLe
 // specialized methods:
 
 int32_t
 nsString::Find( const nsAFlatString& aString, int32_t aOffset, int32_t aCount ) const
   {
     // this method changes the meaning of aOffset and aCount:
     Find_ComputeSearchRange(mLength, aString.Length(), aOffset, aCount);
 
-    int32_t result = FindSubstring(mData + aOffset, aCount, aString.get(), aString.Length(), false);
+    int32_t result = FindSubstring(mData + aOffset, aCount, static_cast<const char16_t*>(aString.get()), aString.Length(), false);
     if (result != kNotFound)
       result += aOffset;
     return result;
   }
 
 int32_t
 nsString::Find( const PRUnichar* aString, int32_t aOffset, int32_t aCount ) const
   {
@@ -884,17 +884,17 @@ nsString::Find( const PRUnichar* aString
   }
 
 int32_t
 nsString::RFind( const nsAFlatString& aString, int32_t aOffset, int32_t aCount ) const
   {
     // this method changes the meaning of aOffset and aCount:
     RFind_ComputeSearchRange(mLength, aString.Length(), aOffset, aCount);
 
-    int32_t result = RFindSubstring(mData + aOffset, aCount, aString.get(), aString.Length(), false);
+    int32_t result = RFindSubstring(mData + aOffset, aCount, static_cast<const char16_t*>(aString.get()), aString.Length(), false);
     if (result != kNotFound)
       result += aOffset;
     return result;
   }
 
 int32_t
 nsString::RFind( const PRUnichar* aString, int32_t aOffset, int32_t aCount ) const
   {
--- a/xpcom/string/src/nsTDependentString.cpp
+++ b/xpcom/string/src/nsTDependentString.cpp
@@ -10,13 +10,13 @@ nsTDependentString_CharT::Rebind( const 
     // If we currently own a buffer, release it.
     Finalize();
 
     size_type strLength = str.Length();
 
     if (startPos > strLength)
       startPos = strLength;
 
-    mData = const_cast<char_type*>(str.Data()) + startPos;
+    mData = const_cast<char_type*>(static_cast<const char_type*>(str.Data())) + startPos;
     mLength = strLength - startPos;
 
     SetDataFlags(F_TERMINATED);
   }
--- a/xpcom/string/src/nsTDependentSubstring.cpp
+++ b/xpcom/string/src/nsTDependentSubstring.cpp
@@ -10,26 +10,26 @@ nsTDependentSubstring_CharT::Rebind( con
     // If we currently own a buffer, release it.
     Finalize();
 
     size_type strLength = str.Length();
 
     if (startPos > strLength)
       startPos = strLength;
 
-    mData = const_cast<char_type*>(str.Data()) + startPos;
+    mData = const_cast<char_type*>(static_cast<const char_type*>(str.Data())) + startPos;
     mLength = XPCOM_MIN(length, strLength - startPos);
 
     SetDataFlags(F_NONE);
   }
 
 void
 nsTDependentSubstring_CharT::Rebind( const char_type* data, size_type length )
   {
     NS_ASSERTION(data, "nsTDependentSubstring must wrap a non-NULL buffer");
 
     // If we currently own a buffer, release it.
     Finalize();
 
-    mData = const_cast<char_type*>(data);
+    mData = const_cast<char_type*>(static_cast<const char_type*>(data));
     mLength = length;
     SetDataFlags(F_NONE);
   }
--- a/xpcom/string/src/nsTPromiseFlatString.cpp
+++ b/xpcom/string/src/nsTPromiseFlatString.cpp
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 void
 nsTPromiseFlatString_CharT::Init(const substring_type& str)
   {
     if (str.IsTerminated())
       {
-        mData = const_cast<char_type*>(str.Data());
+        mData = const_cast<char_type*>(static_cast<const char_type*>(str.Data()));
         mLength = str.Length();
         mFlags = F_TERMINATED; // does not promote F_VOIDED
       }
     else
       {
         Assign(str);
       }
   }
--- a/xpcom/string/src/nsTStringObsolete.cpp
+++ b/xpcom/string/src/nsTStringObsolete.cpp
@@ -462,17 +462,17 @@ void
 nsTString_CharT::ReplaceSubstring( const self_type& aTarget, const self_type& aNewValue )
   {
     if (aTarget.Length() == 0)
       return;
 
     uint32_t i = 0;
     while (i < mLength)
       {
-        int32_t r = FindSubstring(mData + i, mLength - i, aTarget.Data(), aTarget.Length(), false);
+        int32_t r = FindSubstring(mData + i, mLength - i, static_cast<const char_type*>(aTarget.Data()), aTarget.Length(), false);
         if (r == kNotFound)
           break;
 
         Replace(i + r, aTarget.Length(), aNewValue);
         i += r + aNewValue.Length();
       }
   }
 
--- a/xpcom/tests/TestBase64.cpp
+++ b/xpcom/tests/TestBase64.cpp
@@ -253,17 +253,19 @@ FakeInputStream::NextTest()
 
 bool
 FakeInputStream::CheckTest(nsACString& aResult)
 {
   return !strcmp(aResult.BeginReading(), mTest->mResult) ? true : false;
 }
 
 #ifdef XP_WIN
-#define NS_tstrcmp wcscmp
+static inline int NS_tstrcmp(char16ptr_t x, char16ptr_t y) {
+    return wcscmp(x, y);
+}
 #else
 #define NS_tstrcmp strcmp
 #endif
 
 bool
 FakeInputStream::CheckTest(nsAString& aResult)
 {
   return !NS_tstrcmp(aResult.BeginReading(),
--- a/xpcom/threads/nsProcessCommon.cpp
+++ b/xpcom/threads/nsProcessCommon.cpp
@@ -108,17 +108,17 @@ nsProcess::Init(nsIFile* executable)
         rv = mExecutable->GetPath(mTargetPath);
 
     return rv;
 }
 
 
 #if defined(XP_WIN)
 // Out param `wideCmdLine` must be PR_Freed by the caller.
-static int assembleCmdLine(char *const *argv, PRUnichar **wideCmdLine,
+static int assembleCmdLine(char *const *argv, wchar_t **wideCmdLine,
                            UINT codePage)
 {
     char *const *arg;
     char *p, *q, *cmdLine;
     int cmdLineSize;
     int numBackslashes;
     int i;
     int argNeedQuotes;
@@ -209,17 +209,17 @@ static int assembleCmdLine(char *const *
         }
         if (argNeedQuotes) {
             *p++ = '"';
         }
     } 
 
     *p = '\0';
     int32_t numChars = MultiByteToWideChar(codePage, 0, cmdLine, -1, nullptr, 0);
-    *wideCmdLine = (PRUnichar *) PR_MALLOC(numChars*sizeof(PRUnichar));
+    *wideCmdLine = (wchar_t *) PR_MALLOC(numChars*sizeof(wchar_t));
     MultiByteToWideChar(codePage, 0, cmdLine, -1, *wideCmdLine, numChars); 
     PR_Free(cmdLine);
     return 0;
 }
 #endif
 
 void nsProcess::Monitor(void *arg)
 {
@@ -425,17 +425,17 @@ nsProcess::RunProcess(bool blocking, cha
         }
     }
 
     mExitValue = -1;
     mPid = -1;
 
 #if defined(PROCESSMODEL_WINAPI)
     BOOL retVal;
-    PRUnichar *cmdLine = nullptr;
+    wchar_t *cmdLine = nullptr;
 
     // The 'argv' array is null-terminated and always starts with the program path.
     // If the second slot is non-null then arguments are being passed.
     if (my_argv[1] != nullptr &&
         assembleCmdLine(my_argv + 1, &cmdLine, argsUTF8 ? CP_UTF8 : CP_ACP) == -1) {
         return NS_ERROR_FILE_EXECUTION_FAILED;    
     }