Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
switching windows narrow char system calls to wide char b=418703 r=bs…
Browse files Browse the repository at this point in the history
…medberg a=beltzner
  • Loading branch information
bslassey committed Mar 5, 2008
1 parent 07622d9 commit ac3bb05
Show file tree
Hide file tree
Showing 58 changed files with 527 additions and 552 deletions.
2 changes: 1 addition & 1 deletion accessible/src/msaa/nsAccessNodeWrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ void nsAccessNodeWrap::InitAccessibility()
}

if (!gmUserLib) {
gmUserLib =::LoadLibrary("USER32.DLL");
gmUserLib =::LoadLibraryW(L"USER32.DLL");
}

if (gmUserLib) {
Expand Down
2 changes: 1 addition & 1 deletion accessible/src/msaa/nsAccessibleWrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ STDMETHODIMP nsAccessibleWrap::AccessibleObjectFromWindow(HWND hwnd,
{
// open the dll dynamically
if (!gmAccLib)
gmAccLib =::LoadLibrary("OLEACC.DLL");
gmAccLib =::LoadLibraryW(L"OLEACC.DLL");

if (gmAccLib) {
if (!gmAccessibleObjectFromWindow)
Expand Down
8 changes: 3 additions & 5 deletions browser/app/nsBrowserApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ static void Output(const char *fmt, ... )
va_start(ap, fmt);

#if defined(XP_WIN) && !MOZ_WINCONSOLE
char msg[2048];

_vsnprintf(msg, sizeof(msg), fmt, ap);

MessageBox(NULL, msg, "XULRunner", MB_OK | MB_ICONERROR);
PRUnichar msg[2048];
_vsnwprintf(msg, sizeof(msg), NS_ConvertUTF8toUTF16(fmt).get(), ap);
MessageBoxW(NULL, msg, L"XULRunner", MB_OK | MB_ICONERROR);
#else
vfprintf(stderr, fmt, ap);
#endif
Expand Down
13 changes: 6 additions & 7 deletions browser/components/migration/src/nsIEProfileMigrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ nsIEProfileMigrator::CopyPasswords(PRBool aReplace)
nsresult rv;
nsVoidArray signonsFound;

HMODULE pstoreDLL = ::LoadLibrary("pstorec.dll");
HMODULE pstoreDLL = ::LoadLibraryW(L"pstorec.dll");
if (!pstoreDLL) {
// XXXben TODO
// Need to figure out what to do here on Windows 98 etc... it may be that the key is universal read
Expand Down Expand Up @@ -1177,7 +1177,7 @@ nsIEProfileMigrator::CopyFormData(PRBool aReplace)
{
HRESULT hr;

HMODULE pstoreDLL = ::LoadLibrary("pstorec.dll");
HMODULE pstoreDLL = ::LoadLibraryW(L"pstorec.dll");
if (!pstoreDLL) {
// XXXben TODO
// Need to figure out what to do here on Windows 98 etc... it may be that the key is universal read
Expand Down Expand Up @@ -1410,20 +1410,19 @@ nsIEProfileMigrator::ResolveShortcut(const nsString &aFileName, char** aOutURL)
{
HRESULT result;

IUniformResourceLocator* urlLink = nsnull;
IUniformResourceLocatorW* urlLink = nsnull;
result = ::CoCreateInstance(CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER,
IID_IUniformResourceLocator, (void**)&urlLink);
IID_IUniformResourceLocatorW, (void**)&urlLink);
if (SUCCEEDED(result) && urlLink) {
IPersistFile* urlFile = nsnull;
result = urlLink->QueryInterface(IID_IPersistFile, (void**)&urlFile);
if (SUCCEEDED(result) && urlFile) {
result = urlFile->Load(aFileName.get(), STGM_READ);
if (SUCCEEDED(result) ) {
LPSTR lpTemp = nsnull;
LPWSTR lpTemp = nsnull;
result = urlLink->GetURL(&lpTemp);
if (SUCCEEDED(result) && lpTemp) {
*aOutURL = PL_strdup(lpTemp);

*aOutURL = *aOutURL = (char*)ToNewUTF8String(nsDependentString(lpTemp));
// free the string that GetURL alloc'd
::CoTaskMemFree(lpTemp);
}
Expand Down
8 changes: 4 additions & 4 deletions browser/components/shell/src/nsWindowsShellService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUs
rv = appHelper->AppendNative(NS_LITERAL_CSTRING("helper.exe"));
NS_ENSURE_SUCCESS(rv, rv);

nsCAutoString appHelperPath;
rv = appHelper->GetNativePath(appHelperPath);
nsAutoString appHelperPath;
rv = appHelper->GetPath(appHelperPath);
NS_ENSURE_SUCCESS(rv, rv);

if (aForAllUsers) {
Expand All @@ -406,10 +406,10 @@ nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUs
appHelperPath.AppendLiteral(" /SetAsDefaultAppUser");
}

STARTUPINFO si = {sizeof(si), 0};
STARTUPINFOW si = {sizeof(si), 0};
PROCESS_INFORMATION pi = {0};

BOOL ok = CreateProcess(NULL, (LPSTR)appHelperPath.get(), NULL, NULL,
BOOL ok = CreateProcessW(NULL, (LPWSTR)appHelperPath.get(), NULL, NULL,
FALSE, 0, NULL, NULL, &si, &pi);

if (!ok)
Expand Down
10 changes: 0 additions & 10 deletions db/mork/src/morkFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,16 +929,6 @@ morkStdioFile::Steal(nsIMdbEnv* ev, nsIMdbFile* ioThief)
void mork_fileflush(FILE * file)
{
fflush(file);
#ifndef WINCE
OSVERSIONINFOA vi = { sizeof(OSVERSIONINFOA) };
if ((GetVersionExA(&vi) && vi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS))
{
// Win9x/ME
int fd = fileno(file);
HANDLE fh = (HANDLE)_get_osfhandle(fd);
FlushFileBuffers(fh);
}
#endif
}

#endif /*MORK_WIN*/
Expand Down
3 changes: 1 addition & 2 deletions embedding/browser/activex/src/plugin/LegacyPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@ ShowError(MozAxPluginErrors errorCode, const CLSID &clsid)
LPOLESTR szClsid;
StringFromCLSID(clsid, &szClsid);
_sntprintf(szBuffer, kBufSize - 1,
_T("Could not create the control %s. Check that it has been installed on your computer "
"and that this page correctly references it."), OLE2T(szClsid));
_T("Could not create the control %s. Check that it has been installed on your computer and that this page correctly references it."), OLE2T(szClsid));
CoTaskMemFree(szClsid);
szMsg = szBuffer;
}
Expand Down
2 changes: 1 addition & 1 deletion embedding/browser/activex/src/plugin/XPCDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1915,7 +1915,7 @@ END_COM_MAP()
NS_SUCCEEDED(baseURI->GetSpec(spec)))
{
USES_CONVERSION;
if (FAILED(CreateURLMoniker(NULL, T2CW(spec.get()), &baseURLMoniker)))
if (FAILED(CreateURLMoniker(NULL, A2CW(spec.get()), &baseURLMoniker)))
return E_UNEXPECTED;
}
}
Expand Down
2 changes: 1 addition & 1 deletion embedding/browser/activex/src/plugin/XPConnect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ nsScriptablePeer::ConvertVariants(VARIANT *aIn, nsIVariant **aOut)
{
// do_CreateInstance macro is broken so load the component manager by
// hand and get it to create the component.
HMODULE hlib = ::LoadLibrary("xpcom.dll");
HMODULE hlib = ::LoadLibraryW(L"xpcom.dll");
if (hlib)
{
nsIComponentManager *pManager = nsnull; // A frozen interface, even in 1.0.x
Expand Down
34 changes: 16 additions & 18 deletions extensions/auth/nsAuthSSPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
#include "nsNetCID.h"
#include "nsCOMPtr.h"

#include <windows.h>

#define SEC_SUCCESS(Status) ((Status) >= 0)

#ifndef KERB_WRAP_NO_ENCRYPT
Expand Down Expand Up @@ -103,25 +105,25 @@ static const char *MapErrorCode(int rc)
//-----------------------------------------------------------------------------

static HINSTANCE sspi_lib;
static PSecurityFunctionTable sspi;
static PSecurityFunctionTableW sspi;

static nsresult
InitSSPI()
{
PSecurityFunctionTable (*initFun)(void);
PSecurityFunctionTableW (*initFun)(void);

LOG((" InitSSPI\n"));

sspi_lib = LoadLibrary("secur32.dll");
sspi_lib = LoadLibraryW(L"secur32.dll");
if (!sspi_lib) {
sspi_lib = LoadLibrary("security.dll");
sspi_lib = LoadLibraryW(L"security.dll");
if (!sspi_lib) {
LOG(("SSPI library not found"));
return NS_ERROR_UNEXPECTED;
}
}

initFun = (PSecurityFunctionTable (*)(void))
initFun = (PSecurityFunctionTableW (*)(void))
GetProcAddress(sspi_lib, "InitSecurityInterfaceA");
if (!initFun) {
LOG(("InitSecurityInterfaceA not found"));
Expand Down Expand Up @@ -242,11 +244,9 @@ nsAuthSSPI::Init(const char *serviceName,
if (NS_FAILED(rv))
return rv;
}
SEC_WCHAR *package;

SEC_CHAR *package;

package = (SEC_CHAR *) pTypeName[(int)mPackage];

package = (SEC_WCHAR *) pTypeName[(int)mPackage];
if (mPackage != PACKAGE_TYPE_NTLM)
{
rv = MakeSN(serviceName, mServiceName);
Expand All @@ -257,8 +257,8 @@ nsAuthSSPI::Init(const char *serviceName,

SECURITY_STATUS rc;

PSecPkgInfo pinfo;
rc = (sspi->QuerySecurityPackageInfo)(package, &pinfo);
PSecPkgInfoW pinfo;
rc = (sspi->QuerySecurityPackageInfoW)(package, &pinfo);
if (rc != SEC_E_OK) {
LOG(("%s package not found\n", package));
return NS_ERROR_UNEXPECTED;
Expand All @@ -268,7 +268,7 @@ nsAuthSSPI::Init(const char *serviceName,

TimeStamp useBefore;

rc = (sspi->AcquireCredentialsHandle)(NULL,
rc = (sspi->AcquireCredentialsHandleW)(NULL,
package,
SECPKG_CRED_OUTBOUND,
NULL,
Expand Down Expand Up @@ -336,15 +336,13 @@ nsAuthSSPI::GetNextToken(const void *inToken,
if (!ob.pvBuffer)
return NS_ERROR_OUT_OF_MEMORY;
memset(ob.pvBuffer, 0, ob.cbBuffer);

SEC_CHAR *sn;

SEC_WCHAR *sn;
if (mPackage == PACKAGE_TYPE_NTLM)
sn = NULL;
else
sn = (SEC_CHAR *) mServiceName.get();
sn = (SEC_WCHAR *) mServiceName.get();

rc = (sspi->InitializeSecurityContext)(&mCred,
rc = (sspi->InitializeSecurityContextW)(&mCred,
ctxIn,
sn,
ctxReq,
Expand Down Expand Up @@ -461,7 +459,7 @@ nsAuthSSPI::Wrap(const void *inToken,
secBuffers bufs;
SecPkgContext_Sizes sizes;

rc = (sspi->QueryContextAttributes)(
rc = (sspi->QueryContextAttributesW)(
&mCtxt,
SECPKG_ATTR_SIZES,
&sizes);
Expand Down
10 changes: 2 additions & 8 deletions gfx/src/thebes/nsSystemFontsWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,12 @@


nsresult nsSystemFontsWin::CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont,
nsString *aFontName,
gfxFontStyle *aFontStyle,
PRBool aIsWide) const
nsString *aFontName,
gfxFontStyle *aFontStyle) const
{
PRUnichar name[LF_FACESIZE];
name[0] = 0;
if (aIsWide)
memcpy(name, ptrLogFont->lfFaceName, LF_FACESIZE*2);
else {
MultiByteToWideChar(CP_ACP, 0, ptrLogFont->lfFaceName,
strlen(ptrLogFont->lfFaceName) + 1, name, sizeof(name)/sizeof(name[0]));
}
*aFontName = name;

// Do Style
Expand Down
3 changes: 1 addition & 2 deletions gfx/src/thebes/nsSystemFontsWin.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class nsSystemFontsWin
gfxFontStyle *aFontStyle) const;
private:
nsresult CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont,
nsString *aFontName, gfxFontStyle *aFontStyle,
PRBool aIsWide = PR_FALSE) const;
nsString *aFontName, gfxFontStyle *aFontStyle) const;
nsresult GetSysFontInfo(HDC aHDC, nsSystemFontID anID,
nsString *aFontName,
gfxFontStyle *aFontStyle) const;
Expand Down
2 changes: 1 addition & 1 deletion gfx/src/windows/nsDeviceContextWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ NS_IMETHODIMP nsDeviceContextWin :: SetCanonicalPixelScale(float aScale)


nsresult nsDeviceContextWin::CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont,
nsFont* aFont, PRBool aIsWide) const
nsFont* aFont) const
{
PRUnichar name[LF_FACESIZE];
name[0] = 0;
Expand Down
3 changes: 1 addition & 2 deletions gfx/src/windows/nsDeviceContextWin.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ friend class nsNativeThemeWin;
void ComputeFullAreaUsingScreen ( nsRect* outRect ) ;
nsresult GetSysFontInfo(HDC aHDC, nsSystemFontID anID, nsFont* aFont) const;

nsresult CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont, nsFont* aFont,
PRBool aIsWide = PR_FALSE) const;
nsresult CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogFont, nsFont* aFont) const;

PRBool mCachedClientRect;
PRBool mCachedFullRect;
Expand Down
31 changes: 0 additions & 31 deletions gfx/src/windows/nsFontMetricsWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2121,40 +2121,9 @@ nsGlyphAgent::GetGlyphMetrics(HDC aDC,
GLYPHMETRICS* aGlyphMetrics)
{
memset(aGlyphMetrics, 0, sizeof(GLYPHMETRICS)); // UMR: bug 46438
if (eGlyphAgent_UNKNOWN == mState) { // first time we have been in this function
// see if this platform implements GetGlyphOutlineW()
DWORD len = GetGlyphOutlineW(aDC, aChar, GGO_METRICS, aGlyphMetrics, 0, nsnull, &mMat);
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
// next time, we won't bother trying GetGlyphOutlineW()
mState = eGlyphAgent_ANSI;
}
else {
// all is well with GetGlyphOutlineW(), we will be using it from now on
mState = eGlyphAgent_UNICODE;
return len;
}
}

if (eGlyphAgent_UNICODE == mState) {
return GetGlyphOutlineW(aDC, aChar, GGO_METRICS, aGlyphMetrics, 0, nsnull, &mMat);
}

// Otherwise, we are on a platform that doesn't implement GetGlyphOutlineW()
// (see Q241358: The GetGlyphOutlineW Function Fails on Windows 95 & 98
// http://support.microsoft.com/support/kb/articles/Q241/3/58.ASP)
// we will use glyph indices as a work around.
if (0 == aGlyphIndex) { // caller doesn't know the glyph index, so find it
nsAutoChar16Buffer buf;
if (NS_SUCCEEDED(GetGlyphIndices(aDC, nsnull, &aChar, 1, buf)))
aGlyphIndex = *(buf.Elements());
}
if (0 < aGlyphIndex) {
return GetGlyphOutlineA(aDC, aGlyphIndex, GGO_METRICS | GGO_GLYPH_INDEX, aGlyphMetrics, 0, nsnull, &mMat);
}

// if we ever reach here, something went wrong in GetGlyphIndices() above
// because the current font in aDC wasn't a Unicode font
return GDI_ERROR;
}

// the global glyph agent that we will be using
Expand Down
4 changes: 2 additions & 2 deletions gfx/thebes/src/gfxWindowsFonts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,13 @@ gfxWindowsFont::ComputeMetrics()

// Cache the width of a single space.
SIZE size;
GetTextExtentPoint32(dc, " ", 1, &size);
GetTextExtentPoint32W(dc, L" ", 1, &size);
mMetrics->spaceWidth = ROUND(size.cx);

mSpaceGlyph = 0;
if (metrics.tmPitchAndFamily & TMPF_TRUETYPE) {
WORD glyph;
DWORD ret = GetGlyphIndicesA(dc, " ", 1, &glyph,
DWORD ret = GetGlyphIndicesW(dc, L" ", 1, &glyph,
GGI_MARK_NONEXISTING_GLYPHS);
if (ret != GDI_ERROR && glyph != 0xFFFF) {
mSpaceGlyph = glyph;
Expand Down
Loading

0 comments on commit ac3bb05

Please sign in to comment.