Skip to content

Commit

Permalink
Bug 945245 - Fixed misc char16_t/wchar_t mismatches. r=ehsan
Browse files Browse the repository at this point in the history
  • Loading branch information
cjacek committed Dec 3, 2013
1 parent f9652ff commit c993bad
Show file tree
Hide file tree
Showing 20 changed files with 40 additions and 48 deletions.
2 changes: 1 addition & 1 deletion accessible/src/windows/msaa/Compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ using namespace mozilla::a11y;
bool
IsModuleVersionLessThan(HMODULE aModuleHandle, DWORD aMajor, DWORD aMinor)
{
PRUnichar fileName[MAX_PATH];
wchar_t fileName[MAX_PATH];
::GetModuleFileNameW(aModuleHandle, fileName, MAX_PATH);

DWORD dummy = 0;
Expand Down
2 changes: 1 addition & 1 deletion accessible/src/windows/msaa/nsWinUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using namespace mozilla::a11y;

// Window property used by ipc related code in identifying accessible
// tab windows.
const PRUnichar* kPropNameTabContent = L"AccessibleTabWindow";
const wchar_t* kPropNameTabContent = L"AccessibleTabWindow";

/**
* WindowProc to process WM_GETOBJECT messages, used in windows emulation mode.
Expand Down
5 changes: 2 additions & 3 deletions accessible/src/windows/sdn/sdnAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ sdnAccessible::get_attributesForNames(unsigned short aMaxAttribs,
if (aAttribNames[index]) {
nsAutoString attributeValue, nameSpaceURI;
nsAutoString attributeName(nsDependentString(
static_cast<PRUnichar*>(aAttribNames[index])));
static_cast<const wchar_t*>(aAttribNames[index])));

nsresult rv = NS_OK;
if (aNameSpaceID[index]>0 &&
Expand Down Expand Up @@ -282,8 +282,7 @@ sdnAccessible::get_computedStyleForProperties(unsigned short aNumStyleProperties
for (index = 0; index < aNumStyleProperties; index++) {
nsAutoString value;
if (aStyleProperties[index])
cssDecl->GetPropertyValue(nsDependentString(static_cast<PRUnichar*>(
aStyleProperties[index])), value); // Get property value
cssDecl->GetPropertyValue(nsDependentString(aStyleProperties[index]), value); // Get property value
aStyleValues[index] = ::SysAllocString(value.get());
}

Expand Down
10 changes: 5 additions & 5 deletions browser/components/shell/src/nsWindowsShellService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
// otherwise.
*aIsDefaultBrowser = true;

PRUnichar exePath[MAX_BUF];
wchar_t exePath[MAX_BUF];
if (!::GetModuleFileNameW(0, exePath, MAX_BUF))
return NS_ERROR_FAILURE;

Expand All @@ -424,7 +424,7 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
HKEY theKey;
DWORD res;
nsresult rv;
PRUnichar currValue[MAX_BUF];
wchar_t currValue[MAX_BUF];

SETTING* settings = gSettings;
if (!aForAllTypes && IsWin8OrLater()) {
Expand Down Expand Up @@ -611,7 +611,7 @@ DynSHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo)

// shell32.dll is in the knownDLLs list so will always be loaded from the
// system32 directory.
static const PRUnichar kSehllLibraryName[] = L"shell32.dll";
static const wchar_t kSehllLibraryName[] = L"shell32.dll";
HMODULE shellDLL = ::LoadLibraryW(kSehllLibraryName);
if (!shellDLL) {
return NS_ERROR_FAILURE;
Expand Down Expand Up @@ -967,7 +967,7 @@ nsWindowsShellService::OpenApplication(int32_t aApplication)
if (NS_FAILED(rv))
return rv;

PRUnichar buf[MAX_BUF];
wchar_t buf[MAX_BUF];
DWORD type, len = sizeof buf;
DWORD res = ::RegQueryValueExW(theKey, EmptyString().get(), 0,
&type, (LPBYTE)&buf, &len);
Expand Down Expand Up @@ -1068,7 +1068,7 @@ nsWindowsShellService::SetDesktopBackgroundColor(uint32_t aColor)
nsIWindowsRegKey::ACCESS_SET_VALUE);
NS_ENSURE_SUCCESS(rv, rv);

PRUnichar rgb[12];
wchar_t rgb[12];
_snwprintf(rgb, 12, L"%u %u %u", r, g, b);

rv = regKey->WriteStringValue(NS_LITERAL_STRING("Background"),
Expand Down
4 changes: 1 addition & 3 deletions content/base/src/nsDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11403,9 +11403,7 @@ nsIDocument::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope)

NS_NAMED_LITERAL_STRING(doc_str, "document");

if (!JS_DefineUCProperty(aCx, JSVAL_TO_OBJECT(winVal),
reinterpret_cast<const jschar *>
(doc_str.get()),
if (!JS_DefineUCProperty(aCx, JSVAL_TO_OBJECT(winVal), doc_str.get(),
doc_str.Length(), JS::ObjectValue(*obj),
JS_PropertyStub, JS_StrictPropertyStub,
JSPROP_READONLY | JSPROP_ENUMERATE)) {
Expand Down
6 changes: 2 additions & 4 deletions content/xbl/src/nsXBLProtoImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,7 @@ nsXBLProtoImpl::ResolveAllFields(JSContext *cx, JS::Handle<JSObject*> obj) const
// all.
nsDependentString name(f->GetName());
JS::Rooted<JS::Value> dummy(cx);
if (!::JS_LookupUCProperty(cx, obj,
reinterpret_cast<const jschar*>(name.get()),
name.Length(), &dummy)) {
if (!::JS_LookupUCProperty(cx, obj, name.get(), name.Length(), &dummy)) {
return false;
}
}
Expand All @@ -321,7 +319,7 @@ nsXBLProtoImpl::UndefineFields(JSContext *cx, JS::Handle<JSObject*> obj) const
for (nsXBLProtoImplField* f = mFields; f; f = f->GetNext()) {
nsDependentString name(f->GetName());

const jschar* s = reinterpret_cast<const jschar*>(name.get());
const jschar* s = name.get();
bool hasProp;
if (::JS_AlreadyHasOwnUCProperty(cx, obj, s, name.Length(), &hasProp) &&
hasProp) {
Expand Down
2 changes: 1 addition & 1 deletion content/xbl/src/nsXBLProtoImplField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,5 +494,5 @@ nsXBLProtoImplField::Write(nsIObjectOutputStream* aStream)
rv = aStream->Write32(mLineNumber);
NS_ENSURE_SUCCESS(rv, rv);

return aStream->WriteWStringZ(mFieldText ? mFieldText : EmptyString().get());
return aStream->WriteWStringZ(mFieldText ? mFieldText : MOZ_UTF16(""));
}
2 changes: 1 addition & 1 deletion content/xbl/src/nsXBLPrototypeHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,5 +1009,5 @@ nsXBLPrototypeHandler::Write(nsIObjectOutputStream* aStream)

rv = aStream->Write32(mLineNumber);
NS_ENSURE_SUCCESS(rv, rv);
return aStream->WriteWStringZ(mHandlerText ? mHandlerText : EmptyString().get());
return aStream->WriteWStringZ(mHandlerText ? mHandlerText : MOZ_UTF16(""));
}
10 changes: 5 additions & 5 deletions embedding/components/printingui/src/win/nsPrintDialogUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ static HGLOBAL CreateGlobalDevModeAndInit(const nsXPIDLString& aPrintName, nsIPr

HANDLE hPrinter = nullptr;
// const cast kludge for silly Win32 api's
LPWSTR printName = const_cast<wchar_t*>(aPrintName.get());
LPWSTR printName = const_cast<wchar_t*>(static_cast<const wchar_t*>(aPrintName.get()));
BOOL status = ::OpenPrinterW(printName, &hPrinter, nullptr);
if (status) {

Expand Down Expand Up @@ -806,7 +806,7 @@ ShowNativePrintDialog(HWND aHWnd,
GetDefaultPrinterNameFromGlobalPrinters(printerName);
} else {
HANDLE hPrinter = nullptr;
if(!::OpenPrinterW(const_cast<wchar_t*>(printerName.get()), &hPrinter, nullptr)) {
if(!::OpenPrinterW(const_cast<wchar_t*>(static_cast<const wchar_t*>(printerName.get())), &hPrinter, nullptr)) {
// If the last used printer is not found, we should use default printer.
GetDefaultPrinterNameFromGlobalPrinters(printerName);
} else {
Expand Down Expand Up @@ -910,8 +910,8 @@ ShowNativePrintDialog(HWND aHWnd,
return NS_ERROR_FAILURE;
}

wchar_t* device = &(((wchar_t *)devnames)[devnames->wDeviceOffset]);
wchar_t* driver = &(((wchar_t *)devnames)[devnames->wDriverOffset]);
char16_t* device = &(((char16_t *)devnames)[devnames->wDeviceOffset]);
char16_t* driver = &(((char16_t *)devnames)[devnames->wDriverOffset]);

// Check to see if the "Print To File" control is checked
// then take the name from devNames and set it in the PrintSettings
Expand All @@ -922,7 +922,7 @@ ShowNativePrintDialog(HWND aHWnd,
// if the "Print To File" checkbox is checked it MUST be "FILE:"
// We assert as an extra safety check.
if (prntdlg.Flags & PD_PRINTTOFILE) {
wchar_t* fileName = &(((wchar_t *)devnames)[devnames->wOutputOffset]);
char16ptr_t fileName = &(((wchar_t *)devnames)[devnames->wOutputOffset]);
NS_ASSERTION(wcscmp(fileName, L"FILE:") == 0, "FileName must be `FILE:`");
aPrintSettings->SetToFileName(fileName);
aPrintSettings->SetPrintToFile(true);
Expand Down
2 changes: 1 addition & 1 deletion extensions/auth/nsAuthSSPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

//-----------------------------------------------------------------------------

static const PRUnichar *const pTypeName [] = {
static const wchar_t *const pTypeName [] = {
L"Kerberos",
L"Negotiate",
L"NTLM"
Expand Down
4 changes: 2 additions & 2 deletions image/decoders/icon/win/nsIconChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ static DWORD GetSpecialFolderIcon(nsIFile* aFile, int aFolder, SHFILEINFOW* aSFI
if (!aFile)
return shellResult;

PRUnichar fileNativePath[MAX_PATH];
wchar_t fileNativePath[MAX_PATH];
nsAutoString fileNativePathStr;
aFile->GetPath(fileNativePathStr);
::GetShortPathNameW(fileNativePathStr.get(), fileNativePath, ArrayLength(fileNativePath));

LPITEMIDLIST idList;
HRESULT hr = ::SHGetSpecialFolderLocation(nullptr, aFolder, &idList);
if (SUCCEEDED(hr)) {
PRUnichar specialNativePath[MAX_PATH];
wchar_t specialNativePath[MAX_PATH];
::SHGetPathFromIDListW(idList, specialNativePath);
::GetShortPathNameW(specialNativePath, specialNativePath, ArrayLength(specialNativePath));

Expand Down
8 changes: 2 additions & 6 deletions intl/locale/src/windows/nsDateTimeFormatWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ int nsDateTimeFormatWin::nsGetTimeFormatW(DWORD dwFlags, const SYSTEMTIME *lpTim
int len = 0;
len = GetTimeFormatW(mLCID, dwFlags, lpTime,
format ?
const_cast<LPCWSTR>
(NS_ConvertASCIItoUTF16(format).get()) :
NS_ConvertASCIItoUTF16(format).get() :
nullptr,
(LPWSTR) timeStr, cchTime);
return len;
Expand All @@ -249,10 +248,7 @@ int nsDateTimeFormatWin::nsGetDateFormatW(DWORD dwFlags, const SYSTEMTIME *lpDat
{
int len = 0;
len = GetDateFormatW(mLCID, dwFlags, lpDate,
format ?
const_cast<LPCWSTR>
(NS_ConvertASCIItoUTF16(format).get()) :
nullptr,
format ? NS_ConvertASCIItoUTF16(format).get() : nullptr,
(LPWSTR) dateStr, cchDate);
return len;
}
2 changes: 1 addition & 1 deletion intl/locale/src/windows/nsWinCharset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ nsPlatformCharset::GetDefaultCharsetForLocale(const nsAString& localeName, nsACS
rv = nsWin32Locale::GetPlatformLocale(localeName, &localeAsLCID);
if (NS_FAILED(rv)) { return rv; }

PRUnichar acp_name[6];
wchar_t acp_name[6];
if (GetLocaleInfoW(localeAsLCID, LOCALE_IDEFAULTANSICODEPAGE, acp_name,
ArrayLength(acp_name))==0) {
return NS_ERROR_FAILURE;
Expand Down
5 changes: 3 additions & 2 deletions intl/lwbrk/src/nsUniscribeBreaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ NS_GetComplexLineBreaks(const PRUnichar* aText, uint32_t aLength,
int outItems = 0;
HRESULT result;
nsAutoTArray<SCRIPT_ITEM, 64> items;
char16ptr_t text = aText;

memset(aBreakBefore, false, aLength);

if (!items.AppendElements(64))
return;

do {
result = ScriptItemize(aText, aLength, items.Length(), nullptr, nullptr,
result = ScriptItemize(text, aLength, items.Length(), nullptr, nullptr,
items.Elements(), &outItems);

if (result == E_OUTOFMEMORY) {
Expand All @@ -46,7 +47,7 @@ NS_GetComplexLineBreaks(const PRUnichar* aText, uint32_t aLength,
if (!sla.AppendElements(endOffset - startOffset))
return;

if (ScriptBreak(aText + startOffset, endOffset - startOffset,
if (ScriptBreak(text + startOffset, endOffset - startOffset,
&items[iItem].a, sla.Elements()) < 0)
return;

Expand Down
2 changes: 1 addition & 1 deletion ipc/glue/GeckoChildProcessHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
// See XRE_InitChildProcess in nsEmbedFunction.

// Win app model id
cmdLine.AppendLooseValue(std::wstring(mGroupId.get()));
cmdLine.AppendLooseValue(mGroupId.get());

// Process id
cmdLine.AppendLooseValue(UTF8ToWide(pidstring));
Expand Down
2 changes: 1 addition & 1 deletion ipc/glue/WindowsMessageLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ using namespace mozilla::ipc::windows;

#if defined(ACCESSIBILITY)
// pulled from accessibility's win utils
extern const PRUnichar* kPropNameTabContent;
extern const wchar_t* kPropNameTabContent;
#endif

// widget related message id constants we need to defer
Expand Down
2 changes: 1 addition & 1 deletion rdf/datasource/src/nsFileSystemDataSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ FileSystemDataSource::GetVolumeList(nsISimpleEnumerator** aResult)
#ifdef XP_WIN

int32_t driveType;
PRUnichar drive[32];
wchar_t drive[32];
int32_t volNum;

for (volNum = 0; volNum < 26; volNum++)
Expand Down
6 changes: 3 additions & 3 deletions uriloader/exthandler/win/nsMIMEInfoWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ nsMIMEInfoWin::LoadUriInternal(nsIURI * aURL)
rv = textToSubURI->UnEscapeNonAsciiURI(urlCharset, urlSpec, utf16Spec);
NS_ENSURE_SUCCESS(rv, rv);

static const PRUnichar cmdVerb[] = L"open";
static const wchar_t cmdVerb[] = L"open";
SHELLEXECUTEINFOW sinfo;
memset(&sinfo, 0, sizeof(sinfo));
sinfo.cbSize = sizeof(sinfo);
Expand Down Expand Up @@ -426,15 +426,15 @@ bool nsMIMEInfoWin::GetDllLaunchInfo(nsIFile * aDll,
if (bufLength == 0) // Error
return false;

nsAutoArrayPtr<PRUnichar> destination(new PRUnichar[bufLength]);
nsAutoArrayPtr<wchar_t> destination(new wchar_t[bufLength]);
if (!destination)
return false;
if (!::ExpandEnvironmentStringsW(appFilesystemCommand.get(),
destination,
bufLength))
return false;

appFilesystemCommand = destination;
appFilesystemCommand = static_cast<const wchar_t*>(destination);

// C:\Windows\System32\rundll32.exe "C:\Program Files\Windows
// Photo Gallery\PhotoViewer.dll", ImageView_Fullscreen %1
Expand Down
10 changes: 5 additions & 5 deletions uriloader/exthandler/win/nsOSHelperAppService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolSch
{
// Vista: use new application association interface
if (mAppAssoc) {
PRUnichar * pResult = nullptr;
wchar_t * pResult = nullptr;
NS_ConvertASCIItoUTF16 scheme(aProtocolScheme);
// We are responsible for freeing returned strings.
HRESULT hr = mAppAssoc->QueryCurrentDefault(scheme.get(),
Expand Down Expand Up @@ -164,7 +164,7 @@ NS_IMETHODIMP nsOSHelperAppService::GetApplicationDescription(const nsACString&

// Vista: use new application association interface
if (mAppAssoc) {
PRUnichar * pResult = nullptr;
wchar_t * pResult = nullptr;
// We are responsible for freeing returned strings.
HRESULT hr = mAppAssoc->QueryCurrentDefault(buf.get(),
AT_URLPROTOCOL, AL_EFFECTIVE,
Expand Down Expand Up @@ -352,14 +352,14 @@ static void StripRundll32(nsString& aCommandString)
if (bufLength == 0) // Error
return false;

nsAutoArrayPtr<PRUnichar> destination(new PRUnichar[bufLength]);
nsAutoArrayPtr<wchar_t> destination(new wchar_t[bufLength]);
if (!destination)
return false;
if (!::ExpandEnvironmentStringsW(handlerCommand.get(), destination,
bufLength))
return false;

handlerCommand = destination;
handlerCommand = static_cast<const wchar_t*>(destination);

// Remove quotes around paths
handlerCommand.StripChars("\"");
Expand Down Expand Up @@ -543,7 +543,7 @@ already_AddRefed<nsMIMEInfoWin> nsOSHelperAppService::GetByExtension(const nsAFl
// Vista: use the new application association COM interfaces
// for resolving helpers.
nsString assocType(fileExtToUse);
PRUnichar * pResult = nullptr;
wchar_t * pResult = nullptr;
HRESULT hr = mAppAssoc->QueryCurrentDefault(assocType.get(),
AT_FILEEXTENSION, AL_EFFECTIVE,
&pResult);
Expand Down
2 changes: 1 addition & 1 deletion xpfe/components/directory/nsDirectoryViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ nsHTTPIndex::OnFTPControlLog(bool server, const char *msg)

nsString unicodeMsg;
unicodeMsg.AssignWithConversion(msg);
JSString* jsMsgStr = JS_NewUCStringCopyZ(cx, (jschar*) unicodeMsg.get());
JSString* jsMsgStr = JS_NewUCStringCopyZ(cx, unicodeMsg.get());
NS_ENSURE_TRUE(jsMsgStr, NS_ERROR_OUT_OF_MEMORY);

params[0] = BOOLEAN_TO_JSVAL(server);
Expand Down

0 comments on commit c993bad

Please sign in to comment.