Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/coreclr/debug/daccess/inspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1047,8 +1047,8 @@ ClrDataValue::GetString(
{
*strLen = static_cast<ULONG32>(u16_strlen(msgStr) + 1);
}
status = StringCchCopy(str, bufLen, msgStr) == S_OK ?
S_OK : S_FALSE;

status = u16_strcpy_s(str, bufLen, msgStr) != NULL ? S_OK : S_FALSE;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/daccess/stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ ClrDataFrame::GetArgumentByIndex(
*nameLen = 5;
}

StringCchCopy(name, bufLen, W("this"));
u16_strcpy_s(name, bufLen, W("this"));
}
else
{
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/debug/daccess/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@
#include "dacimpl.h"


#define STRSAFE_NO_DEPRECATE
#include <strsafe.h>
#undef _ftcscat
#undef _ftcscpy

// from ntstatus.h
#define STATUS_STOWED_EXCEPTION ((NTSTATUS)0xC000027BL)

Expand Down
5 changes: 2 additions & 3 deletions src/coreclr/debug/daccess/task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,7 @@ ClrDataAppDomain::GetName(
}
else
{
status = StringCchCopy(name, bufLen, (PCWSTR)rawName) == S_OK ?
S_OK : S_FALSE;
status = u16_strcpy_s(name, bufLen, (PCWSTR)rawName) != NULL ? S_OK : S_FALSE;
if (nameLen)
{
size_t cchName = u16_strlen((PCWSTR)rawName) + 1;
Expand Down Expand Up @@ -4763,7 +4762,7 @@ ClrDataExceptionState::GetString(
message->GetStringLength(),
true);

status = StringCchCopy(str, bufLen, msgStr) == S_OK ? S_OK : S_FALSE;
status = u16_strcpy_s(str, bufLen, msgStr) != NULL ? S_OK : S_FALSE;
if (strLen != NULL)
{
size_t cchName = u16_strlen(msgStr) + 1;
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/dlls/mscordac/mscordac_unixexports.src
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ nativeStringResourceTable_mscorrc
#PAL_wcscat
#PAL_wcsstr

#minipal_get_length_utf16_to_utf8
#minipal_convert_utf16_to_utf8

#_wcsicmp
#sprintf_s
#vsprintf_s
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/ilasm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "clrversion.h"
#include "shimload.h"

#include "strsafe.h"
#define ASSERTE_ALL_BUILDS(expr) _ASSERTE_ALL_BUILDS((expr))

WCHAR* EqualOrColon(_In_ __nullterminated WCHAR* szArg)
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/inc/clr/fs/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

#include "clrtypes.h"

#include "strsafe.h"

#include "clr/str.h"

namespace clr
Expand Down
72 changes: 23 additions & 49 deletions src/coreclr/inc/corhlprpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define __CORHLPRPRIV_H__

#include "corhlpr.h"
#include "fstring.h"
#include <minipal/utf8.h>

#if defined(_MSC_VER) && defined(HOST_X86)
#pragma optimize("y", on) // If routines don't get inlined, don't pay the EBP frame penalty
Expand Down Expand Up @@ -225,71 +225,45 @@ class CQuickMemoryBase
iSize = cbTotal;
}


// Convert UTF8 string to UNICODE string, optimized for speed
HRESULT ConvertUtf8_UnicodeNoThrow(const char * utf8str)
{
bool allAscii;
DWORD length;

HRESULT hr = FString::Utf8_Unicode_Length(utf8str, & allAscii, & length);

if (SUCCEEDED(hr))
{
LPWSTR buffer = (LPWSTR) AllocNoThrow((length + 1) * sizeof(WCHAR));

if (buffer == NULL)
{
hr = E_OUTOFMEMORY;
}
else
{
hr = FString::Utf8_Unicode(utf8str, allAscii, buffer, length);
}
}

return hr;
}

// Convert UTF8 string to UNICODE string, optimized for speed
void ConvertUtf8_Unicode(const char * utf8str)
{
bool allAscii;
DWORD length;

HRESULT hr = FString::Utf8_Unicode_Length(utf8str, & allAscii, & length);

if (SUCCEEDED(hr))
size_t sourceLen = 0;
size_t destLen = 0;
if (utf8str != NULL)
{
LPWSTR buffer = (LPWSTR) AllocThrows((length + 1) * sizeof(WCHAR));

hr = FString::Utf8_Unicode(utf8str, allAscii, buffer, length);
sourceLen = strlen(utf8str) + 1;
destLen = minipal_get_length_utf8_to_utf16(utf8str, sourceLen, /* flags */ 0);
}

if (FAILED(hr))
CHAR16_T* buffer = (CHAR16_T*) AllocThrows((destLen + 1) * sizeof(CHAR16_T));
buffer[destLen] = W('\0');

if (destLen > 0
&& !minipal_convert_utf8_to_utf16(utf8str, sourceLen, buffer, destLen, /* flags */ 0))
{
ThrowHR(hr);
ThrowHR(EMAKEHR(errno));
}
}

// Convert UNICODE string to UTF8 string, optimized for speed
void ConvertUnicode_Utf8(const WCHAR * pString)
{
bool allAscii;
DWORD length;

HRESULT hr = FString::Unicode_Utf8_Length(pString, & allAscii, & length);

if (SUCCEEDED(hr))
size_t sourceLen = 0;
size_t destLen = 0;
if (pString != NULL)
{
LPSTR buffer = (LPSTR) AllocThrows((length + 1) * sizeof(char));

hr = FString::Unicode_Utf8(pString, allAscii, buffer, length);
sourceLen = u16_strlen(pString) + 1;
destLen = minipal_get_length_utf16_to_utf8((const CHAR16_T*)pString, sourceLen, /* flags */ 0);
}

if (FAILED(hr))
LPSTR buffer = (LPSTR) AllocThrows((destLen + 1) * sizeof(char));
buffer[destLen] = '\0';

if (destLen > 0
&& !minipal_convert_utf16_to_utf8((const CHAR16_T*)pString, sourceLen, buffer, destLen, /* flags */ 0))
{
ThrowHR(hr);
ThrowHR(EMAKEHR(errno));
}
}

Expand Down
44 changes: 0 additions & 44 deletions src/coreclr/inc/fstring.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/coreclr/inc/sstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ class EMPTY_BASES_DECL SString : private SBuffer

// Converts/copies into the given output string
void ConvertToUnicode(SString &dest) const;
COUNT_T ConvertToUTF8(SString &dest) const;
void ConvertToUTF8(SString &dest) const;

//-------------------------------------------------------------------
// Accessing the string contents directly
Expand Down
21 changes: 0 additions & 21 deletions src/coreclr/inc/utilcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -2834,27 +2834,6 @@ template <class T> class CChainedHash
};


//*****************************************************************************
//
//********** String helper functions.
//
//*****************************************************************************

//*****************************************************************************
// Checks if string length exceeds the specified limit
//*****************************************************************************
inline BOOL IsStrLongerThan(_In_ _In_z_ char* pstr, unsigned N)
{
LIMITED_METHOD_CONTRACT;
unsigned i = 0;
if(pstr)
{
for(i=0; (i < N)&&(pstr[i]); i++);
}
return (i >= N);
}


//*****************************************************************************
// Class to parse a list of simple assembly names and then find a match
//*****************************************************************************
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/minipal/Unix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ if(NOT CLR_CROSS_COMPONENTS_BUILD)
list(APPEND SOURCES
${CLR_SRC_NATIVE_DIR}/minipal/cpufeatures.c
)

if(CLR_CMAKE_HOST_OSX)
list(APPEND SOURCES
${CLR_SRC_NATIVE_DIR}/minipal/utf8.c
)
endif()
endif()

add_library(coreclrminipal
Expand Down
Loading