mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-25 05:21:02 +00:00
Merge branch 'master' of https://github.com/rheit/zdoom into zscript
This commit is contained in:
commit
71e8f09126
3 changed files with 49 additions and 47 deletions
|
@ -1144,7 +1144,7 @@ CCMD(currentpos)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Printf("You are not in game!");
|
Printf("You are not in game!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -863,66 +863,34 @@ void FString::Insert (size_t index, const char *instr, size_t instrlen)
|
||||||
|
|
||||||
void FString::ReplaceChars (char oldchar, char newchar)
|
void FString::ReplaceChars (char oldchar, char newchar)
|
||||||
{
|
{
|
||||||
size_t i, j;
|
if (oldchar == '\0')
|
||||||
|
return;
|
||||||
|
|
||||||
LockBuffer();
|
ReplaceChars([&oldchar](char c){ return c == oldchar; }, newchar);
|
||||||
for (i = 0, j = Len(); i < j; ++i)
|
|
||||||
{
|
|
||||||
if (Chars[i] == oldchar)
|
|
||||||
{
|
|
||||||
Chars[i] = newchar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UnlockBuffer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FString::ReplaceChars (const char *oldcharset, char newchar)
|
void FString::ReplaceChars (const char *oldcharset, char newchar)
|
||||||
{
|
{
|
||||||
size_t i, j;
|
if (oldcharset == NULL || oldcharset[0] == '\0')
|
||||||
|
return;
|
||||||
|
|
||||||
LockBuffer();
|
ReplaceChars([&oldcharset](char c){ return strchr(oldcharset, c) != NULL; }, newchar);
|
||||||
for (i = 0, j = Len(); i < j; ++i)
|
|
||||||
{
|
|
||||||
if (strchr (oldcharset, Chars[i]) != NULL)
|
|
||||||
{
|
|
||||||
Chars[i] = newchar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UnlockBuffer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FString::StripChars (char killchar)
|
void FString::StripChars (char killchar)
|
||||||
{
|
{
|
||||||
size_t read, write, mylen;
|
if (killchar == '\0')
|
||||||
|
return;
|
||||||
|
|
||||||
LockBuffer();
|
StripChars([&killchar](char c){ return c == killchar; });
|
||||||
for (read = write = 0, mylen = Len(); read < mylen; ++read)
|
|
||||||
{
|
|
||||||
if (Chars[read] != killchar)
|
|
||||||
{
|
|
||||||
Chars[write++] = Chars[read];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Chars[write] = '\0';
|
|
||||||
ReallocBuffer (write);
|
|
||||||
UnlockBuffer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FString::StripChars (const char *killchars)
|
void FString::StripChars (const char *killcharset)
|
||||||
{
|
{
|
||||||
size_t read, write, mylen;
|
if (killcharset == NULL || killcharset[0] == '\0')
|
||||||
|
return;
|
||||||
|
|
||||||
LockBuffer();
|
StripChars([&killcharset](char c){ return strchr(killcharset, c) != NULL; });
|
||||||
for (read = write = 0, mylen = Len(); read < mylen; ++read)
|
|
||||||
{
|
|
||||||
if (strchr (killchars, Chars[read]) == NULL)
|
|
||||||
{
|
|
||||||
Chars[write++] = Chars[read];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Chars[write] = '\0';
|
|
||||||
ReallocBuffer (write);
|
|
||||||
UnlockBuffer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FString::MergeChars (char merger)
|
void FString::MergeChars (char merger)
|
||||||
|
|
|
@ -236,11 +236,45 @@ public:
|
||||||
void Insert (size_t index, const char *instr);
|
void Insert (size_t index, const char *instr);
|
||||||
void Insert (size_t index, const char *instr, size_t instrlen);
|
void Insert (size_t index, const char *instr, size_t instrlen);
|
||||||
|
|
||||||
|
template<typename Func>
|
||||||
|
void ReplaceChars (Func IsOldChar, char newchar)
|
||||||
|
{
|
||||||
|
size_t i, j;
|
||||||
|
|
||||||
|
LockBuffer();
|
||||||
|
for (i = 0, j = Len(); i < j; ++i)
|
||||||
|
{
|
||||||
|
if (IsOldChar(Chars[i]))
|
||||||
|
{
|
||||||
|
Chars[i] = newchar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UnlockBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
void ReplaceChars (char oldchar, char newchar);
|
void ReplaceChars (char oldchar, char newchar);
|
||||||
void ReplaceChars (const char *oldcharset, char newchar);
|
void ReplaceChars (const char *oldcharset, char newchar);
|
||||||
|
|
||||||
|
template<typename Func>
|
||||||
|
void StripChars (Func IsKillChar)
|
||||||
|
{
|
||||||
|
size_t read, write, mylen;
|
||||||
|
|
||||||
|
LockBuffer();
|
||||||
|
for (read = write = 0, mylen = Len(); read < mylen; ++read)
|
||||||
|
{
|
||||||
|
if (!IsKillChar(Chars[read]))
|
||||||
|
{
|
||||||
|
Chars[write++] = Chars[read];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Chars[write] = '\0';
|
||||||
|
ReallocBuffer (write);
|
||||||
|
UnlockBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
void StripChars (char killchar);
|
void StripChars (char killchar);
|
||||||
void StripChars (const char *killchars);
|
void StripChars (const char *killcharset);
|
||||||
|
|
||||||
void MergeChars (char merger);
|
void MergeChars (char merger);
|
||||||
void MergeChars (char merger, char newchar);
|
void MergeChars (char merger, char newchar);
|
||||||
|
|
Loading…
Reference in a new issue