Improve some messages.

unicode_conversions version.
This commit is contained in:
jief666 2021-04-21 08:32:38 +03:00
parent e9d0f08c8e
commit a1a27d29a1
6 changed files with 399 additions and 83 deletions

View File

@ -478,15 +478,18 @@ UINT16 getDDRspeedMhz(UINT8 * spd)
MsgLog("Found module with XMP version %d.%d\n", (xmpVersion >> 4) & 0xF, xmpVersion & 0xF);
switch (gSettings.Boot.XMPDetection) {
case -1:
MsgLog("XMPDetection deactivated in config.plist\n");
break;
case 0:
// Detect the better XMP profile
if (xmpFrequency1 >= xmpFrequency2) {
if (xmpFrequency1 >= frequency) {
DBG("Using XMP Profile1 instead of standard frequency %dMHz\n", frequency);
MsgLog("Using XMP Profile1 instead of standard frequency %dMHz\n", frequency);
frequency = xmpFrequency1;
}
} else if (xmpFrequency2 >= frequency) {
DBG("Using XMP Profile2 instead of standard frequency %dMHz\n", frequency);
MsgLog("Using XMP Profile2 instead of standard frequency %dMHz\n", frequency);
frequency = xmpFrequency2;
}
break;
@ -495,9 +498,9 @@ UINT16 getDDRspeedMhz(UINT8 * spd)
// Use first profile if present
if ((xmpProfiles & 1) == 1) {
frequency = xmpFrequency1;
DBG("Using XMP Profile1 instead of standard frequency %dMHz\n", frequency);
MsgLog("Using XMP Profile1 instead of standard frequency %dMHz\n", frequency);
} else {
DBG("Not using XMP Profile1 because it is not present\n");
MsgLog("Not using XMP Profile1 because it is not present\n");
}
break;
@ -505,28 +508,34 @@ UINT16 getDDRspeedMhz(UINT8 * spd)
// Use second profile
if ((xmpProfiles & 2) == 2) {
frequency = xmpFrequency2;
DBG("Using XMP Profile2 instead of standard frequency %dMHz\n", frequency);
MsgLog("Using XMP Profile2 instead of standard frequency %dMHz\n", frequency);
} else {
DBG("Not using XMP Profile2 because it is not present\n");
MsgLog("Not using XMP Profile2 because it is not present\n");
}
break;
default:
MsgLog("XMPDetection invalid value '%d' in config.plist\n", gSettings.Boot.XMPDetection);
break;
}
} else {
// Print out XMP not detected
switch (gSettings.Boot.XMPDetection) {
case -1:
MsgLog("XMP is not present, XMPDetection deactivated in config.plist\n");
break;
case 0:
DBG("Not using XMP because it is not present\n");
MsgLog("Not using XMP because it is not present\n");
break;
case 1:
case 2:
DBG("Not using XMP Profile%d because it is not present\n", gSettings.Boot.XMPDetection);
MsgLog("Not using XMP Profile%d because it is not present\n", gSettings.Boot.XMPDetection);
break;
default:
MsgLog("XMP is not present, XMPDetection has invalid value '%d' config.plist, \n", gSettings.Boot.XMPDetection);
break;
}
}

View File

@ -1,8 +1,10 @@
//
// unicode_conversions.cpp
//
// Created by jief the 24 Feb 2020.
//
/*
* unicode_conversions.cpp
*
* Created by jief the 24 Feb 2020.
*
* version 1.0
*/
#include "unicode_conversions.h"
#include <string.h>
@ -109,6 +111,7 @@ const char32_t* utf8_size_of_utf32_char_ptr(const char32_t *s, size_t* size)
* Store an utf32 char in dst, if there is enough room (dst_max_size is >= size of converted utf32 char)
* If there is enough room, dst_max_size is decrement and dst is increment and returned
* If there isn't enough room, dst_max_size is set to 0 and dst is returned
* if utf32_char == 0, it IS sent to dst
*/
char* get_utf8_from_char32(char* dst, size_t* dst_max_size, char32_t utf32_char)
{
@ -401,6 +404,29 @@ size_t utf32_string_from_utf8_string_len(char32_t* dst, size_t dst_max_size, con
return (size_t)(p-dst);
}
size_t utf32_string_from_utf8_string_size(char32_t* dst, size_t dst_max_size, const char* s, size_t size)
{
if ( dst_max_size == 0 ) return 0;
if ( !s || size == 0 ) {
*dst = 0;
return 0;
}
char32_t* p = dst;
dst_max_size -= 1;
const char* s_start = s;
char32_t* p_max = dst + dst_max_size;
char32_t char32;
s = get_char32_from_utf8_string(s, &char32);
while ( char32 && p < p_max && (uintptr_t)(s - s_start) <= size ) {
*p++ = char32;
s = get_char32_from_utf8_string(s, &char32);
}
*p = 0;
return (size_t)(p-dst);
}
size_t utf8_stringnn_from_utf32_string(char* dst, size_t dst_max_size, const char32_t *s)
{
if ( dst_max_size <= 0 ) return 0;
@ -460,6 +486,25 @@ size_t utf8_string_from_utf32_string_len(char* dst, size_t dst_max_size, const c
return (size_t)(p-dst);
}
size_t utf8_string_from_utf32_string_size(char* dst, size_t dst_max_size, const char32_t *s, size_t size)
{
if ( dst_max_size <= 0 ) return 0;
if ( !s || size <= 0 ) {
*dst = 0;
return 0;
}
dst_max_size -= 1;
const char32_t* s_start = s;
char* p = dst;
while ( *s && dst_max_size > 0 && (uintptr_t)(s - s_start) < size ) {
p = get_utf8_from_char32(p, &dst_max_size, *s++);
}
*p = 0;
return (size_t)(p-dst);
}
/*
* get nth char32 of an utf8 string
* Return value : pointer to the end of string or at the error
@ -599,15 +644,15 @@ size_t utf8_string_from_utf16_string(char* dst, size_t dst_max_size, const char1
size_t utf8_string_from_utf16_string_len(char* dst, size_t dst_max_size, const char16_t *s, size_t len)
{
if ( dst_max_size <= 0 ) return 0;
if ( !s || len <= 0 ) {
*dst = 0;
return 0;
}
if ( dst_max_size == 0 ) return 0;
if ( dst_max_size == 1 || !s || len <= 0 ) {
*dst = 0;
return 0;
}
char* p = dst;
dst_max_size -= 1;
char32_t utf32_char;
while ( *s && dst_max_size > 0 && len > 0 ) {
char32_t utf32_char;
s = get_char32_from_utf16_string(s, &utf32_char);
p = get_utf8_from_char32(p, &dst_max_size, utf32_char);
len--;
@ -616,6 +661,26 @@ size_t utf8_string_from_utf16_string_len(char* dst, size_t dst_max_size, const c
return (size_t)(p-dst);
}
size_t utf8_string_from_utf16_string_size(char* dst, size_t dst_max_size, const char16_t *s, size_t size)
{
if ( dst_max_size == 0 ) return 0;
if ( dst_max_size == 1 || !s || size <= 0 ) {
*dst = 0;
return 0;
}
char* p = dst;
dst_max_size -= 1;
const char16_t* s_start = s;
char32_t char32;
s = get_char32_from_utf16_string(s, &char32);
while ( char32 && dst_max_size > 0 && (uintptr_t)(s - s_start) <= size ) {
p = get_utf8_from_char32(p, &dst_max_size, char32);
s = get_char32_from_utf16_string(s, &char32);
}
*p = 0;
return (size_t)(p-dst);
}
size_t utf16_stringnn_from_utf8_string(char16_t* dst, size_t dst_max_size, const char* s)
{
@ -700,22 +765,19 @@ size_t utf16_string_from_utf8_string_len(char16_t* dst, size_t dst_max_size, con
size_t utf16_string_from_utf8_string_size(char16_t* dst, size_t dst_max_size, const char* s, size_t size)
{
if ( dst_max_size <= 0 ) return 0;
if ( !s || size <= 0 ) {
if ( dst_max_size == 0 ) return 0;
if ( dst_max_size == 1 || !s || size <= 0 ) {
*dst = 0;
return 0;
}
dst_max_size -= 1;
// size_t dst_len = 0;
const char* s_start = s;
char16_t* p = dst;
// char16_t* p_max = dst + dst_max_size;
char32_t char32 = 1;
while ( char32 && dst_max_size > 0 && uintptr_t(s)-uintptr_t(s_start) < size ) {
s = get_char32_from_utf8_string(s, &char32);
dst_max_size -= 1;
const char* s_start = s;
char32_t char32;
s = get_char32_from_utf8_string(s, &char32);
while ( char32 && dst_max_size > 0 && (uintptr_t)(s - s_start) <= size ) {
p = get_utf16_from_char32(p, &dst_max_size, char32);
s = get_char32_from_utf8_string(s, &char32);
}
*p = 0;
return (size_t)(p-dst);
@ -896,6 +958,25 @@ size_t utf16_string_from_utf32_string_len(char16_t* dst, size_t dst_max_size, co
return (size_t)(p-dst);
}
size_t utf16_string_from_utf32_string_size(char16_t* dst, size_t dst_max_size, const char32_t *s, size_t size)
{
if ( dst_max_size <= 0 ) return 0;
if ( !s || size <= 0 ) {
*dst = 0;
return 0;
}
dst_max_size -= 1;
const char32_t* s_start = s;
char16_t* p = dst;
while ( *s && dst_max_size > 0 && (uintptr_t)(s - s_start) < size ) {
p = get_utf16_from_char32(p, &dst_max_size, *s++);
}
*p = 0;
return (size_t)(p-dst);
}
size_t utf32_stringnn_from_utf16_string(char32_t* dst, size_t dst_max_size, const char16_t *s)
{
if ( dst_max_size <= 0 ) return 0;
@ -967,6 +1048,28 @@ size_t utf32_string_from_utf16_string_len(char32_t* dst, size_t dst_max_size, co
return (size_t)(p-dst);
}
size_t utf32_string_from_utf16_string_size(char32_t* dst, size_t dst_max_size, const char16_t *s, size_t size)
{
if ( dst_max_size <= 0 ) return 0;
if ( !s || size <= 0 ) {
*dst = 0;
return 0;
}
dst_max_size -= 1;
const char16_t* s_start = s;
char32_t* p = dst;
char32_t* p_max = dst + dst_max_size;
char32_t char32;
s = get_char32_from_utf16_string(s, &char32);
while ( char32 != 0 && p < p_max && (uintptr_t)(s - s_start) <= size ) {
*p++ = char32;
s = get_char32_from_utf16_string(s, &char32);
}
*p = 0;
return (size_t)(p-dst);
}
/*
* get nth char32 of an utf16 string
@ -1045,9 +1148,18 @@ size_t utf8_string_from_wchar_string(char* dst, size_t dst_max_size, const wchar
size_t utf8_string_from_wchar_string_len(char* dst, size_t dst_max_size, const wchar_t* s, size_t len)
{
#if __WCHAR_MAX__ <= 0xFFFFu
return utf8_string_from_utf16_string_len(dst, dst_max_size, (char16_t*)s, len);
return utf8_string_from_utf16_string_len(dst, dst_max_size, (char16_t*)s, len);
#else
return utf8_string_from_utf32_string_len(dst, dst_max_size, (char32_t*)s, len);
return utf8_string_from_utf32_string_len(dst, dst_max_size, (char32_t*)s, len);
#endif
}
size_t utf8_string_from_wchar_string_size(char* dst, size_t dst_max_size, const wchar_t* s, size_t size)
{
#if __WCHAR_MAX__ <= 0xFFFFu
return utf8_string_from_utf16_string_size(dst, dst_max_size, (char16_t*)s, size);
#else
return utf8_string_from_utf32_string_size(dst, dst_max_size, (char32_t*)s, size);
#endif
}
@ -1072,9 +1184,18 @@ size_t wchar_string_from_utf8_string(wchar_t* dst, size_t dst_max_size, const ch
size_t wchar_string_from_utf8_string_len(wchar_t* dst, size_t dst_max_size, const char* s, size_t len)
{
#if __WCHAR_MAX__ <= 0xFFFFu
return utf16_string_from_utf8_string_len((char16_t*)dst, dst_max_size, s, len);
return utf16_string_from_utf8_string_len((char16_t*)dst, dst_max_size, s, len);
#else
return utf32_string_from_utf8_string_len((char32_t*)dst, dst_max_size, s, len);
return utf32_string_from_utf8_string_len((char32_t*)dst, dst_max_size, s, len);
#endif
}
size_t wchar_string_from_utf8_string_size(wchar_t* dst, size_t dst_max_size, const char* s, size_t size)
{
#if __WCHAR_MAX__ <= 0xFFFFu
return utf16_string_from_utf8_string_size((char16_t*)dst, dst_max_size, s, size);
#else
return utf32_string_from_utf8_string_size((char32_t*)dst, dst_max_size, s, size);
#endif
}
@ -1144,6 +1265,15 @@ size_t utf16_string_from_wchar_string_len(char16_t* dst, size_t dst_max_size, co
#endif
}
size_t utf16_string_from_wchar_string_size(char16_t* dst, size_t dst_max_size, const wchar_t* s, size_t size)
{
#if __WCHAR_MAX__ <= 0xFFFFu
return utf16_string_from_utf16_string_size(dst, dst_max_size, (char16_t*)s, size);
#else
return utf16_string_from_utf32_string_size(dst, dst_max_size, (char32_t*)s, size);
#endif
}
size_t wchar_stringnn_from_utf16_string(wchar_t* dst, size_t dst_max_size, const char16_t* s)
{
#if __WCHAR_MAX__ <= 0xFFFFu
@ -1171,6 +1301,15 @@ size_t wchar_string_from_utf16_string_len(wchar_t* dst, size_t dst_max_size, con
#endif
}
size_t wchar_string_from_utf16_string_size(wchar_t* dst, size_t dst_max_size, const char16_t* s, size_t size)
{
#if __WCHAR_MAX__ <= 0xFFFFu
return utf16_string_from_utf16_string_size((char16_t*)dst, dst_max_size, s, size);
#else
return utf32_string_from_utf16_string_size((char32_t*)dst, dst_max_size, s, size);
#endif
}
/************************************************************* utf32 - wchar_t *********************************************************/
@ -1229,6 +1368,24 @@ size_t utf32_string_from_wchar_string(char32_t* dst, size_t dst_max_size, const
#endif
}
size_t utf32_string_from_wchar_string_len(char32_t* dst, size_t dst_max_size, const wchar_t* s, size_t len)
{
#if __WCHAR_MAX__ <= 0xFFFFu
return utf32_string_from_utf16_string_len(dst, dst_max_size, (char16_t*)s, len);
#else
return utf32_string_from_utf32_string_len(dst, dst_max_size, (char32_t*)s, len);
#endif
}
size_t utf32_string_from_wchar_string_size(char32_t* dst, size_t dst_max_size, const wchar_t* s, size_t size)
{
#if __WCHAR_MAX__ <= 0xFFFFu
return utf32_string_from_utf16_string_size(dst, dst_max_size, (char16_t*)s, size);
#else
return utf32_string_from_utf32_string_size(dst, dst_max_size, (char32_t*)s, size);
#endif
}
size_t wchar_stringnn_from_utf32_string(wchar_t* dst, size_t dst_max_size, const char32_t* s)
{
#if __WCHAR_MAX__ <= 0xFFFFu
@ -1247,6 +1404,24 @@ size_t wchar_string_from_utf32_string(wchar_t* dst, size_t dst_max_size, const c
#endif
}
size_t wchar_string_from_utf32_string_len(wchar_t* dst, size_t dst_max_size, const char32_t* s, size_t len)
{
#if __WCHAR_MAX__ <= 0xFFFFu
return utf16_string_from_utf32_string_len((char16_t*)dst, dst_max_size, s, len);
#else
return utf32_string_from_utf32_string_len((char32_t*)dst, dst_max_size, s, len);
#endif
}
size_t wchar_string_from_utf32_string_size(wchar_t* dst, size_t dst_max_size, const char32_t* s, size_t size)
{
#if __WCHAR_MAX__ <= 0xFFFFu
return utf16_string_from_utf32_string_size((char16_t*)dst, dst_max_size, s, size);
#else
return utf32_string_from_utf32_string_size((char32_t*)dst, dst_max_size, s, size);
#endif
}
/*
@ -1425,18 +1600,61 @@ size_t utf8_string_from_utf8_string_len(char* dst, size_t dst_max_size, const ch
len--;
}
*p = 0;
return (uintptr_t)p - (uintptr_t)dst - 1;
// return (uintptr_t)p - (uintptr_t)dst - 1;
return (uintptr_t)p - (uintptr_t)dst;
}
/*
Number Bits for First Last Byte 1 Byte 2 Byte 3 cByte 4
of bytes code point
1 7 U+0000 U+007F 0xxxxxxx
2 11 U+0080 U+07FF 110xxxxx 10xxxxxx
3 16 U+0800 U+FFFF 1110xxxx 10xxxxxx 10xxxxxx
4 21 U+10000 U+10FFFF[12] 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
*/
size_t utf8_string_from_utf8_string_size(char* dst, size_t dst_max_size, const char *s, size_t size)
{
if ( !s || size <= 0 || dst_max_size <= 1 ) {
if ( dst_max_size > 0 ) *dst = 0;
return 0;
}
memmove(dst, s, MIN(size, dst_max_size-1));
dst[MIN(size, dst_max_size-1)] = 0;
return MIN(size, dst_max_size-1);
size_t real_size = utf8_size_of_utf8_string(s);
if ( real_size == 0 ) {
*dst = 0; // here, dst_max_size is > 1
return 0;
}
size = MIN(real_size, size);
dst_max_size -= 1;
size = MIN(size, dst_max_size);
if ( s[size-1] & 0x80 )
{
size_t idx_of_first_multibyte = size;
while ( idx_of_first_multibyte > 0 && (s[--idx_of_first_multibyte] & 0xC0) == 0x80 ) ;
if ( (s[idx_of_first_multibyte] & 0xC0) == 0xC0 ) // this is the first of the multibyte sequence
{
if ( (s[idx_of_first_multibyte] & 0xE0) == 0xC0 ) { // 2 bytes sequence
if ( size - idx_of_first_multibyte < 2 ) size = idx_of_first_multibyte;
else size = idx_of_first_multibyte + 2;
}else
if ( (s[idx_of_first_multibyte] & 0xF0) == 0xE0 ) { // 3 bytes sequence
if ( size - idx_of_first_multibyte < 3 ) size = idx_of_first_multibyte;
else size = idx_of_first_multibyte + 3;
}else
if ( (s[idx_of_first_multibyte] & 0xF8) == 0xF0 ) { // 3 bytes sequence
if ( size - idx_of_first_multibyte < 4 ) size = idx_of_first_multibyte;
else size = idx_of_first_multibyte + 4;
}
}else{
while ( size > 1 && ( s[--size] & 0x80 ) ) ; // remove all the multibyte chars because there is none multibyte beginning sequence.
}
}
// while ( size > 0 && (s[size-1] & 0x80) ) --size; // ignore incomplete UTF8 sequence. // Cannot put the --size inside the if because size must not be modified if !(s[size-1] & 0x80)
memmove(dst, s, size);
dst[size] = 0;
return size;
}
size_t utf16_stringnn_from_utf16_string(char16_t* dst, size_t dst_max_size, const char16_t *s)
@ -1509,18 +1727,30 @@ size_t utf16_string_from_utf16_string_len(char16_t* dst, size_t dst_max_size, co
len--;
}
*p = 0;
return (uintptr_t)p - (uintptr_t)dst - 1;
return (uintptr_t)(p - dst);
}
size_t utf16_string_from_utf16_string_size(char16_t* dst, size_t dst_max_size, const char16_t *s, size_t size)
{
if ( !s || size <= 0 || dst_max_size <= 1 ) {
if ( dst_max_size > 0 ) *dst = 0;
if ( dst_max_size == 0 ) return 0;
if ( dst_max_size == 1 || !s || size <= 0 ) {
*dst = 0;
return 0;
}
memmove(dst, s, MIN(size, dst_max_size-1)*sizeof(char16_t));
dst[MIN(size, dst_max_size-1)] = 0;
return MIN(size, dst_max_size);
size_t real_size = utf16_size_of_utf16_string(s);
if ( real_size == 0 ) {
*dst = 0; // here, dst_max_size is > 1
return 0;
}
size = MIN(real_size, size); // size & real_size are >= 1
dst_max_size -= 1; // dst_max_size is > 1
size = MIN(size, dst_max_size); // here, size is >= 1
if ( is_high_surrogate(s[size-1]) ) --size;
memmove(dst, s, size*sizeof(char16_t));
dst[size] = 0;
return size;
}
size_t utf32_stringnn_from_utf32_string(char32_t* dst, size_t dst_max_size, const char32_t *s)
@ -1572,7 +1802,7 @@ size_t utf32_string_from_utf32_string_len(char32_t* dst, size_t dst_max_size, co
else dst_max_size -= 1;
memcpy((void*)dst, (void*)s, dst_max_size * sizeof(char32_t));
dst[dst_max_size] = 0;
return dst_max_size * sizeof(char32_t);
return dst_max_size;
}
size_t utf32_string_from_utf32_string_size(char32_t* dst, size_t dst_max_size, const char32_t *s, size_t size)
@ -1581,9 +1811,18 @@ size_t utf32_string_from_utf32_string_size(char32_t* dst, size_t dst_max_size, c
if ( dst_max_size > 0 ) *dst = 0;
return 0;
}
memmove(dst, s, MIN(size, dst_max_size-1)*sizeof(char32_t));
dst[MIN(size, dst_max_size-1)] = 0;
return MIN(size, dst_max_size);
size_t real_size = utf32_size_of_utf32_string(s);
if ( real_size == 0 ) {
*dst = 0; // here, dst_max_size is > 1
return 0;
}
size = MIN(real_size, size);
dst_max_size -= 1;
size = MIN(size, dst_max_size);
memmove(dst, s, size*sizeof(char32_t));
dst[size] = 0;
return size;
}
size_t wchar_stringnn_from_wchar_string(wchar_t* dst, size_t dst_max_size, const wchar_t *s)
@ -1607,9 +1846,18 @@ size_t wchar_string_from_wchar_string(wchar_t* dst, size_t dst_max_size, const w
size_t wchar_string_from_wchar_string_len(wchar_t* dst, size_t dst_max_size, const wchar_t *s, size_t len)
{
#if __WCHAR_MAX__ <= 0xFFFFu
return utf16_string_from_utf16_string_len((char16_t*)dst, dst_max_size, (char16_t*)s, len);
return utf16_string_from_utf16_string_len((char16_t*)dst, dst_max_size, (char16_t*)s, len);
#else
return utf32_string_from_utf32_string_len((char32_t*)dst, dst_max_size, (char32_t*)s, len);
return utf32_string_from_utf32_string_len((char32_t*)dst, dst_max_size, (char32_t*)s, len);
#endif
}
size_t wchar_string_from_wchar_string_size(wchar_t* dst, size_t dst_max_size, const wchar_t *s, size_t size)
{
#if __WCHAR_MAX__ <= 0xFFFFu
return utf16_string_from_utf16_string_size((char16_t*)dst, dst_max_size, (char16_t*)s, size);
#else
return utf32_string_from_utf32_string_size((char32_t*)dst, dst_max_size, (char32_t*)s, size);
#endif
}

View File

@ -1,8 +1,10 @@
//
// unicode_conversions.h
//
// Created by jief the 24 Feb 2020.
//
/*
* unicode_conversions.cpp
*
* Created by jief the 24 Feb 2020.
*
* version 1.0
*/
#ifndef __unicode_conversions_h__
#define __unicode_conversions_h__
@ -125,6 +127,7 @@ size_t utf32_size_of_utf8_string_len(const char* s, size_t len);
size_t utf32_stringnn_from_utf8_string(char32_t* dst, size_t dst_max_size, const char* s);
size_t utf32_string_from_utf8_string(char32_t* dst, size_t dst_max_size, const char* s);
size_t utf32_string_from_utf8_string_len(char32_t* dst, size_t dst_max_size, const char* s, size_t len);
size_t utf32_string_from_utf8_string_size(char32_t* dst, size_t dst_max_size, const char* s, size_t size);
/*
* Convert s to dst. Do not add null terminator.
* Return the number of utf8 char written
@ -132,6 +135,7 @@ size_t utf32_string_from_utf8_string_len(char32_t* dst, size_t dst_max_size, con
size_t utf8_stringnn_from_utf32_string(char* dst, size_t dst_max_size, const char32_t *s);
size_t utf8_string_from_utf32_string(char* dst, size_t dst_max_size, const char32_t *s);
size_t utf8_string_from_utf32_string_len(char* dst, size_t dst_max_size, const char32_t *s, size_t len);
size_t utf8_string_from_utf32_string_size(char* dst, size_t dst_max_size, const char32_t *s, size_t size);
char32_t get_char32_from_utf8_string_at_pos(const char* s, size_t pos);
@ -153,6 +157,7 @@ size_t utf16_size_of_utf8_string_len(const char* s, size_t len);
size_t utf8_stringnn_from_utf16_string(char* dst, size_t dst_max_size, const char16_t *s);
size_t utf8_string_from_utf16_string(char* dst, size_t dst_max_size, const char16_t *s);
size_t utf8_string_from_utf16_string_len(char* dst, size_t dst_max_size, const char16_t *s, size_t len);
size_t utf8_string_from_utf16_string_size(char* dst, size_t dst_max_size, const char16_t *s, size_t size);
size_t utf16_stringnn_from_utf8_string(char16_t* dst, size_t dst_max_size, const char* s);
size_t utf16_string_from_utf8_string(char16_t* dst, size_t dst_max_size, const char* s);
size_t utf16_string_from_utf8_string_len(char16_t* dst, size_t dst_max_size, const char* s, size_t len);
@ -175,9 +180,11 @@ size_t utf32_size_of_utf16_string_len(const char16_t *s, size_t len);
size_t utf16_stringnn_from_utf32_string(char16_t* dst, size_t dst_max_size, const char32_t *s);
size_t utf16_string_from_utf32_string(char16_t* dst, size_t dst_max_size, const char32_t *s);
size_t utf16_string_from_utf32_string_len(char16_t* dst, size_t dst_max_size, const char32_t *s, size_t len);
size_t utf16_string_from_utf32_string_size(char16_t* dst, size_t dst_max_size, const char32_t *s, size_t size);
size_t utf32_stringnn_from_utf16_string(char32_t* dst, size_t dst_max_size, const char16_t *s);
size_t utf32_string_from_utf16_string(char32_t* dst, size_t dst_max_size, const char16_t *s);
size_t utf32_string_from_utf16_string_len(char32_t* dst, size_t dst_max_size, const char16_t *s, size_t len);
size_t utf32_string_from_utf16_string_size(char32_t* dst, size_t dst_max_size, const char16_t *s, size_t size);
/*
@ -197,9 +204,11 @@ size_t wchar_size_of_utf8_string_len(const char* s, size_t len);
size_t utf8_stringnn_from_wchar_string(char* dst, size_t dst_max_size, const wchar_t* s);
size_t utf8_string_from_wchar_string(char* dst, size_t dst_max_size, const wchar_t* s);
size_t utf8_string_from_wchar_string_len(char* dst, size_t dst_max_size, const wchar_t* s, size_t len);
size_t utf8_string_from_wchar_string_size(char* dst, size_t dst_max_size, const wchar_t* s, size_t size);
size_t wchar_stringnn_from_utf8_string(wchar_t* dst, size_t dst_max_size, const char* s);
size_t wchar_string_from_utf8_string(wchar_t* dst, size_t dst_max_size, const char* s);
size_t wchar_string_from_utf8_string_len(wchar_t* dst, size_t dst_max_size, const char* s, size_t len);
size_t wchar_string_from_utf8_string_size(wchar_t* dst, size_t dst_max_size, const char* s, size_t size);
/****** utf16 - wchar_t *****/
@ -211,9 +220,11 @@ size_t wchar_size_of_utf16_string_len(const char16_t *s, size_t len);
size_t utf16_stringnn_from_wchar_string(char16_t* dst, size_t dst_max_size, const wchar_t* s);
size_t utf16_string_from_wchar_string(char16_t* dst, size_t dst_max_size, const wchar_t* s);
size_t utf16_string_from_wchar_string_len(char16_t* dst, size_t dst_max_size, const wchar_t* s, size_t len);
size_t utf16_string_from_wchar_string_size(char16_t* dst, size_t dst_max_size, const wchar_t* s, size_t size);
size_t wchar_stringnn_from_utf16_string(wchar_t* dst, size_t dst_max_size, const char16_t* s);
size_t wchar_string_from_utf16_string(wchar_t* dst, size_t dst_max_size, const char16_t* s);
size_t wchar_string_from_utf16_string_len(wchar_t* dst, size_t dst_max_size, const char16_t* s, size_t len);
size_t wchar_string_from_utf16_string_size(wchar_t* dst, size_t dst_max_size, const char16_t* s, size_t size);
/****** utf32 - wchar_t *****/
@ -225,9 +236,11 @@ size_t wchar_size_of_utf32_string_len(const char32_t *s, size_t len);
size_t utf32_stringnn_from_wchar_string(char32_t* dst, size_t dst_max_size, const wchar_t* s);
size_t utf32_string_from_wchar_string(char32_t* dst, size_t dst_max_size, const wchar_t* s);
size_t utf32_string_from_wchar_string_len(char32_t* dst, size_t dst_max_size, const wchar_t* s, size_t len);
size_t utf32_string_from_wchar_string_size(char32_t* dst, size_t dst_max_size, const wchar_t* s, size_t size);
size_t wchar_stringnn_from_utf32_string(wchar_t* dst, size_t dst_max_size, const char32_t* s);
size_t wchar_string_from_utf32_string(wchar_t* dst, size_t dst_max_size, const char32_t* s);
size_t wchar_string_from_utf32_string_len(wchar_t* dst, size_t dst_max_size, const char32_t* s, size_t len);
size_t wchar_string_from_utf32_string_size(wchar_t* dst, size_t dst_max_size, const char32_t* s, size_t size);
char32_t get_char32_from_wchar_string_at_pos(const char16_t* s, size_t pos);
@ -258,15 +271,16 @@ size_t utf32_string_from_utf32_string_size(char32_t* dst, size_t dst_max_size, c
size_t wchar_stringnn_from_wchar_string(wchar_t* dst, size_t dst_max_size, const wchar_t *s);
size_t wchar_string_from_wchar_string(wchar_t* dst, size_t dst_max_size, const wchar_t *s);
size_t wchar_string_from_wchar_string_len(wchar_t* dst, size_t dst_max_size, const wchar_t *s, size_t len);
size_t wchar_string_from_wchar_string_size(wchar_t* dst, size_t dst_max_size, const wchar_t *s, size_t size);
char32_t get_char32_from_utf32_string_at_pos(const char32_t* s, size_t pos);
/****** convenience *****/
inline size_t length_of_utf8_string(const char* s);
inline size_t length_of_utf16_string(const char16_t* s);
inline size_t length_of_utf32_string(const char32_t* s); // UTF32 length == size
inline size_t length_of_wchar_string(const wchar_t* s);
//inline size_t length_of_utf8_string(const char* s);
//inline size_t length_of_utf16_string(const char16_t* s);
//inline size_t length_of_utf32_string(const char32_t* s); // UTF32 length == size
//inline size_t length_of_wchar_string(const wchar_t* s);
#ifdef __cplusplus
@ -315,10 +329,10 @@ inline size_t size_of_utf_string(const char32_t* s) { return utf32_size_of_utf32
inline size_t size_of_utf_string(const wchar_t* s) { return size_of_utf_string((wchar_cast*)s); }
/* Returns amount of utf chars. Type of utf chars are determined by the first parameter. */
inline size_t utf_size_of_utf_string(const char* dummy, const char* s) { return utf8_size_of_utf8_string(s); }
inline size_t utf_size_of_utf_string(const char16_t* dummy, const char* s) { return utf16_size_of_utf8_string(s); }
inline size_t utf_size_of_utf_string(const char32_t* dummy, const char* s) { return utf32_size_of_utf8_string(s); }
inline size_t utf_size_of_utf_string(const wchar_t* dummy, const char* s) { return utf_size_of_utf_string((wchar_cast*)dummy, s); }
inline size_t utf_size_of_utf_string(const char* dummy, const char* s) { (void)dummy; return utf8_size_of_utf8_string(s); }
inline size_t utf_size_of_utf_string(const char16_t* dummy, const char* s) { (void)dummy; return utf16_size_of_utf8_string(s); }
inline size_t utf_size_of_utf_string(const char32_t* dummy, const char* s) { (void)dummy; return utf32_size_of_utf8_string(s); }
inline size_t utf_size_of_utf_string(const wchar_t* dummy, const char* s) { (void)dummy; return utf_size_of_utf_string((wchar_cast*)dummy, s); }
inline size_t utf_size_of_utf_string(const char*, const char16_t* s) { return utf8_size_of_utf16_string(s); }
inline size_t utf_size_of_utf_string(const char16_t*, const char16_t* s) { return utf16_size_of_utf16_string(s); }
@ -363,6 +377,37 @@ inline size_t utf_size_of_utf_string_len(const char16_t* t, const wchar_t* s, si
inline size_t utf_size_of_utf_string_len(const char32_t* t, const wchar_t* s, size_t len) { return utf_size_of_utf_string_len(t, (wchar_cast*)s, len); }
inline size_t utf_size_of_utf_string_len(const wchar_t* t, const wchar_t* s, size_t len) { return utf_size_of_utf_string_len((wchar_cast*)t, (wchar_cast*)s, len); }
//
//
///* Returns amount of utf chars needed to represent the first [size] native chars chars. */
//inline size_t size_of_utf_string_size(const char* s, size_t size) { return utf8_size_of_utf8_string_size(s, size); }
//inline size_t size_of_utf_string_size(const char16_t* s, size_t size) { return utf16_size_of_utf16_string_size(s, size); }
//inline size_t size_of_utf_string_size(const char32_t* s, size_t size) { return utf32_size_of_utf32_string_size(s, size); } // for UTF32 size and sizegth are equal
//inline size_t size_of_utf_string_size(const wchar_t* s, size_t size) { return size_of_utf_string_size((wchar_cast*)s, size); }
//
///* Returns amount of utf chars needed to represent the first [size] native chars. Type of utf chars are determined by the first parameter. */
//inline size_t utf_size_of_utf_string_size(const char*, const char* s, size_t size) { return utf8_size_of_utf8_string_size(s, size); }
//inline size_t utf_size_of_utf_string_size(const char16_t*, const char* s, size_t size) { return utf16_size_of_utf8_string_size(s, size); }
//inline size_t utf_size_of_utf_string_size(const char32_t*, const char* s, size_t size) { return utf32_size_of_utf8_string_size(s, size); }
//inline size_t utf_size_of_utf_string_size(const wchar_t* t, const char* s, size_t size) { return utf_size_of_utf_string_size((wchar_cast*)t, s, size); }
//
//inline size_t utf_size_of_utf_string_size(const char*, const char16_t* s, size_t size) { return utf8_size_of_utf16_string_size(s, size); }
//inline size_t utf_size_of_utf_string_size(const char16_t*, const char16_t* s, size_t size) { return utf16_size_of_utf16_string_size(s, size); }
//inline size_t utf_size_of_utf_string_size(const char32_t*, const char16_t* s, size_t size) { return utf32_size_of_utf16_string_size(s, size); }
//inline size_t utf_size_of_utf_string_size(const wchar_t* t, const char16_t* s, size_t size) { return utf_size_of_utf_string_size((wchar_cast*)t, s, size); }
//
//inline size_t utf_size_of_utf_string_size(const char*, const char32_t* s, size_t size) { return utf8_size_of_utf32_string_size(s, size); }
//inline size_t utf_size_of_utf_string_size(const char16_t*, const char32_t* s, size_t size) { return utf16_size_of_utf32_string_size(s, size); }
//inline size_t utf_size_of_utf_string_size(const char32_t*, const char32_t* s, size_t size) { return utf32_size_of_utf32_string_size(s, size); }
//inline size_t utf_size_of_utf_string_size(const wchar_t* t, const char32_t* s, size_t size) { return utf_size_of_utf_string_size((wchar_cast*)t, s, size); }
//
//inline size_t utf_size_of_utf_string_size(const char* t, const wchar_t* s, size_t size) { return utf_size_of_utf_string_size(t, (wchar_cast*)s, size); }
//inline size_t utf_size_of_utf_string_size(const char16_t* t, const wchar_t* s, size_t size) { return utf_size_of_utf_string_size(t, (wchar_cast*)s, size); }
//inline size_t utf_size_of_utf_string_size(const char32_t* t, const wchar_t* s, size_t size) { return utf_size_of_utf_string_size(t, (wchar_cast*)s, size); }
//inline size_t utf_size_of_utf_string_size(const wchar_t* t, const wchar_t* s, size_t size) { return utf_size_of_utf_string_size((wchar_cast*)t, (wchar_cast*)s, size); }
//
//
/*
@ -440,22 +485,22 @@ inline size_t utf_string_from_utf_string_len(wchar_t* dst, size_t dst_max_size,
inline size_t utf_string_from_utf_string_size(char* dst, size_t dst_max_size, const char* s, size_t size) { return utf8_string_from_utf8_string_size(dst, dst_max_size, s, size); }
inline size_t utf_string_from_utf_string_size(char16_t* dst, size_t dst_max_size, const char* s, size_t size) { return utf16_string_from_utf8_string_size(dst, dst_max_size, s, size); }
//inline size_t utf_string_from_utf_string_size(char32_t* dst, size_t dst_max_size, const char* s, size_t size) { return utf32_string_from_utf8_string_size(dst, dst_max_size, s, size); }
inline size_t utf_string_from_utf_string_size(char32_t* dst, size_t dst_max_size, const char* s, size_t size) { return utf32_string_from_utf8_string_size(dst, dst_max_size, s, size); }
inline size_t utf_string_from_utf_string_size(wchar_t* dst, size_t dst_max_size, const char* s, size_t size) { return utf_string_from_utf_string_size((wchar_cast*)dst, dst_max_size, s, size); }
//
//inline size_t utf_string_from_utf_string_size(char* dst, size_t dst_max_size, const char16_t * s, size_t size) { return utf8_string_from_utf16_string_size(dst, dst_max_size, s, size); }
inline size_t utf_string_from_utf_string_size(char* dst, size_t dst_max_size, const char16_t * s, size_t size) { return utf8_string_from_utf16_string_size(dst, dst_max_size, s, size); }
inline size_t utf_string_from_utf_string_size(char16_t* dst, size_t dst_max_size, const char16_t * s, size_t size) { return utf16_string_from_utf16_string_size(dst, dst_max_size, s, size); }
//inline size_t utf_string_from_utf_string_size(char32_t* dst, size_t dst_max_size, const char16_t * s, size_t size) { return utf32_string_from_utf16_string_size(dst, dst_max_size, s, size); }
inline size_t utf_string_from_utf_string_size(char32_t* dst, size_t dst_max_size, const char16_t * s, size_t size) { return utf32_string_from_utf16_string_size(dst, dst_max_size, s, size); }
inline size_t utf_string_from_utf_string_size(wchar_t* dst, size_t dst_max_size, const char16_t * s, size_t size) { return utf_string_from_utf_string_size((wchar_cast*)dst, dst_max_size, s, size); }
//
//inline size_t utf_string_from_utf_string_size(char* dst, size_t dst_max_size, const char32_t * s, size_t size) { return utf8_string_from_utf32_string_size(dst, dst_max_size, s, size); }
//inline size_t utf_string_from_utf_string_size(char16_t* dst, size_t dst_max_size, const char32_t * s, size_t size) { return utf16_string_from_utf32_string_size(dst, dst_max_size, s, size); }
inline size_t utf_string_from_utf_string_size(char* dst, size_t dst_max_size, const char32_t * s, size_t size) { return utf8_string_from_utf32_string_size(dst, dst_max_size, s, size); }
inline size_t utf_string_from_utf_string_size(char16_t* dst, size_t dst_max_size, const char32_t * s, size_t size) { return utf16_string_from_utf32_string_size(dst, dst_max_size, s, size); }
inline size_t utf_string_from_utf_string_size(char32_t* dst, size_t dst_max_size, const char32_t * s, size_t size) { return utf32_string_from_utf32_string_size(dst, dst_max_size, s, size); }
//inline size_t utf_string_from_utf_string_size(wchar_t* dst, size_t dst_max_size, const char32_t * s, size_t size) { return utf_string_from_utf_string_size((wchar_cast*)dst, dst_max_size, s, size); }
//
//inline size_t utf_string_from_utf_string_size(char* dst, size_t dst_max_size, const wchar_t * s, size_t size) { return utf_string_from_utf_string_size(dst, dst_max_size, (wchar_cast*)s, size); }
//inline size_t utf_string_from_utf_string_size(char16_t* dst, size_t dst_max_size, const wchar_t * s, size_t size) { return utf_string_from_utf_string_size(dst, dst_max_size, (wchar_cast*)s, size); }
//inline size_t utf_string_from_utf_string_size(char32_t* dst, size_t dst_max_size, const wchar_t * s, size_t size) { return utf_string_from_utf_string_size(dst, dst_max_size, (wchar_cast*)s, size); }
inline size_t utf_string_from_utf_string_size(wchar_t* dst, size_t dst_max_size, const char32_t * s, size_t size) { return utf_string_from_utf_string_size((wchar_cast*)dst, dst_max_size, s, size); }
inline size_t utf_string_from_utf_string_size(char* dst, size_t dst_max_size, const wchar_t * s, size_t size) { return utf_string_from_utf_string_size(dst, dst_max_size, (wchar_cast*)s, size); }
inline size_t utf_string_from_utf_string_size(char16_t* dst, size_t dst_max_size, const wchar_t * s, size_t size) { return utf_string_from_utf_string_size(dst, dst_max_size, (wchar_cast*)s, size); }
inline size_t utf_string_from_utf_string_size(char32_t* dst, size_t dst_max_size, const wchar_t * s, size_t size) { return utf_string_from_utf_string_size(dst, dst_max_size, (wchar_cast*)s, size); }
inline size_t utf_string_from_utf_string_size(wchar_t* dst, size_t dst_max_size, const wchar_t * s, size_t size) { return utf_string_from_utf_string_size(dst, dst_max_size, (wchar_cast*)s, size); }

View File

@ -8,6 +8,23 @@ int XStringArray_tests()
// printf("XStringWArray_tests -> Enter\n");
#endif
{
ConstXStringWArray constArray;
constArray.Add(L"aa");
XStringW ws = L"bb"_XSW;
constArray.AddReference(&ws, false);
const XStringW ws2 = L"cc"_XSW;
constArray.AddReference(&ws2, false);
XStringWArray array;
array.Add(L"aa");
array.AddReference(&ws, false);
array.Add(L"cc");
bool b = array == constArray;
if ( !b ) return 5;
}
{
XStringWArray array1;

View File

@ -515,13 +515,12 @@
[BuildOptions]
XCODE:*_*_*_CC_FLAGS = -fno-use-cxa-atexit -fno-omit-frame-pointer -fno-rtti -fno-exceptions -DJCONST=CONST -Wno-incompatible-ms-struct #-Wunused-parameter
XCODE:*_*_*_CXX_FLAGS = -fno-use-cxa-atexit -fno-omit-frame-pointer -fno-rtti -fno-exceptions -DJCONST=CONST -Wno-incompatible-ms-struct #-Wunused-parameter
# -fno-rtti is only for C++
XCODE:*_*_*_CC_FLAGS = -fno-use-cxa-atexit -fno-omit-frame-pointer -fno-exceptions -DJCONST=CONST -Wno-incompatible-ms-struct #-Wunused-parameter
XCODE:*_*_*_CXX_FLAGS = -fno-use-cxa-atexit -fno-omit-frame-pointer -fno-rtti -fno-exceptions -DJCONST=CONST -Wno-incompatible-ms-struct #-Wunused-parameter
# -Wno-unused-const-variable, -maccumulate-outgoing-args is set in tools_def.template
GCC:*_*_*_CC_FLAGS = -fno-omit-frame-pointer -DJCONST=CONST
GCC:*_*_*_CXX_FLAGS = -fno-omit-frame-pointer -fno-rtti -DJCONST=CONST
MSFT:*_*_*_CC_FLAGS = /Os /wd4201 /D JCONST=const

View File

@ -2930,7 +2930,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
ZeroMem((void*)&gGraphics[0], sizeof(GFX_PROPERTIES) * 4);
ZeroMem((void*)&gAudios[0], sizeof(HDA_PROPERTIES) * 4);
DBG("\n");
DbgHeader("Starting Clover");
if (Now.TimeZone < -1440 || Now.TimeZone > 1440) {
MsgLog("Now is %02d.%02d.%d, %02d:%02d:%02d (GMT)\n",
Now.Day, Now.Month, Now.Year, Now.Hour, Now.Minute, Now.Second);
@ -2989,8 +2989,6 @@ RefitMain (IN EFI_HANDLE ImageHandle,
}
DBG("SimpleTextEx Status=%s\n", efiStrError(Status));
//debugStartImageWithOC(); // ok BS_I
GetDefaultSettings(); // do this before PrepatchSmbios() because PrepatchSmbios() change gSettings.Smbios.SmUUID.
// TODO : there is a mixup between SmUUID read from the platform and the SmUUID set by the user. They should be read in 2 different vars.
PrepatchSmbios();