mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
Merge branch 'master' of https://github.com/rheit/zdoom
This commit is contained in:
commit
f284a24ed9
6 changed files with 497 additions and 383 deletions
File diff suppressed because it is too large
Load diff
|
@ -95,7 +95,8 @@ void FResourceLump::LumpNameSetup(FString iname)
|
||||||
{
|
{
|
||||||
long slash = iname.LastIndexOf('/');
|
long slash = iname.LastIndexOf('/');
|
||||||
FString base = (slash >= 0) ? iname.Mid(slash + 1) : iname;
|
FString base = (slash >= 0) ? iname.Mid(slash + 1) : iname;
|
||||||
base.Truncate(base.LastIndexOf('.'));
|
auto dot = base.LastIndexOf('.');
|
||||||
|
if (dot >= 0) base.Truncate(dot);
|
||||||
uppercopy(Name, base);
|
uppercopy(Name, base);
|
||||||
Name[8] = 0;
|
Name[8] = 0;
|
||||||
FullName = iname;
|
FullName = iname;
|
||||||
|
|
|
@ -162,7 +162,7 @@ static const char *StringToUnicode(const char *cc, int size = -1)
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int count1 = 0;
|
int count1 = 0;
|
||||||
out.Clear();
|
out.Clear();
|
||||||
while (ch = (*c++) & 255)
|
while ((ch = (*c++) & 255))
|
||||||
{
|
{
|
||||||
count1++;
|
count1++;
|
||||||
if (ch >= 128)
|
if (ch >= 128)
|
||||||
|
@ -180,7 +180,7 @@ static const char *StringToUnicode(const char *cc, int size = -1)
|
||||||
out.Last() = 0;
|
out.Last() = 0;
|
||||||
c = cc;
|
c = cc;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (ch = (*c++) & 255)
|
while ((ch = (*c++) & 255))
|
||||||
{
|
{
|
||||||
utf8_encode(ch, &out[i], &count1);
|
utf8_encode(ch, &out[i], &count1);
|
||||||
i += count1;
|
i += count1;
|
||||||
|
|
|
@ -981,8 +981,6 @@ void DFrameBuffer::DrawRateStuff ()
|
||||||
int rate_x;
|
int rate_x;
|
||||||
|
|
||||||
int textScale = active_con_scale();
|
int textScale = active_con_scale();
|
||||||
if (textScale == 0)
|
|
||||||
textScale = CleanXfac;
|
|
||||||
|
|
||||||
chars = mysnprintf (fpsbuff, countof(fpsbuff), "%2u ms (%3u fps)", howlong, LastCount);
|
chars = mysnprintf (fpsbuff, countof(fpsbuff), "%2u ms (%3u fps)", howlong, LastCount);
|
||||||
rate_x = Width / textScale - ConFont->StringWidth(&fpsbuff[0]);
|
rate_x = Width / textScale - ConFont->StringWidth(&fpsbuff[0]);
|
||||||
|
|
104
src/zstring.cpp
104
src/zstring.cpp
|
@ -343,28 +343,74 @@ FString &FString::operator += (char tail)
|
||||||
|
|
||||||
FString &FString::AppendCStrPart (const char *tail, size_t tailLen)
|
FString &FString::AppendCStrPart (const char *tail, size_t tailLen)
|
||||||
{
|
{
|
||||||
|
if (tailLen > 0)
|
||||||
|
{
|
||||||
size_t len1 = Len();
|
size_t len1 = Len();
|
||||||
ReallocBuffer (len1 + tailLen);
|
ReallocBuffer(len1 + tailLen);
|
||||||
StrCopy (Chars + len1, tail, tailLen);
|
StrCopy(Chars + len1, tail, tailLen);
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
FString &FString::CopyCStrPart(const char *tail, size_t tailLen)
|
FString &FString::CopyCStrPart(const char *tail, size_t tailLen)
|
||||||
{
|
{
|
||||||
|
if (tailLen > 0)
|
||||||
|
{
|
||||||
ReallocBuffer(tailLen);
|
ReallocBuffer(tailLen);
|
||||||
StrCopy(Chars, tail, tailLen);
|
StrCopy(Chars, tail, tailLen);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Data()->Release();
|
||||||
|
NullString.RefCount++;
|
||||||
|
Chars = &NullString.Nothing[0];
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FString::Truncate(long newlen)
|
void FString::Truncate(long newlen)
|
||||||
{
|
{
|
||||||
if (newlen >= 0 && newlen < (long)Len())
|
if (newlen <= 0)
|
||||||
|
{
|
||||||
|
Data()->Release();
|
||||||
|
NullString.RefCount++;
|
||||||
|
Chars = &NullString.Nothing[0];
|
||||||
|
}
|
||||||
|
else if (newlen < (long)Len())
|
||||||
{
|
{
|
||||||
ReallocBuffer (newlen);
|
ReallocBuffer (newlen);
|
||||||
Chars[newlen] = '\0';
|
Chars[newlen] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FString::Remove(size_t index, size_t remlen)
|
||||||
|
{
|
||||||
|
if (index < Len())
|
||||||
|
{
|
||||||
|
if (index + remlen >= Len())
|
||||||
|
{
|
||||||
|
Truncate((long)index);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
remlen = Len() - remlen < remlen ? Len() - remlen : remlen;
|
||||||
|
if (Data()->RefCount == 1)
|
||||||
|
{ // Can do this in place
|
||||||
|
memmove(Chars + index, Chars + index + remlen, Len() - index - remlen);
|
||||||
|
Data()->Len -= (unsigned)remlen;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Must do it in a copy
|
||||||
|
FStringData *old = Data();
|
||||||
|
AllocBuffer(old->Len - remlen);
|
||||||
|
StrCopy(Chars, old->Chars(), index);
|
||||||
|
StrCopy(Chars + index, old->Chars() + index + remlen, old->Len - index - remlen);
|
||||||
|
old->Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FString FString::Left (size_t numChars) const
|
FString FString::Left (size_t numChars) const
|
||||||
{
|
{
|
||||||
size_t len = Len();
|
size_t len = Len();
|
||||||
|
@ -589,6 +635,10 @@ void FString::StripLeft ()
|
||||||
if (!isspace(Chars[i]))
|
if (!isspace(Chars[i]))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (i == 0)
|
||||||
|
{ // Nothing to strip.
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Data()->RefCount <= 1)
|
if (Data()->RefCount <= 1)
|
||||||
{
|
{
|
||||||
for (j = 0; i <= max; ++j, ++i)
|
for (j = 0; i <= max; ++j, ++i)
|
||||||
|
@ -620,6 +670,10 @@ void FString::StripLeft (const char *charset)
|
||||||
if (!strchr (charset, Chars[i]))
|
if (!strchr (charset, Chars[i]))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (i == 0)
|
||||||
|
{ // Nothing to strip.
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Data()->RefCount <= 1)
|
if (Data()->RefCount <= 1)
|
||||||
{
|
{
|
||||||
for (j = 0; i <= max; ++j, ++i)
|
for (j = 0; i <= max; ++j, ++i)
|
||||||
|
@ -640,11 +694,16 @@ void FString::StripLeft (const char *charset)
|
||||||
void FString::StripRight ()
|
void FString::StripRight ()
|
||||||
{
|
{
|
||||||
size_t max = Len(), i;
|
size_t max = Len(), i;
|
||||||
for (i = max; i-- > 0; )
|
if (max == 0) return;
|
||||||
|
for (i = --max; i-- > 0; )
|
||||||
{
|
{
|
||||||
if (!isspace(Chars[i]))
|
if (!isspace(Chars[i]))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (i == max)
|
||||||
|
{ // Nothing to strip.
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Data()->RefCount <= 1)
|
if (Data()->RefCount <= 1)
|
||||||
{
|
{
|
||||||
Chars[i+1] = '\0';
|
Chars[i+1] = '\0';
|
||||||
|
@ -668,11 +727,15 @@ void FString::StripRight (const char *charset)
|
||||||
{
|
{
|
||||||
size_t max = Len(), i;
|
size_t max = Len(), i;
|
||||||
if (max == 0) return;
|
if (max == 0) return;
|
||||||
for (i = max; i-- > 0; )
|
for (i = --max; i-- > 0; )
|
||||||
{
|
{
|
||||||
if (!strchr (charset, Chars[i]))
|
if (!strchr (charset, Chars[i]))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (i == max)
|
||||||
|
{ // Nothing to strip.
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Data()->RefCount <= 1)
|
if (Data()->RefCount <= 1)
|
||||||
{
|
{
|
||||||
Chars[i+1] = '\0';
|
Chars[i+1] = '\0';
|
||||||
|
@ -701,6 +764,10 @@ void FString::StripLeftRight ()
|
||||||
if (!isspace(Chars[j]))
|
if (!isspace(Chars[j]))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (i == 0 && j == max - 1)
|
||||||
|
{ // Nothing to strip.
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Data()->RefCount <= 1)
|
if (Data()->RefCount <= 1)
|
||||||
{
|
{
|
||||||
for (k = 0; i <= j; ++i, ++k)
|
for (k = 0; i <= j; ++i, ++k)
|
||||||
|
@ -713,8 +780,8 @@ void FString::StripLeftRight ()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FStringData *old = Data();
|
FStringData *old = Data();
|
||||||
AllocBuffer (j - i);
|
AllocBuffer(j - i + 1);
|
||||||
StrCopy (Chars, old->Chars(), j - i);
|
StrCopy(Chars, old->Chars(), j - i + 1);
|
||||||
old->Release();
|
old->Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -768,26 +835,29 @@ void FString::Insert (size_t index, const char *instr)
|
||||||
|
|
||||||
void FString::Insert (size_t index, const char *instr, size_t instrlen)
|
void FString::Insert (size_t index, const char *instr, size_t instrlen)
|
||||||
{
|
{
|
||||||
|
if (instrlen > 0)
|
||||||
|
{
|
||||||
size_t mylen = Len();
|
size_t mylen = Len();
|
||||||
if (index > mylen)
|
if (index >= mylen)
|
||||||
{
|
{
|
||||||
index = mylen;
|
AppendCStrPart(instr, instrlen);
|
||||||
}
|
}
|
||||||
if (Data()->RefCount <= 1)
|
else if (Data()->RefCount <= 1)
|
||||||
{
|
{
|
||||||
ReallocBuffer (mylen + instrlen);
|
ReallocBuffer(mylen + instrlen);
|
||||||
memmove (Chars + index + instrlen, Chars + index, (mylen - index + 1)*sizeof(char));
|
memmove(Chars + index + instrlen, Chars + index, (mylen - index + 1) * sizeof(char));
|
||||||
memcpy (Chars + index, instr, instrlen*sizeof(char));
|
memcpy(Chars + index, instr, instrlen * sizeof(char));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FStringData *old = Data();
|
FStringData *old = Data();
|
||||||
AllocBuffer (mylen + instrlen);
|
AllocBuffer(mylen + instrlen);
|
||||||
StrCopy (Chars, old->Chars(), index);
|
StrCopy(Chars, old->Chars(), index);
|
||||||
StrCopy (Chars + index, instr, instrlen);
|
StrCopy(Chars + index, instr, instrlen);
|
||||||
StrCopy (Chars + index + instrlen, old->Chars() + index, mylen - index);
|
StrCopy(Chars + index + instrlen, old->Chars() + index, mylen - index);
|
||||||
old->Release();
|
old->Release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FString::ReplaceChars (char oldchar, char newchar)
|
void FString::ReplaceChars (char oldchar, char newchar)
|
||||||
|
|
|
@ -268,6 +268,7 @@ public:
|
||||||
bool IsNotEmpty() const { return Len() != 0; }
|
bool IsNotEmpty() const { return Len() != 0; }
|
||||||
|
|
||||||
void Truncate (long newlen);
|
void Truncate (long newlen);
|
||||||
|
void Remove(size_t index, size_t remlen);
|
||||||
|
|
||||||
int Compare (const FString &other) const { return strcmp (Chars, other.Chars); }
|
int Compare (const FString &other) const { return strcmp (Chars, other.Chars); }
|
||||||
int Compare (const char *other) const { return strcmp (Chars, other); }
|
int Compare (const char *other) const { return strcmp (Chars, other); }
|
||||||
|
|
Loading…
Reference in a new issue