PR comments/fixes

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
monroegm-disable-blank-issue-2
Esteban Papp 4 years ago
parent 9bab676109
commit 9a82005cb8

@ -58,15 +58,15 @@ namespace AZStd
}
}
static inline void to_string(char* dest, size_t destSize, const wchar_t* first, const wchar_t* last)
static inline char* to_string(char* dest, size_t destSize, const wchar_t* first, const wchar_t* last)
{
if constexpr (Size == 2)
{
Utf8::Unchecked::utf16to8(first, last, dest, destSize);
return Utf8::Unchecked::utf16to8(first, last, dest, destSize);
}
else if constexpr (Size == 4)
{
Utf8::Unchecked::utf32to8(first, last, dest, destSize);
return Utf8::Unchecked::utf32to8(first, last, dest, destSize);
}
}
@ -96,15 +96,15 @@ namespace AZStd
}
}
static inline void to_wstring(wchar_t* dest, size_t destSize, const char* first, const char* last)
static inline wchar_t* to_wstring(wchar_t* dest, size_t destSize, const char* first, const char* last)
{
if constexpr (Size == 2)
{
Utf8::Unchecked::utf8to16(first, last, dest, destSize);
return Utf8::Unchecked::utf8to16(first, last, dest, destSize);
}
else if constexpr (Size == 4)
{
Utf8::Unchecked::utf8to32(first, last, dest, destSize);
return Utf8::Unchecked::utf8to32(first, last, dest, destSize);
}
}
};
@ -337,7 +337,11 @@ namespace AZStd
if (srcLen > 0)
{
Internal::WCharTPlatformConverter<>::to_string(dest, destSize, str, str + srcLen + 1); // copy null terminator
char* endStr = Internal::WCharTPlatformConverter<>::to_string(dest, destSize, str, str + srcLen);
if (*(endStr - 1) != '\0')
{
*endStr = '\0'; // copy null terminator
}
}
}
@ -485,12 +489,16 @@ namespace AZStd
{
if (srcLen == 0)
{
srcLen = strlen(str) + 1;
srcLen = strlen(str);
}
if (srcLen > 0)
{
Internal::WCharTPlatformConverter<>::to_wstring(dest, destSize, str, str + srcLen + 1); // copy null terminator
wchar_t* endWStr = Internal::WCharTPlatformConverter<>::to_wstring(dest, destSize, str, str + srcLen);
if (*(endWStr - 1) != '\0')
{
*endWStr = '\0'; // copy null terminator
}
}
}

@ -30,7 +30,7 @@ namespace AZ
result.m_pathIncludesFilename = true;
// Platform specific get exe path: http://stackoverflow.com/a/1024937
// https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamea
wchar_t pathBufferW[AZ_MAX_PATH_LEN] = { 0 };
wchar_t pathBufferW[AZ::IO::MaxPathLength] = { 0 };
const DWORD pathLen = GetModuleFileNameW(nullptr, pathBufferW, static_cast<DWORD>(exeStorageSize));
const DWORD errorCode = GetLastError();
if (pathLen == exeStorageSize && errorCode == ERROR_INSUFFICIENT_BUFFER)

@ -15,7 +15,7 @@ namespace AZ
{
namespace Platform
{
void OutputToDebugger(const char* title, const char* message)
void OutputToDebugger([[maybe_unused]] const char* title, [[maybe_unused]] const char* message)
{
// std::cout << title << ": " << message;
}

@ -703,7 +703,7 @@ namespace UnitTest
AZ_TEST_ASSERT(0 == azwcsicmp(wstrBuffer, L"BlaBla 5"));
// char buffer to wchar_t buffer
memset(wstrBuffer, 0, AZ_ARRAY_SIZE(wstrBuffer));
memset(wstrBuffer, L' ', AZ_ARRAY_SIZE(wstrBuffer)); // to check that the null terminator is properly placed
to_wstring(wstrBuffer, 9, strBuffer);
AZ_TEST_ASSERT(0 == azwcsicmp(wstrBuffer, L"BLABLA 5"));

Loading…
Cancel
Save