Bug 944913 - Fixed char16_t/wchar_t mismatch in tollkit/. r=ehsan

--HG--
extra : rebase_source : c33427dd7c1c2db3d2741b8c2e0d1b4a0359a0a4
This commit is contained in:
Jacek Caban 2013-12-03 16:07:22 +01:00
Родитель 9956262b6c
Коммит ae12308871
11 изменённых файлов: 54 добавлений и 53 удалений

Просмотреть файл

@ -459,10 +459,10 @@ nsDownloadScanner::Scan::DoScanAES()
bool gotException = false;
MOZ_SEH_TRY {
(void)ae->SetClientGuid(GUID_MozillaVirusScannerPromptGeneric);
(void)ae->SetLocalPath(mPath.BeginWriting());
(void)ae->SetLocalPath(mPath.get());
// Provide the src for everything but data: schemes.
if (!mSkipSource)
(void)ae->SetSource(mOrigin.BeginWriting());
(void)ae->SetSource(mOrigin.get());
// Save() will invoke the scanner
hr = ae->Save();

Просмотреть файл

@ -32,7 +32,7 @@ nsUserInfo::GetUsername(char **aUsername)
*aUsername = nullptr;
// ULEN is the max username length as defined in lmcons.h
PRUnichar username[UNLEN +1];
wchar_t username[UNLEN +1];
DWORD size = mozilla::ArrayLength(username);
if (!GetUserNameW(username, &size))
return NS_ERROR_FAILURE;
@ -47,7 +47,7 @@ nsUserInfo::GetFullname(PRUnichar **aFullname)
NS_ENSURE_ARG_POINTER(aFullname);
*aFullname = nullptr;
PRUnichar fullName[512];
wchar_t fullName[512];
DWORD size = mozilla::ArrayLength(fullName);
if (GetUserNameExW(NameDisplay, fullName, &size)) {
@ -57,7 +57,7 @@ nsUserInfo::GetFullname(PRUnichar **aFullname)
// Try to use the net APIs regardless of the error because it may be
// able to obtain the information.
PRUnichar username[UNLEN + 1];
wchar_t username[UNLEN + 1];
size = mozilla::ArrayLength(username);
if (!GetUserNameW(username, &size)) {
// ERROR_NONE_MAPPED means the user info is not filled out on this computer
@ -119,7 +119,7 @@ nsUserInfo::GetEmailAddress(char **aEmailAddress)
*aEmailAddress = nullptr;
// RFC3696 says max length of an email address is 254
PRUnichar emailAddress[255];
wchar_t emailAddress[255];
DWORD size = mozilla::ArrayLength(emailAddress);
if (!GetUserNameExW(NameUserPrincipal, emailAddress, &size)) {

Просмотреть файл

@ -871,7 +871,7 @@ nsresult SetExceptionHandler(nsIFile* aXREDirectory,
nsString crashReporterPath_temp;
exePath->GetPath(crashReporterPath_temp);
crashReporterPath = ToNewUnicode(crashReporterPath_temp);
crashReporterPath = reinterpret_cast<wchar_t*>(ToNewUnicode(crashReporterPath_temp));
#elif !defined(__ANDROID__)
nsCString crashReporterPath_temp;
@ -1098,7 +1098,7 @@ nsresult SetMinidumpPath(const nsAString& aPath)
#ifndef XP_LINUX
gExceptionHandler->set_dump_path(
CONVERT_UTF16_TO_XP_CHAR(aPath).BeginReading());
char16ptr_t(CONVERT_UTF16_TO_XP_CHAR(aPath).BeginReading()));
#else
gExceptionHandler->set_minidump_descriptor(
MinidumpDescriptor(CONVERT_UTF16_TO_XP_CHAR(aPath).BeginReading()));
@ -1922,7 +1922,7 @@ FindPendingDir()
#ifdef XP_WIN
nsString path;
pendingDir->GetPath(path);
pendingDirectory = ToNewUnicode(path);
pendingDirectory = reinterpret_cast<wchar_t*>(ToNewUnicode(path));
#else
nsCString path;
pendingDir->GetNativePath(path);
@ -2503,7 +2503,7 @@ SetRemoteExceptionHandler(const nsACString& crashPipe)
nullptr, // no callback context
google_breakpad::ExceptionHandler::HANDLER_ALL,
MiniDumpNormal,
NS_ConvertASCIItoUTF16(crashPipe).BeginReading(),
NS_ConvertASCIItoUTF16(crashPipe).get(),
nullptr);
#ifdef XP_WIN
gExceptionHandler->set_handle_debug_exceptions(true);

Просмотреть файл

@ -153,8 +153,8 @@
#include <process.h>
#include <shlobj.h>
#include "nsThreadUtils.h"
#include <comutil.h>
#include <Wbemidl.h>
#include <comdef.h>
#include <wbemidl.h>
#endif
#ifdef XP_MACOSX

Просмотреть файл

@ -97,7 +97,7 @@ WriteConsoleLog();
#ifdef XP_WIN
BOOL
WinLaunchChild(const PRUnichar *exePath, int argc,
WinLaunchChild(const wchar_t *exePath, int argc,
char **argv, HANDLE userToken = nullptr,
HANDLE *hProcess = nullptr);
BOOL

Просмотреть файл

@ -99,7 +99,7 @@ using mozilla::startup::sChildProcessType;
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
#ifdef XP_WIN
static const PRUnichar kShellLibraryName[] = L"shell32.dll";
static const wchar_t kShellLibraryName[] = L"shell32.dll";
#endif
nsresult

Просмотреть файл

@ -476,9 +476,9 @@ struct MessageWindow {
}
// Class name: appName + "MessageWindow"
static const PRUnichar *className() {
static PRUnichar classNameBuffer[128];
static PRUnichar *mClassName = 0;
static const wchar_t *className() {
static wchar_t classNameBuffer[128];
static wchar_t *mClassName = 0;
if ( !mClassName ) {
::_snwprintf(classNameBuffer,
128, // size of classNameBuffer in PRUnichars
@ -643,7 +643,8 @@ nsNativeAppSupportWin::Start( bool *aResult ) {
// Grab mutex first.
// Build mutex name from app name.
::_snwprintf(mMutexName, sizeof mMutexName / sizeof(PRUnichar), L"%s%s%s",
::_snwprintf(reinterpret_cast<wchar_t*>(mMutexName),
sizeof mMutexName / sizeof(PRUnichar), L"%s%s%s",
MOZ_MUTEX_NAMESPACE,
NS_ConvertUTF8toUTF16(gAppData->name).get(),
MOZ_STARTUP_MUTEX_NAME );
@ -1218,7 +1219,7 @@ void nsNativeAppSupportWin::ParseDDEArg( HSZ args, int index, nsString& aString)
// Ensure result's buffer is sufficiently big.
temp.SetLength( argLen );
// Now get the string contents.
DdeQueryString( mInstance, args, temp.BeginWriting(), temp.Length(), CP_WINUNICODE );
DdeQueryString( mInstance, args, reinterpret_cast<wchar_t*>(temp.BeginWriting()), temp.Length(), CP_WINUNICODE );
// Parse out the given arg.
ParseDDEArg(temp.get(), index, aString);
return;

Просмотреть файл

@ -24,7 +24,7 @@
* additional length if the string needs to be quoted and if characters need to
* be escaped.
*/
static int ArgStrLen(const PRUnichar *s)
static int ArgStrLen(const wchar_t *s)
{
int backslashes = 0;
int i = wcslen(s);
@ -65,7 +65,7 @@ static int ArgStrLen(const PRUnichar *s)
*
* @return the end of the string
*/
static PRUnichar* ArgToString(PRUnichar *d, const PRUnichar *s)
static wchar_t* ArgToString(wchar_t *d, const wchar_t *s)
{
int backslashes = 0;
BOOL hasDoubleQuote = wcschr(s, L'"') != nullptr;
@ -116,8 +116,8 @@ static PRUnichar* ArgToString(PRUnichar *d, const PRUnichar *s)
*
* argv is UTF8
*/
PRUnichar*
MakeCommandLine(int argc, PRUnichar **argv)
wchar_t*
MakeCommandLine(int argc, wchar_t **argv)
{
int i;
int len = 0;
@ -130,11 +130,11 @@ MakeCommandLine(int argc, PRUnichar **argv)
if (len == 0)
len = 1;
PRUnichar *s = (PRUnichar*) malloc(len * sizeof(PRUnichar));
wchar_t *s = (wchar_t*) malloc(len * sizeof(wchar_t));
if (!s)
return nullptr;
PRUnichar *c = s;
wchar_t *c = s;
for (i = 0; i < argc; ++i) {
c = ArgToString(c, argv[i]);
if (i + 1 != argc) {
@ -168,7 +168,7 @@ AllocConvertUTF8toUTF16(const char *arg)
}
static void
FreeAllocStrings(int argc, PRUnichar **argv)
FreeAllocStrings(int argc, wchar_t **argv)
{
while (argc) {
--argc;
@ -187,23 +187,23 @@ FreeAllocStrings(int argc, PRUnichar **argv)
*/
BOOL
WinLaunchChild(const PRUnichar *exePath,
int argc, PRUnichar **argv,
WinLaunchChild(const wchar_t *exePath,
int argc, wchar_t **argv,
HANDLE userToken = nullptr,
HANDLE *hProcess = nullptr);
BOOL
WinLaunchChild(const PRUnichar *exePath,
int argc, char **argv,
WinLaunchChild(const wchar_t *exePath,
int argc, char **argv,
HANDLE userToken,
HANDLE *hProcess)
{
PRUnichar** argvConverted = new PRUnichar*[argc];
wchar_t** argvConverted = new wchar_t*[argc];
if (!argvConverted)
return FALSE;
for (int i = 0; i < argc; ++i) {
argvConverted[i] = AllocConvertUTF8toUTF16(argv[i]);
argvConverted[i] = reinterpret_cast<wchar_t*>(AllocConvertUTF8toUTF16(argv[i]));
if (!argvConverted[i]) {
FreeAllocStrings(i, argvConverted);
return FALSE;
@ -216,13 +216,13 @@ WinLaunchChild(const PRUnichar *exePath,
}
BOOL
WinLaunchChild(const PRUnichar *exePath,
WinLaunchChild(const wchar_t *exePath,
int argc,
PRUnichar **argv,
wchar_t **argv,
HANDLE userToken,
HANDLE *hProcess)
{
PRUnichar *cl;
wchar_t *cl;
BOOL ok;
cl = MakeCommandLine(argc, argv);

Просмотреть файл

@ -49,7 +49,7 @@ int main(int argc, char **argv, char **envp);
#endif
static char*
AllocConvertUTF16toUTF8(const WCHAR *arg)
AllocConvertUTF16toUTF8(char16ptr_t arg)
{
// be generous... UTF16 units can expand up to 3 UTF8 units
int len = wcslen(arg);

Просмотреть файл

@ -879,7 +879,7 @@ nsXREDirProvider::DoShutdown()
static nsresult
GetShellFolderPath(int folder, nsAString& _retval)
{
PRUnichar* buf;
wchar_t* buf;
uint32_t bufLength = _retval.GetMutableData(&buf, MAXPATHLEN + 3);
NS_ENSURE_TRUE(bufLength >= (MAXPATHLEN + 3), NS_ERROR_OUT_OF_MEMORY);
@ -960,14 +960,14 @@ GetCachedHash(HKEY rootKey, const nsAString &regPath, const nsAString &path,
nsAString &cachedHash)
{
HKEY baseKey;
if (RegOpenKeyExW(rootKey, regPath.BeginReading(), 0, KEY_READ, &baseKey) !=
if (RegOpenKeyExW(rootKey, reinterpret_cast<const wchar_t*>(regPath.BeginReading()), 0, KEY_READ, &baseKey) !=
ERROR_SUCCESS) {
return false;
}
wchar_t cachedHashRaw[512];
DWORD bufferSize = sizeof(cachedHashRaw);
LONG result = RegQueryValueExW(baseKey, path.BeginReading(), 0, nullptr,
LONG result = RegQueryValueExW(baseKey, reinterpret_cast<const wchar_t*>(path.BeginReading()), 0, nullptr,
(LPBYTE)cachedHashRaw, &bufferSize);
RegCloseKey(baseKey);
if (result == ERROR_SUCCESS) {
@ -1045,7 +1045,7 @@ nsXREDirProvider::GetUpdateRootDir(nsIFile* *aResult)
// AppDir may be a short path. Convert to long path to make sure
// the consistency of the update folder location
nsString longPath;
PRUnichar* buf;
wchar_t* buf;
uint32_t bufLength = longPath.GetMutableData(&buf, MAXPATHLEN);
NS_ENSURE_TRUE(bufLength >= MAXPATHLEN, NS_ERROR_OUT_OF_MEMORY);

Просмотреть файл

@ -42,8 +42,8 @@
// CommandLineToArgvW and converting it back to a command line with
// MakeCommandLine.
static int
verifyCmdLineCreation(PRUnichar *inCmdLine,
PRUnichar *compareCmdLine,
verifyCmdLineCreation(wchar_t *inCmdLine,
wchar_t *compareCmdLine,
bool passes, int testNum)
{
int rv = 0;
@ -64,13 +64,13 @@ verifyCmdLineCreation(PRUnichar *inCmdLine,
// handles argv[0] differently than other arguments since argv[0] is the path
// to the binary being executed and MakeCommandLine only handles argv[1] and
// larger.
PRUnichar *inCmdLineNew = (PRUnichar *) malloc((wcslen(DUMMY_ARG1) + wcslen(inCmdLine) + 1) * sizeof(PRUnichar));
wchar_t *inCmdLineNew = (wchar_t *) malloc((wcslen(DUMMY_ARG1) + wcslen(inCmdLine) + 1) * sizeof(wchar_t));
wcscpy(inCmdLineNew, DUMMY_ARG1);
wcscat(inCmdLineNew, inCmdLine);
LPWSTR *inArgv = CommandLineToArgvW(inCmdLineNew, &inArgc);
PRUnichar *outCmdLine = MakeCommandLine(inArgc - 1, inArgv + 1);
PRUnichar *outCmdLineNew = (PRUnichar *) malloc((wcslen(DUMMY_ARG1) + wcslen(outCmdLine) + 1) * sizeof(PRUnichar));
wchar_t *outCmdLine = MakeCommandLine(inArgc - 1, inArgv + 1);
wchar_t *outCmdLineNew = (wchar_t *) malloc((wcslen(DUMMY_ARG1) + wcslen(outCmdLine) + 1) * sizeof(wchar_t));
wcscpy(outCmdLineNew, DUMMY_ARG1);
wcscat(outCmdLineNew, outCmdLine);
LPWSTR *outArgv = CommandLineToArgvW(outCmdLineNew, &outArgc);
@ -160,7 +160,7 @@ verifyCmdLineCreation(PRUnichar *inCmdLine,
return rv;
}
int wmain(int argc, PRUnichar *argv[])
int wmain(int argc, wchar_t *argv[])
{
int i;
int rv = 0;
@ -174,7 +174,7 @@ int wmain(int argc, PRUnichar *argv[])
return 255;
}
PRUnichar inifile[MAXPATHLEN];
wchar_t inifile[MAXPATHLEN];
if (!::GetModuleFileNameW(0, inifile, MAXPATHLEN)) {
wprintf(L"TEST-UNEXPECTED-FAIL | %s | GetModuleFileNameW\n", TEST_NAME);
return 2;
@ -189,12 +189,12 @@ int wmain(int argc, PRUnichar *argv[])
wcscpy(slash + 1, L"TestXREMakeCommandLineWin.ini\0");
for (i = 0; i < MAX_TESTS; ++i) {
PRUnichar sInputVal[MAXPATHLEN];
PRUnichar sOutputVal[MAXPATHLEN];
PRUnichar sPassesVal[MAXPATHLEN];
PRUnichar sInputKey[MAXPATHLEN];
PRUnichar sOutputKey[MAXPATHLEN];
PRUnichar sPassesKey[MAXPATHLEN];
wchar_t sInputVal[MAXPATHLEN];
wchar_t sOutputVal[MAXPATHLEN];
wchar_t sPassesVal[MAXPATHLEN];
wchar_t sInputKey[MAXPATHLEN];
wchar_t sOutputKey[MAXPATHLEN];
wchar_t sPassesKey[MAXPATHLEN];
if (argc > 2 && _wcsicmp(argv[1], L"-check-one") == 0 && argc == 3) {
i = _wtoi(argv[2]);