Core/ResourceLoader: Fix assert
Former-commit-id: 391a0ec4de1a1c5ed97ea82aee0d3d69fbbc00df
This commit is contained in:
parent
d2e3bb36a6
commit
5465951f87
|
|
@ -244,7 +244,7 @@ namespace Nz
|
|||
bool ResourceLoader<Type, Parameters>::LoadFromStream(Type* resource, Stream& stream, const Parameters& parameters)
|
||||
{
|
||||
NazaraAssert(resource, "Invalid resource");
|
||||
NazaraAssert(stream.GetCursorPos() >= stream.GetSize(), "No data to load");
|
||||
NazaraAssert(stream.GetCursorPos() < stream.GetSize(), "No data to load");
|
||||
NazaraAssert(parameters.IsValid(), "Invalid parameters");
|
||||
|
||||
UInt64 streamPos = stream.GetCursorPos();
|
||||
|
|
|
|||
|
|
@ -1462,8 +1462,12 @@ namespace Nz
|
|||
{
|
||||
if (Detail::ToLower(*ptr) == c)
|
||||
{
|
||||
if (ptr != m_sharedString->string.get() && !std::isspace(*(ptr-1)))
|
||||
continue;
|
||||
if (ptr != m_sharedString->string.get())
|
||||
{
|
||||
--ptr;
|
||||
if (!(Unicode::GetCategory(*ptr++) & Unicode::Category_Separator))
|
||||
continue;
|
||||
}
|
||||
|
||||
const char* p = &string[1];
|
||||
const char* tPtr = ptr+1;
|
||||
|
|
@ -1471,7 +1475,7 @@ namespace Nz
|
|||
{
|
||||
if (*p == '\0')
|
||||
{
|
||||
if (*tPtr == '\0' || std::isspace(*tPtr))
|
||||
if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator)
|
||||
return ptr-m_sharedString->string.get();
|
||||
else
|
||||
break;
|
||||
|
|
@ -1496,8 +1500,12 @@ namespace Nz
|
|||
{
|
||||
if (*ptr == string[0])
|
||||
{
|
||||
if (ptr != m_sharedString->string.get() && !std::isspace(*(ptr-1)))
|
||||
continue;
|
||||
if (ptr != m_sharedString->string.get())
|
||||
{
|
||||
--ptr;
|
||||
if (!(Unicode::GetCategory(*ptr++) & Unicode::Category_Separator))
|
||||
continue;
|
||||
}
|
||||
|
||||
const char* p = &string[1];
|
||||
const char* tPtr = ptr+1;
|
||||
|
|
@ -1505,7 +1513,7 @@ namespace Nz
|
|||
{
|
||||
if (*p == '\0')
|
||||
{
|
||||
if (*tPtr == '\0' || std::isspace(*tPtr))
|
||||
if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator)
|
||||
return ptr-m_sharedString->string.get();
|
||||
else
|
||||
break;
|
||||
|
|
@ -1655,7 +1663,8 @@ namespace Nz
|
|||
{
|
||||
if (Detail::ToLower(*ptr) == c)
|
||||
{
|
||||
if (*(ptr+1) != '\0' && !std::isspace(*(ptr+1)))
|
||||
char nextC = *(ptr + 1);
|
||||
if (nextC != '\0' && (Unicode::GetCategory(nextC) & Unicode::Category_Separator_Space) == 0)
|
||||
continue;
|
||||
|
||||
const char* p = &string.m_sharedString->string[string.m_sharedString->size-1];
|
||||
|
|
@ -1666,7 +1675,7 @@ namespace Nz
|
|||
|
||||
if (p == &string.m_sharedString->string[0])
|
||||
{
|
||||
if (ptr == m_sharedString->string.get() || std::isspace(*(ptr-1)))
|
||||
if (ptr == m_sharedString->string.get() || Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator_Space)
|
||||
return ptr-m_sharedString->string.get();
|
||||
else
|
||||
break;
|
||||
|
|
@ -1685,7 +1694,8 @@ namespace Nz
|
|||
{
|
||||
if (*ptr == string.m_sharedString->string[string.m_sharedString->size-1])
|
||||
{
|
||||
if (*(ptr+1) != '\0' && !std::isspace(*(ptr+1)))
|
||||
char nextC = *(ptr + 1);
|
||||
if (nextC != '\0' && (Unicode::GetCategory(nextC) & Unicode::Category_Separator_Space) == 0)
|
||||
continue;
|
||||
|
||||
const char* p = &string.m_sharedString->string[string.m_sharedString->size-1];
|
||||
|
|
@ -1696,7 +1706,7 @@ namespace Nz
|
|||
|
||||
if (p == &string.m_sharedString->string[0])
|
||||
{
|
||||
if (ptr == m_sharedString->string.get() || std::isspace(*(ptr-1)))
|
||||
if (ptr == m_sharedString->string.get() || Unicode::GetCategory(*(ptr - 1)) & Unicode::Category_Separator_Space)
|
||||
return ptr-m_sharedString->string.get();
|
||||
else
|
||||
break;
|
||||
|
|
@ -1834,7 +1844,7 @@ namespace Nz
|
|||
{
|
||||
if (Detail::ToLower(*ptr) == c)
|
||||
{
|
||||
if (ptr != m_sharedString->string.get() && !std::isspace(*(ptr-1)))
|
||||
if (ptr != m_sharedString->string.get() && (Unicode::GetCategory(*(ptr - 1)) & Unicode::Category_Separator) == 0)
|
||||
continue;
|
||||
|
||||
const char* p = &string[1];
|
||||
|
|
@ -1843,7 +1853,7 @@ namespace Nz
|
|||
{
|
||||
if (*p == '\0')
|
||||
{
|
||||
if (*tPtr == '\0' || std::isspace(*tPtr))
|
||||
if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator)
|
||||
return ptr - m_sharedString->string.get();
|
||||
else
|
||||
break;
|
||||
|
|
@ -1865,7 +1875,7 @@ namespace Nz
|
|||
{
|
||||
if (*ptr == string[0])
|
||||
{
|
||||
if (ptr != m_sharedString->string.get() && !std::isspace(*(ptr-1)))
|
||||
if (ptr != m_sharedString->string.get() && (Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator) == 0)
|
||||
continue;
|
||||
|
||||
const char* p = &string[1];
|
||||
|
|
@ -1874,7 +1884,7 @@ namespace Nz
|
|||
{
|
||||
if (*p == '\0')
|
||||
{
|
||||
if (*tPtr == '\0' || std::isspace(*tPtr))
|
||||
if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator)
|
||||
return ptr - m_sharedString->string.get();
|
||||
else
|
||||
break;
|
||||
|
|
@ -2016,7 +2026,7 @@ namespace Nz
|
|||
{
|
||||
if (Detail::ToLower(*ptr) == c)
|
||||
{
|
||||
if (ptr != m_sharedString->string.get() && !std::isspace(*(ptr-1)))
|
||||
if (ptr != m_sharedString->string.get() && (Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator_Space) == 0)
|
||||
continue;
|
||||
|
||||
const char* p = &string.m_sharedString->string[1];
|
||||
|
|
@ -2025,7 +2035,7 @@ namespace Nz
|
|||
{
|
||||
if (*p == '\0')
|
||||
{
|
||||
if (*tPtr == '\0' || std::isspace(*tPtr))
|
||||
if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator_Space)
|
||||
return ptr - m_sharedString->string.get();
|
||||
else
|
||||
break;
|
||||
|
|
@ -2046,7 +2056,7 @@ namespace Nz
|
|||
while ((ptr = std::strstr(ptr, string.GetConstBuffer())) != nullptr)
|
||||
{
|
||||
// If the word is really alone
|
||||
if ((ptr == m_sharedString->string.get() || std::isspace(*(ptr-1))) && (*(ptr+m_sharedString->size) == '\0' || std::isspace(*(ptr+m_sharedString->size))))
|
||||
if ((ptr == m_sharedString->string.get() || Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator_Space) && (*(ptr+m_sharedString->size) == '\0' || Unicode::GetCategory(*(ptr+m_sharedString->size)) & Unicode::Category_Separator_Space))
|
||||
return ptr - m_sharedString->string.get();
|
||||
|
||||
ptr++;
|
||||
|
|
@ -2221,7 +2231,7 @@ namespace Nz
|
|||
{
|
||||
do
|
||||
{
|
||||
if (std::isspace(*ptr))
|
||||
if (Unicode::GetCategory(*ptr) & Unicode::Category_Separator)
|
||||
{
|
||||
endPos = static_cast<std::intmax_t>(ptr - m_sharedString->string.get() - 1);
|
||||
break;
|
||||
|
|
@ -2273,7 +2283,7 @@ namespace Nz
|
|||
{
|
||||
do
|
||||
{
|
||||
if (std::isspace(*ptr))
|
||||
if (Unicode::GetCategory(*ptr) & Unicode::Category_Separator)
|
||||
inWord = false;
|
||||
else
|
||||
{
|
||||
|
|
@ -3427,7 +3437,7 @@ namespace Nz
|
|||
const char* limit = &m_sharedString->string[m_sharedString->size];
|
||||
do
|
||||
{
|
||||
if (std::isspace(*ptr))
|
||||
if (Unicode::GetCategory(*ptr) & Unicode::Category_Separator)
|
||||
{
|
||||
if (inword)
|
||||
{
|
||||
|
|
@ -4232,7 +4242,7 @@ namespace Nz
|
|||
utf8::unchecked::iterator<const char*> it(m_sharedString->string.get());
|
||||
do
|
||||
{
|
||||
if (Unicode::GetCategory(*it) & Unicode::Category_Separator)
|
||||
if ((Unicode::GetCategory(*it) & Unicode::Category_Separator) == 0)
|
||||
break;
|
||||
}
|
||||
while (*++it);
|
||||
|
|
@ -4247,7 +4257,7 @@ namespace Nz
|
|||
utf8::unchecked::iterator<const char*> it(&m_sharedString->string[m_sharedString->size]);
|
||||
while ((it--).base() != m_sharedString->string.get())
|
||||
{
|
||||
if (Unicode::GetCategory(*it) & Unicode::Category_Separator)
|
||||
if ((Unicode::GetCategory(*it) & Unicode::Category_Separator) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -4263,7 +4273,7 @@ namespace Nz
|
|||
{
|
||||
for (; startPos < m_sharedString->size; ++startPos)
|
||||
{
|
||||
if (!std::isspace(m_sharedString->string[startPos]))
|
||||
if ((Unicode::GetCategory(m_sharedString->string[startPos]) & Unicode::Category_Separator) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -4273,7 +4283,7 @@ namespace Nz
|
|||
{
|
||||
for (; endPos > 0; --endPos)
|
||||
{
|
||||
if (!std::isspace(m_sharedString->string[endPos]))
|
||||
if ((Unicode::GetCategory(m_sharedString->string[endPos]) & Unicode::Category_Separator) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue