mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
Bug 944905 - Fix char16_t/wchar_t mismatch in xpcom/ r=bsmedberg
This commit is contained in:
parent
545f16470c
commit
40790e8807
@ -333,7 +333,7 @@ nsWindowsRegKey::ReadStringValue(const nsAString &name, nsAString &result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
resultLen = ExpandEnvironmentStringsW(flatSource.get(),
|
||||
begin.get(),
|
||||
wwc(begin.get()),
|
||||
resultLen + 1);
|
||||
if (resultLen <= 0) {
|
||||
rv = ERROR_UNKNOWN_FEATURE;
|
||||
|
@ -513,9 +513,7 @@ static int cvt_S(SprintfState *ss, const char16_t *s, int width,
|
||||
}
|
||||
|
||||
/* and away we go */
|
||||
NS_NAMED_LITERAL_STRING(nullstr, "(null)");
|
||||
|
||||
return fill2(ss, s ? s : nullstr.get(), slen, width, flags);
|
||||
return fill2(ss, s ? s : MOZ_UTF16("(null)"), slen, width, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -100,7 +100,7 @@ struct NS_COM_GLUE VersionW
|
||||
{
|
||||
VersionW(const char16_t *versionStringW)
|
||||
{
|
||||
versionContentW = wcsdup(versionStringW);
|
||||
versionContentW = reinterpret_cast<char16_t*>(wcsdup(char16ptr_t(versionStringW)));
|
||||
}
|
||||
|
||||
const char16_t* ReadContentW() const
|
||||
|
@ -1021,7 +1021,7 @@ nsLocalFile::ResolveShortcut()
|
||||
if (mResolvedPath.Length() != MAX_PATH)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
char16_t *resolvedPath = mResolvedPath.BeginWriting();
|
||||
wchar_t *resolvedPath = wwc(mResolvedPath.BeginWriting());
|
||||
|
||||
// resolve this shortcut
|
||||
nsresult rv = gResolver->Resolve(mWorkingPath.get(), resolvedPath);
|
||||
@ -1256,7 +1256,7 @@ nsLocalFile::Create(uint32_t type, uint32_t attributes)
|
||||
// Skip the first 'X:\' for the first form, and skip the first full
|
||||
// '\\machine\volume\' segment for the second form.
|
||||
|
||||
char16_t* path = mResolvedPath.BeginWriting();
|
||||
wchar_t* path = wwc(mResolvedPath.BeginWriting());
|
||||
|
||||
if (path[0] == L'\\' && path[1] == L'\\')
|
||||
{
|
||||
@ -3446,7 +3446,7 @@ nsresult nsDriveEnumerator::Init()
|
||||
/* The string is null terminated */
|
||||
if (!mDrives.SetLength(length+1, fallible_t()))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (!GetLogicalDriveStringsW(length, mDrives.BeginWriting()))
|
||||
if (!GetLogicalDriveStringsW(length, wwc(mDrives.BeginWriting())))
|
||||
return NS_ERROR_FAILURE;
|
||||
mDrives.BeginReading(mStartOfCurrentDrive);
|
||||
mDrives.EndReading(mEndOfDrivesString);
|
||||
|
@ -901,7 +901,7 @@ NS_CopyNativeToUnicode(const nsACString &input, nsAString &output)
|
||||
|
||||
char16_t *result = out_iter.get();
|
||||
|
||||
::MultiByteToWideChar(CP_ACP, 0, buf, inputLen, result, resultLen);
|
||||
::MultiByteToWideChar(CP_ACP, 0, buf, inputLen, wwc(result), resultLen);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -947,7 +947,7 @@ NS_CopyUnicodeToNative(const nsAString &input, nsACString &output)
|
||||
int32_t
|
||||
NS_ConvertAtoW(const char *aStrInA, int aBufferSize, char16_t *aStrOutW)
|
||||
{
|
||||
return MultiByteToWideChar(CP_ACP, 0, aStrInA, -1, aStrOutW, aBufferSize);
|
||||
return MultiByteToWideChar(CP_ACP, 0, aStrInA, -1, wwc(aStrOutW), aBufferSize);
|
||||
}
|
||||
|
||||
int32_t
|
||||
|
@ -183,6 +183,30 @@ class NS_ConvertUTF8toUTF16 : public nsAutoString
|
||||
};
|
||||
|
||||
|
||||
#ifdef MOZ_USE_CHAR16_WRAPPER
|
||||
|
||||
inline char16_t*
|
||||
wwc(wchar_t *str)
|
||||
{
|
||||
return reinterpret_cast<char16_t*>(str);
|
||||
}
|
||||
|
||||
inline wchar_t*
|
||||
wwc(char16_t *str)
|
||||
{
|
||||
return reinterpret_cast<wchar_t*>(str);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline char16_t*
|
||||
wwc(char16_t *str)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// the following are included/declared for backwards compatibility
|
||||
typedef nsAutoString nsVoidableString;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user