mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-12-25 16:37:42 +01:00
Merge branch 'master' of https://github.com/CloverHackyColor/CloverBootloader
This commit is contained in:
commit
fab5d07b37
@ -102,7 +102,7 @@ typedef struct PrintfParams {
|
||||
|
||||
|
||||
#if PRINTF_UTF8_OUTPUT_SUPPORT == 1
|
||||
// Print a char as is. Not analyse is made to check if it's a utf8 partial char
|
||||
// Print a char as is. No analyse is made to check if it's a utf8 partial char
|
||||
// c is an int for prototype compatibility, but must be < 255
|
||||
static void print_char(int c, PrintfParams* printfParams)
|
||||
{
|
||||
@ -167,6 +167,9 @@ static void print_wchar(int c, PrintfParams* printfParams)
|
||||
*printfParams->newlinePtr = 0; // to do BEFORE call to printTimeStamp
|
||||
if ( printfParams->timestamp ) print_timestamp(printfParams);
|
||||
}
|
||||
#if PRINTF_EMIT_CR == 1
|
||||
if ( c == '\n' ) print_wchar('\r', printfParams);
|
||||
#endif
|
||||
#if PRINTF_LITE_BUF_SIZE > 1
|
||||
printfParams->buf.wbuf[(printfParams->bufIdx)++] = (wchar_t)c;
|
||||
#else
|
||||
@ -176,6 +179,9 @@ static void print_wchar(int c, PrintfParams* printfParams)
|
||||
*printfParams->newlinePtr = 1;
|
||||
}
|
||||
}else{
|
||||
#if PRINTF_EMIT_CR == 1
|
||||
if ( c == '\n' ) print_wchar('\r', printfParams);
|
||||
#endif
|
||||
#if PRINTF_LITE_BUF_SIZE > 1
|
||||
printfParams->buf.wbuf[(printfParams->bufIdx)++] = (wchar_t)c;
|
||||
#else
|
||||
@ -184,6 +190,9 @@ static void print_wchar(int c, PrintfParams* printfParams)
|
||||
}
|
||||
#else
|
||||
{
|
||||
#if PRINTF_EMIT_CR == 1
|
||||
if ( c == '\n' ) print_wchar('\r', printfParams);
|
||||
#endif
|
||||
#if PRINTF_LITE_BUF_SIZE > 1
|
||||
printfParams->buf.wbuf[(printfParams->bufIdx)++] = (wchar_t)c; // cast suposed to be safe, as this function must be called
|
||||
#else
|
||||
|
@ -33,7 +33,7 @@ const XString NullXString;
|
||||
|
||||
void XString::Init(xsize aSize)
|
||||
{
|
||||
m_data = (char*)malloc( (aSize+1)*sizeof(char) ); /* le 0 terminal n'est pas compté dans mSize */
|
||||
m_data = (char*)malloc( (aSize+1)*sizeof(char) ); /* le 0 terminal n'est pas compté dans m_allocatedSize */
|
||||
if ( !m_data ) {
|
||||
DebugLog(2, "XString::Init(%llu) : Xalloc returned NULL. Cpu halted\n", (aSize+1)*sizeof(char));
|
||||
panic();
|
||||
@ -51,7 +51,7 @@ XString::XString()
|
||||
XString::~XString()
|
||||
{
|
||||
//Debugf("Destructeur :%s\n", c);
|
||||
delete m_data;
|
||||
delete m_data; // delete nullptr do nothing
|
||||
}
|
||||
|
||||
void XString::setLength(xsize len)
|
||||
@ -67,7 +67,7 @@ char *XString::CheckSize(xsize nNewSize, xsize nGrowBy)
|
||||
{
|
||||
|
||||
nNewSize += nGrowBy;
|
||||
m_data = (char*)realloc(m_data, (nNewSize+1)*sizeof(char), m_allocatedSize*sizeof(wchar_t));
|
||||
m_data = (char*)realloc(m_data, (nNewSize+1)*sizeof(char), m_allocatedSize*sizeof(wchar_t)); // realloc is identical to malloc if m_data is NULL
|
||||
if ( !m_data ) {
|
||||
DBG("XString::CheckSize(%d, %d) : Xrealloc(%d, %d, %d) returned NULL. System halted\n", nNewSize, nGrowBy, m_size, (nNewSize+1)*sizeof(char), c);
|
||||
panic();
|
||||
@ -349,6 +349,14 @@ XString::XString(const XString &aString)
|
||||
StrnCpy(aString.data(), aString.length());
|
||||
}
|
||||
|
||||
XString::XString(XString&& aString) // Move constructor
|
||||
{
|
||||
m_data = aString.m_data;
|
||||
m_allocatedSize = aString.m_allocatedSize;
|
||||
aString.m_data = 0;
|
||||
aString.m_allocatedSize = 0;
|
||||
}
|
||||
|
||||
//// Deactivate assignment during refactoring to avoid confusion
|
||||
//XString::XString(const wchar_t *S)
|
||||
//{
|
||||
@ -828,23 +836,16 @@ const XString &XString::operator =(const XString &aString)
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef __AFXWIN_H__
|
||||
const XString &XString::operator =(const CString &aCString)
|
||||
XString& XString::operator =(XString&& aString)
|
||||
{
|
||||
//TRACE("Operator =const CString&\n");
|
||||
StrnCpy(aCString, aCString.GetLength());
|
||||
delete m_data; // delete does nothing if m_data is NULL
|
||||
m_data = aString.m_data;
|
||||
m_allocatedSize = aString.m_allocatedSize;
|
||||
aString.m_data = 0;
|
||||
aString.m_allocatedSize = 0;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WX_WXSTRINGH__
|
||||
const XString &XString::operator =(const wxString &awxString)
|
||||
{
|
||||
//TRACE("Operator =const wxString&\n");
|
||||
StrnCpy(awxString.mb_str(), awxString.length());
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
//
|
||||
//const XString &XString::operator =(const XConstString &aConstString)
|
||||
//{
|
||||
@ -1082,7 +1083,7 @@ XString ToUpper(const char *S)
|
||||
}
|
||||
#endif
|
||||
|
||||
// Deactivate assignment during refactoring to avoid confusion
|
||||
// Deactivate during refactoring to avoid confusion
|
||||
//XString CleanCtrl(const XString &S)
|
||||
//{
|
||||
// XString ReturnValue;
|
||||
|
@ -43,6 +43,8 @@ class XString
|
||||
void Init(xsize aSize=0);
|
||||
XString();
|
||||
XString(const XString &aString);
|
||||
XString(XString&& aString); // Move constructor
|
||||
|
||||
|
||||
// XString(const XConstString &aConstString);
|
||||
// XString(const char *S);
|
||||
@ -124,7 +126,8 @@ class XString
|
||||
const XString& takeValueFrom(const char* S, xsize count) { StrnCpy(S, count); return *this; }
|
||||
const XString& takeValueFrom(const wchar_t* S) { SPrintf("%ls", S); return *this; }
|
||||
|
||||
const XString &operator =(const XString &aString);
|
||||
const XString& operator =(const XString& aString);
|
||||
XString& operator =(XString&& aString);
|
||||
// const XString &operator =(const XConstString &aConstString);
|
||||
|
||||
// Deactivate assignment during refactoring to avoid confusion
|
||||
@ -226,7 +229,9 @@ class XString
|
||||
// OpÈrateur +
|
||||
// Chaines
|
||||
friend XString operator + (const XString& p1, const XString& p2) { XString s; s=p1; s+=p2; return s; }
|
||||
friend XString operator + (const XString& p1, const char *p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
// friend XString operator + (const XString& p1, const char *p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
XString operator + (const char *p2 ) { XString s(*this); s+=p2; return s; }
|
||||
|
||||
friend XString operator + (const char *p1, const XString& p2) { XString s; s.takeValueFrom(p1); s+=p2; return s; }
|
||||
// friend XString operator + (const XConstString& p1, const XString& p2) { XString s; s=p1; s+=p2; return s; }
|
||||
// friend XString operator + (const XString& p1, const XConstString& p2) { XString s; s=p1; s+=p2; return s; }
|
||||
|
@ -4,12 +4,13 @@
|
||||
#include "global_test.h"
|
||||
|
||||
|
||||
//#include <wchar.h>
|
||||
|
||||
|
||||
int XString_tests()
|
||||
{
|
||||
|
||||
#ifdef JIEF_DEBUG
|
||||
#endif
|
||||
|
||||
#ifdef JIEF_DEBUG
|
||||
// DebugLog(2, "XStringW_tests -> Enter\n");
|
||||
#endif
|
||||
@ -48,6 +49,19 @@ int XString_tests()
|
||||
}
|
||||
#endif
|
||||
|
||||
// Move assignment.
|
||||
{
|
||||
XString str1;
|
||||
str1.takeValueFrom("str1");
|
||||
XString str2(str1 + "b");
|
||||
str2 += "a"; // this is more efficient than str2 = str2 + "a", of course
|
||||
if ( str2 != "str1ba" ) return 120;
|
||||
str2 = str2 + "a";
|
||||
if ( str2 != "str1baa" ) return 121;
|
||||
str2 = str1 + "a"; // this must call the move assignment operator
|
||||
if ( str2 != "str1a" ) return 122;
|
||||
}
|
||||
|
||||
// check [] operator
|
||||
{
|
||||
XString str;
|
||||
|
Loading…
Reference in New Issue
Block a user