- changed FString API to use ptrdiff_t instead of long for signed size arguments.

This commit is contained in:
Christoph Oelckers 2021-08-12 00:45:59 +02:00
parent 1d96b68e1a
commit c3772fe203
18 changed files with 100 additions and 100 deletions

View file

@ -291,7 +291,7 @@ void FCommandBuffer::AddString(FString clip)
if (clip.IsNotEmpty()) if (clip.IsNotEmpty())
{ {
// Only paste the first line. // Only paste the first line.
long brk = clip.IndexOfAny("\r\n\b"); auto brk = clip.IndexOfAny("\r\n\b");
std::u32string build; std::u32string build;
if (brk >= 0) if (brk >= 0)
{ {

View file

@ -533,7 +533,7 @@ FString BuildString (int argc, FString *argv)
else if (strchr(argv[arg], '"')) else if (strchr(argv[arg], '"'))
{ // If it contains one or more quotes, we need to escape them. { // If it contains one or more quotes, we need to escape them.
buf << '"'; buf << '"';
long substr_start = 0, quotepos; ptrdiff_t substr_start = 0, quotepos;
while ((quotepos = argv[arg].IndexOf('"', substr_start)) >= 0) while ((quotepos = argv[arg].IndexOf('"', substr_start)) >= 0)
{ {
if (substr_start < quotepos) if (substr_start < quotepos)

View file

@ -435,7 +435,7 @@ void FStringTable::InsertString(int lumpnum, int langid, FName label, const FStr
{ {
const char *strlangid = (const char *)&langid; const char *strlangid = (const char *)&langid;
TableElement te = { fileSystem.GetFileContainer(lumpnum), { string, string, string, string } }; TableElement te = { fileSystem.GetFileContainer(lumpnum), { string, string, string, string } };
long index; ptrdiff_t index;
while ((index = te.strings[0].IndexOf("@[")) >= 0) while ((index = te.strings[0].IndexOf("@[")) >= 0)
{ {
auto endindex = te.strings[0].IndexOf(']', index); auto endindex = te.strings[0].IndexOf(']', index);

View file

@ -1546,7 +1546,7 @@ bool FileSystem::CreatePathlessCopy(const char *name, int id, int /*flags*/)
if (lump < 0) return false; // Does not exist. if (lump < 0) return false; // Does not exist.
auto oldlump = FileInfo[lump]; auto oldlump = FileInfo[lump];
int slash = oldlump.longName.LastIndexOf('/'); ptrdiff_t slash = oldlump.longName.LastIndexOf('/');
if (slash == -1) if (slash == -1)
{ {

View file

@ -348,8 +348,8 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize, LumpFilterI
uint32_t max = NumLumps; uint32_t max = NumLumps;
max -= FilterLumpsByGameType(filter, lumps, lumpsize, max); max -= FilterLumpsByGameType(filter, lumps, lumpsize, max);
long len; ptrdiff_t len;
int lastpos = -1; ptrdiff_t lastpos = -1;
FString file; FString file;
FString LumpFilter = filter->dotFilter; FString LumpFilter = filter->dotFilter;
while ((len = LumpFilter.IndexOf('.', lastpos+1)) > 0) while ((len = LumpFilter.IndexOf('.', lastpos+1)) > 0)

View file

@ -90,8 +90,8 @@ static int FindGFXFile(FString & fn)
if (lump != -1) return lump; if (lump != -1) return lump;
int best = -1; int best = -1;
int dot = fn.LastIndexOf('.'); auto dot = fn.LastIndexOf('.');
int slash = fn.LastIndexOf('/'); auto slash = fn.LastIndexOf('/');
if (dot > slash) fn.Truncate(dot); if (dot > slash) fn.Truncate(dot);
static const char * extensions[] = { ".png", ".jpg", ".tga", ".pcx", nullptr }; static const char * extensions[] = { ".png", ".jpg", ".tga", ".pcx", nullptr };

View file

@ -44,8 +44,8 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length
{ {
// Ensure usemtl statements remain intact // Ensure usemtl statements remain intact
TArray<FString> mtlUsages; TArray<FString> mtlUsages;
TArray<long> mtlUsageIdxs; TArray<ptrdiff_t> mtlUsageIdxs;
long bpos = 0, nlpos = 0, slashpos = 0; ptrdiff_t bpos = 0, nlpos = 0, slashpos = 0;
while (1) while (1)
{ {
bpos = objBuf.IndexOf("\nusemtl", bpos); bpos = objBuf.IndexOf("\nusemtl", bpos);
@ -58,7 +58,7 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length
} }
if (nlpos == -1) if (nlpos == -1)
{ {
nlpos = (long)objBuf.Len(); nlpos = objBuf.Len();
} }
FString lineStr(objBuf.GetChars() + bpos, nlpos - bpos); FString lineStr(objBuf.GetChars() + bpos, nlpos - bpos);
mtlUsages.Push(lineStr); mtlUsages.Push(lineStr);
@ -76,7 +76,7 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length
nlpos = objBuf.IndexOf('\n', bpos); nlpos = objBuf.IndexOf('\n', bpos);
if (nlpos == -1) if (nlpos == -1)
{ {
nlpos = (long)objBuf.Len(); nlpos = objBuf.Len();
} }
memcpy(wObjBuf + bpos, mtlUsages[i].GetChars(), nlpos - bpos); memcpy(wObjBuf + bpos, mtlUsages[i].GetChars(), nlpos - bpos);
} }

View file

@ -52,15 +52,15 @@ static bool IsGlslWhitespace(char c)
} }
} }
static FString NextGlslToken(const char *chars, long len, long &pos) static FString NextGlslToken(const char *chars, ptrdiff_t len, ptrdiff_t &pos)
{ {
// Eat whitespace // Eat whitespace
long tokenStart = pos; ptrdiff_t tokenStart = pos;
while (tokenStart != len && IsGlslWhitespace(chars[tokenStart])) while (tokenStart != len && IsGlslWhitespace(chars[tokenStart]))
tokenStart++; tokenStart++;
// Find token end // Find token end
long tokenEnd = tokenStart; ptrdiff_t tokenEnd = tokenStart;
while (tokenEnd != len && !IsGlslWhitespace(chars[tokenEnd]) && chars[tokenEnd] != ';') while (tokenEnd != len && !IsGlslWhitespace(chars[tokenEnd]) && chars[tokenEnd] != ';')
tokenEnd++; tokenEnd++;
@ -82,13 +82,13 @@ FString RemoveLegacyUserUniforms(FString code)
// The following code searches for legacy uniform declarations in the shader itself and replaces them with whitespace. // The following code searches for legacy uniform declarations in the shader itself and replaces them with whitespace.
long len = (long)code.Len(); ptrdiff_t len = code.Len();
char *chars = code.LockBuffer(); char *chars = code.LockBuffer();
long startIndex = 0; ptrdiff_t startIndex = 0;
while (true) while (true)
{ {
long matchIndex = code.IndexOf("uniform", startIndex); ptrdiff_t matchIndex = code.IndexOf("uniform", startIndex);
if (matchIndex == -1) if (matchIndex == -1)
break; break;
@ -98,7 +98,7 @@ FString RemoveLegacyUserUniforms(FString code)
bool isKeywordEnd = matchIndex + 7 == len || IsGlslWhitespace(chars[matchIndex + 7]); bool isKeywordEnd = matchIndex + 7 == len || IsGlslWhitespace(chars[matchIndex + 7]);
if (isKeywordStart && isKeywordEnd) if (isKeywordStart && isKeywordEnd)
{ {
long pos = matchIndex + 7; ptrdiff_t pos = matchIndex + 7;
FString type = NextGlslToken(chars, len, pos); FString type = NextGlslToken(chars, len, pos);
FString identifier = NextGlslToken(chars, len, pos); FString identifier = NextGlslToken(chars, len, pos);
@ -107,10 +107,10 @@ FString RemoveLegacyUserUniforms(FString code)
if (isLegacyUniformName) if (isLegacyUniformName)
{ {
long statementEndIndex = code.IndexOf(';', matchIndex + 7); ptrdiff_t statementEndIndex = code.IndexOf(';', matchIndex + 7);
if (statementEndIndex == -1) if (statementEndIndex == -1)
statementEndIndex = len; statementEndIndex = len;
for (long i = matchIndex; i <= statementEndIndex; i++) for (ptrdiff_t i = matchIndex; i <= statementEndIndex; i++)
{ {
if (!IsGlslWhitespace(chars[i])) if (!IsGlslWhitespace(chars[i]))
chars[i] = ' '; chars[i] = ' ';
@ -127,7 +127,7 @@ FString RemoveLegacyUserUniforms(FString code)
// Modern GLSL only allows use of 'texture'. // Modern GLSL only allows use of 'texture'.
while (true) while (true)
{ {
long matchIndex = code.IndexOf("texture2d", startIndex); ptrdiff_t matchIndex = code.IndexOf("texture2d", startIndex);
if (matchIndex == -1) if (matchIndex == -1)
break; break;
@ -148,14 +148,14 @@ FString RemoveLegacyUserUniforms(FString code)
FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &samplerstobind) FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &samplerstobind)
{ {
long len = (long)code.Len(); ptrdiff_t len = code.Len();
char *chars = code.LockBuffer(); char *chars = code.LockBuffer();
long startIndex = 0; ptrdiff_t startIndex = 0;
long startpos, endpos; ptrdiff_t startpos, endpos;
while (true) while (true)
{ {
long matchIndex = code.IndexOf("layout(binding", startIndex); ptrdiff_t matchIndex = code.IndexOf("layout(binding", startIndex);
if (matchIndex == -1) if (matchIndex == -1)
break; break;
@ -165,7 +165,7 @@ FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &sam
bool isKeywordEnd = matchIndex + 14 == len || IsGlslWhitespace(chars[matchIndex + 14]) || chars[matchIndex + 14] == '='; bool isKeywordEnd = matchIndex + 14 == len || IsGlslWhitespace(chars[matchIndex + 14]) || chars[matchIndex + 14] == '=';
if (isKeywordStart && isKeywordEnd) if (isKeywordStart && isKeywordEnd)
{ {
long pos = matchIndex + 14; ptrdiff_t pos = matchIndex + 14;
startpos = matchIndex; startpos = matchIndex;
while (IsGlslWhitespace(chars[pos])) pos++; while (IsGlslWhitespace(chars[pos])) pos++;
if (chars[pos] == '=') if (chars[pos] == '=')
@ -175,7 +175,7 @@ FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &sam
auto val = strtol(&chars[pos], &p, 0); auto val = strtol(&chars[pos], &p, 0);
if (p != &chars[pos]) if (p != &chars[pos])
{ {
pos = long(p - chars); pos = (p - chars);
while (IsGlslWhitespace(chars[pos])) pos++; while (IsGlslWhitespace(chars[pos])) pos++;
if (chars[pos] == ')') if (chars[pos] == ')')
{ {
@ -216,17 +216,17 @@ FString RemoveSamplerBindings(FString code, TArray<std::pair<FString, int>> &sam
FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword) FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword)
{ {
long len = (long)code.Len(); ptrdiff_t len = code.Len();
char *chars = code.LockBuffer(); char *chars = code.LockBuffer();
long startIndex = 0; ptrdiff_t startIndex = 0;
while (true) while (true)
{ {
long matchIndex = code.IndexOf("layout(location", startIndex); ptrdiff_t matchIndex = code.IndexOf("layout(location", startIndex);
if (matchIndex == -1) if (matchIndex == -1)
break; break;
long endIndex = matchIndex; ptrdiff_t endIndex = matchIndex;
// Find end of layout declaration // Find end of layout declaration
while (chars[endIndex] != ')' && chars[endIndex] != 0) while (chars[endIndex] != ')' && chars[endIndex] != 0)
@ -255,7 +255,7 @@ FString RemoveLayoutLocationDecl(FString code, const char *inoutkeyword)
if (keywordFound && IsGlslWhitespace(chars[endIndex + i])) if (keywordFound && IsGlslWhitespace(chars[endIndex + i]))
{ {
// yes - replace declaration with spaces // yes - replace declaration with spaces
for (long i = matchIndex; i < endIndex; i++) for (auto i = matchIndex; i < endIndex; i++)
chars[i] = ' '; chars[i] = ' ';
} }

View file

@ -419,7 +419,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, Filter, StringFilter)
static int StringIndexOf(FString *self, const FString &substr, int startIndex) static int StringIndexOf(FString *self, const FString &substr, int startIndex)
{ {
return self->IndexOf(substr, startIndex); return (int)self->IndexOf(substr, startIndex);
} }
DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, IndexOf, StringIndexOf) DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, IndexOf, StringIndexOf)
@ -427,12 +427,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, IndexOf, StringIndexOf)
PARAM_SELF_STRUCT_PROLOGUE(FString); PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(substr); PARAM_STRING(substr);
PARAM_INT(startIndex); PARAM_INT(startIndex);
ACTION_RETURN_INT(self->IndexOf(substr, startIndex)); ACTION_RETURN_INT(StringIndexOf(self, substr, startIndex));
} }
static int StringLastIndexOf(FString *self, const FString &substr, int endIndex) static int StringLastIndexOf(FString *self, const FString &substr, int endIndex)
{ {
return self->LastIndexOfBroken(substr, endIndex); return (int)self->LastIndexOfBroken(substr, endIndex);
} }
DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, LastIndexOf, StringLastIndexOf) DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, LastIndexOf, StringLastIndexOf)
@ -440,12 +440,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, LastIndexOf, StringLastIndexOf)
PARAM_SELF_STRUCT_PROLOGUE(FString); PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(substr); PARAM_STRING(substr);
PARAM_INT(endIndex); PARAM_INT(endIndex);
ACTION_RETURN_INT(self->LastIndexOfBroken(substr, endIndex)); ACTION_RETURN_INT(StringLastIndexOf(self, substr, endIndex));
} }
static int StringRightIndexOf(FString *self, const FString &substr, int endIndex) static int StringRightIndexOf(FString *self, const FString &substr, int endIndex)
{ {
return self->LastIndexOf(substr, endIndex); return (int)self->LastIndexOf(substr, endIndex);
} }
DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, RightIndexOf, StringRightIndexOf) DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, RightIndexOf, StringRightIndexOf)
@ -453,7 +453,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, RightIndexOf, StringRightIndexOf)
PARAM_SELF_STRUCT_PROLOGUE(FString); PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(substr); PARAM_STRING(substr);
PARAM_INT(endIndex); PARAM_INT(endIndex);
ACTION_RETURN_INT(self->LastIndexOf(substr, endIndex)); ACTION_RETURN_INT(StringRightIndexOf(self, substr, endIndex));
} }
static void StringToUpper(FString *self) static void StringToUpper(FString *self)

View file

@ -95,7 +95,7 @@ bool FPlayList::ChangeList (const char *path)
} }
// Check for relative paths. // Check for relative paths.
long slashpos = song.IndexOf('/'); auto slashpos = song.IndexOf('/');
if (slashpos == 0) if (slashpos == 0)
{ {

View file

@ -422,7 +422,7 @@ void FString::Remove(size_t index, size_t remlen)
{ {
if (index + remlen >= Len()) if (index + remlen >= Len())
{ {
Truncate((long)index); Truncate(index);
} }
else else
{ {
@ -500,12 +500,12 @@ void FString::DeleteLastCharacter()
} }
long FString::IndexOf (const FString &substr, long startIndex) const ptrdiff_t FString::IndexOf (const FString &substr, ptrdiff_t startIndex) const
{ {
return IndexOf (substr.Chars, startIndex); return IndexOf (substr.Chars, startIndex);
} }
long FString::IndexOf (const char *substr, long startIndex) const ptrdiff_t FString::IndexOf (const char *substr, ptrdiff_t startIndex) const
{ {
if (startIndex > 0 && Len() <= (size_t)startIndex) if (startIndex > 0 && Len() <= (size_t)startIndex)
{ {
@ -516,10 +516,10 @@ long FString::IndexOf (const char *substr, long startIndex) const
{ {
return -1; return -1;
} }
return long(str - Chars); return str - Chars;
} }
long FString::IndexOf (char subchar, long startIndex) const ptrdiff_t FString::IndexOf (char subchar, ptrdiff_t startIndex) const
{ {
if (startIndex > 0 && Len() <= (size_t)startIndex) if (startIndex > 0 && Len() <= (size_t)startIndex)
{ {
@ -530,15 +530,15 @@ long FString::IndexOf (char subchar, long startIndex) const
{ {
return -1; return -1;
} }
return long(str - Chars); return str - Chars;
} }
long FString::IndexOfAny (const FString &charset, long startIndex) const ptrdiff_t FString::IndexOfAny (const FString &charset, ptrdiff_t startIndex) const
{ {
return IndexOfAny (charset.Chars, startIndex); return IndexOfAny (charset.Chars, startIndex);
} }
long FString::IndexOfAny (const char *charset, long startIndex) const ptrdiff_t FString::IndexOfAny (const char *charset, ptrdiff_t startIndex) const
{ {
if (startIndex > 0 && Len() <= (size_t)startIndex) if (startIndex > 0 && Len() <= (size_t)startIndex)
{ {
@ -549,19 +549,19 @@ long FString::IndexOfAny (const char *charset, long startIndex) const
{ {
return -1; return -1;
} }
return long(brk - Chars); return brk - Chars;
} }
long FString::LastIndexOf (char subchar) const ptrdiff_t FString::LastIndexOf (char subchar) const
{ {
return LastIndexOf (subchar, long(Len())); return LastIndexOf (subchar, Len());
} }
long FString::LastIndexOf (char subchar, long endIndex) const ptrdiff_t FString::LastIndexOf (char subchar, ptrdiff_t endIndex) const
{ {
if ((size_t)endIndex > Len()) if ((size_t)endIndex > Len())
{ {
endIndex = long(Len()); endIndex = Len();
} }
while (--endIndex >= 0) while (--endIndex >= 0)
{ {
@ -573,16 +573,16 @@ long FString::LastIndexOf (char subchar, long endIndex) const
return -1; return -1;
} }
long FString::LastIndexOfBroken (const FString &_substr, long endIndex) const ptrdiff_t FString::LastIndexOfBroken (const FString &_substr, ptrdiff_t endIndex) const
{ {
const char *substr = _substr.GetChars(); const char *substr = _substr.GetChars();
size_t substrlen = _substr.Len(); size_t substrlen = _substr.Len();
if ((size_t)endIndex > Len()) if ((size_t)endIndex > Len())
{ {
endIndex = long(Len()); endIndex = Len();
} }
substrlen--; substrlen--;
while (--endIndex >= long(substrlen)) while (--endIndex >= ptrdiff_t(substrlen))
{ {
if (strncmp (substr, Chars + endIndex - substrlen, substrlen + 1) == 0) if (strncmp (substr, Chars + endIndex - substrlen, substrlen + 1) == 0)
{ {
@ -592,26 +592,26 @@ long FString::LastIndexOfBroken (const FString &_substr, long endIndex) const
return -1; return -1;
} }
long FString::LastIndexOfAny (const FString &charset) const ptrdiff_t FString::LastIndexOfAny (const FString &charset) const
{ {
return LastIndexOfAny (charset.Chars, long(Len())); return LastIndexOfAny (charset.Chars, Len());
} }
long FString::LastIndexOfAny (const char *charset) const ptrdiff_t FString::LastIndexOfAny (const char *charset) const
{ {
return LastIndexOfAny (charset, long(Len())); return LastIndexOfAny (charset, long(Len()));
} }
long FString::LastIndexOfAny (const FString &charset, long endIndex) const ptrdiff_t FString::LastIndexOfAny (const FString &charset, ptrdiff_t endIndex) const
{ {
return LastIndexOfAny (charset.Chars, endIndex); return LastIndexOfAny (charset.Chars, endIndex);
} }
long FString::LastIndexOfAny (const char *charset, long endIndex) const ptrdiff_t FString::LastIndexOfAny (const char *charset, ptrdiff_t endIndex) const
{ {
if ((size_t)endIndex > Len()) if ((size_t)endIndex > Len())
{ {
endIndex = long(Len()); endIndex = Len();
} }
while (--endIndex >= 0) while (--endIndex >= 0)
{ {
@ -623,31 +623,31 @@ long FString::LastIndexOfAny (const char *charset, long endIndex) const
return -1; return -1;
} }
long FString::LastIndexOf (const FString &substr) const ptrdiff_t FString::LastIndexOf (const FString &substr) const
{ {
return LastIndexOf(substr.Chars, long(Len() - substr.Len()), substr.Len()); return LastIndexOf(substr.Chars, Len() - substr.Len(), substr.Len());
} }
long FString::LastIndexOf (const FString &substr, long endIndex) const ptrdiff_t FString::LastIndexOf (const FString &substr, ptrdiff_t endIndex) const
{ {
return LastIndexOf(substr.Chars, endIndex, substr.Len()); return LastIndexOf(substr.Chars, endIndex, substr.Len());
} }
long FString::LastIndexOf (const char *substr) const ptrdiff_t FString::LastIndexOf (const char *substr) const
{ {
return LastIndexOf(substr, long(Len() - strlen(substr)), strlen(substr)); return LastIndexOf(substr, Len() - strlen(substr), strlen(substr));
} }
long FString::LastIndexOf (const char *substr, long endIndex) const ptrdiff_t FString::LastIndexOf (const char *substr, ptrdiff_t endIndex) const
{ {
return LastIndexOf(substr, endIndex, strlen(substr)); return LastIndexOf(substr, endIndex, strlen(substr));
} }
long FString::LastIndexOf (const char *substr, long endIndex, size_t substrlen) const ptrdiff_t FString::LastIndexOf (const char *substr, ptrdiff_t endIndex, size_t substrlen) const
{ {
if ((size_t)endIndex + substrlen > Len()) if ((size_t)endIndex + substrlen > Len())
{ {
endIndex = long(Len() - substrlen); endIndex = Len() - substrlen;
} }
while (endIndex >= 0) while (endIndex >= 0)
{ {
@ -1256,15 +1256,15 @@ void FString::Split(TArray<FString>& tokens, const char *delimiter, EmptyTokenTy
{ {
assert(nullptr != delimiter); assert(nullptr != delimiter);
const long selfLen = static_cast<long>(Len()); const auto selfLen = static_cast<ptrdiff_t>(Len());
const long delimLen = static_cast<long>(strlen(delimiter)); const auto delimLen = static_cast<ptrdiff_t>(strlen(delimiter));
long lastPos = 0; ptrdiff_t lastPos = 0;
if (selfLen == 0) return; // Empty strings do not contain tokens, even with TOK_KEEPEMPTY. if (selfLen == 0) return; // Empty strings do not contain tokens, even with TOK_KEEPEMPTY.
while (lastPos <= selfLen) while (lastPos <= selfLen)
{ {
long pos = IndexOf(delimiter, lastPos); auto pos = IndexOf(delimiter, lastPos);
if (-1 == pos) if (-1 == pos)
{ {

View file

@ -215,28 +215,28 @@ public:
void AppendCharacter(int codepoint); void AppendCharacter(int codepoint);
void DeleteLastCharacter(); void DeleteLastCharacter();
long IndexOf (const FString &substr, long startIndex=0) const; ptrdiff_t IndexOf (const FString &substr, ptrdiff_t startIndex=0) const;
long IndexOf (const char *substr, long startIndex=0) const; ptrdiff_t IndexOf (const char *substr, ptrdiff_t startIndex=0) const;
long IndexOf (char subchar, long startIndex=0) const; ptrdiff_t IndexOf (char subchar, ptrdiff_t startIndex=0) const;
long IndexOfAny (const FString &charset, long startIndex=0) const; ptrdiff_t IndexOfAny (const FString &charset, ptrdiff_t startIndex=0) const;
long IndexOfAny (const char *charset, long startIndex=0) const; ptrdiff_t IndexOfAny (const char *charset, ptrdiff_t startIndex=0) const;
// This is only kept for backwards compatibility with old ZScript versions that used this function and depend on its bug. // This is only kept for backwards compatibility with old ZScript versions that used this function and depend on its bug.
long LastIndexOf (char subchar) const; ptrdiff_t LastIndexOf (char subchar) const;
long LastIndexOfBroken (const FString &substr, long endIndex) const; ptrdiff_t LastIndexOfBroken (const FString &substr, ptrdiff_t endIndex) const;
long LastIndexOf (char subchar, long endIndex) const; ptrdiff_t LastIndexOf (char subchar, ptrdiff_t endIndex) const;
long LastIndexOfAny (const FString &charset) const; ptrdiff_t LastIndexOfAny (const FString &charset) const;
long LastIndexOfAny (const char *charset) const; ptrdiff_t LastIndexOfAny (const char *charset) const;
long LastIndexOfAny (const FString &charset, long endIndex) const; ptrdiff_t LastIndexOfAny (const FString &charset, ptrdiff_t endIndex) const;
long LastIndexOfAny (const char *charset, long endIndex) const; ptrdiff_t LastIndexOfAny (const char *charset, ptrdiff_t endIndex) const;
long LastIndexOf (const FString &substr) const; ptrdiff_t LastIndexOf (const FString &substr) const;
long LastIndexOf (const FString &substr, long endIndex) const; ptrdiff_t LastIndexOf (const FString &substr, ptrdiff_t endIndex) const;
long LastIndexOf (const char *substr) const; ptrdiff_t LastIndexOf (const char *substr) const;
long LastIndexOf (const char *substr, long endIndex) const; ptrdiff_t LastIndexOf (const char *substr, ptrdiff_t endIndex) const;
long LastIndexOf (const char *substr, long endIndex, size_t substrlen) const; ptrdiff_t LastIndexOf (const char *substr, ptrdiff_t endIndex, size_t substrlen) const;
void ToUpper (); void ToUpper ();
void ToLower (); void ToLower ();

View file

@ -762,7 +762,7 @@ int FIWadManager::IdentifyVersion (TArray<FString> &wadfiles, const char *iwad,
FString path; FString path;
if (info.Load[i][0] != ':') if (info.Load[i][0] != ':')
{ {
long lastslash = picks[pick].mFullPath.LastIndexOf('/'); auto lastslash = picks[pick].mFullPath.LastIndexOf('/');
if (lastslash == -1) if (lastslash == -1)
{ {

View file

@ -2122,8 +2122,8 @@ static void AddAutoloadFiles(const char *autoname)
// Add common (global) wads // Add common (global) wads
D_AddConfigFiles(allwads, "Global.Autoload", "*.wad", GameConfig); D_AddConfigFiles(allwads, "Global.Autoload", "*.wad", GameConfig);
long len; ptrdiff_t len;
int lastpos = -1; ptrdiff_t lastpos = -1;
while ((len = LumpFilterIWAD.IndexOf('.', lastpos+1)) > 0) while ((len = LumpFilterIWAD.IndexOf('.', lastpos+1)) > 0)
{ {

View file

@ -255,7 +255,7 @@ void FGameConfigFile::DoAutoloadSetup (FIWadManager *iwad_man)
{ {
FString section = workname + ".Autoload"; FString section = workname + ".Autoload";
CreateSectionAtStart(section.GetChars()); CreateSectionAtStart(section.GetChars());
long dotpos = workname.LastIndexOf('.'); auto dotpos = workname.LastIndexOf('.');
if (dotpos < 0) break; if (dotpos < 0) break;
workname.Truncate(dotpos); workname.Truncate(dotpos);
} }

View file

@ -635,7 +635,7 @@ void M_ScreenShot (const char *filename)
if (!screenshot_quiet) if (!screenshot_quiet)
{ {
int slash = -1; ptrdiff_t slash = -1;
if (!longsavemessages) slash = autoname.LastIndexOfAny(":/\\"); if (!longsavemessages) slash = autoname.LastIndexOfAny(":/\\");
Printf ("Captured %s\n", autoname.GetChars()+slash+1); Printf ("Captured %s\n", autoname.GetChars()+slash+1);
} }

View file

@ -1001,13 +1001,13 @@ static FString CreateCacheName(MapData *map, bool create)
{ {
FString path = M_GetCachePath(create); FString path = M_GetCachePath(create);
FString lumpname = fileSystem.GetFileFullPath(map->lumpnum); FString lumpname = fileSystem.GetFileFullPath(map->lumpnum);
int separator = lumpname.IndexOf(':'); auto separator = lumpname.IndexOf(':');
path << '/' << lumpname.Left(separator); path << '/' << lumpname.Left(separator);
if (create) CreatePath(path); if (create) CreatePath(path);
lumpname.ReplaceChars('/', '%'); lumpname.ReplaceChars('/', '%');
lumpname.ReplaceChars(':', '$'); lumpname.ReplaceChars(':', '$');
path << '/' << lumpname.Right(lumpname.Len() - separator - 1) << ".gzc"; path << '/' << lumpname.Right((ptrdiff_t)lumpname.Len() - separator - 1) << ".gzc";
return path; return path;
} }

View file

@ -808,12 +808,12 @@ FxMultiNameState::FxMultiNameState(const char *_statestring, const FScriptPositi
{ {
FName scopename = NAME_None; FName scopename = NAME_None;
FString statestring = _statestring; FString statestring = _statestring;
int scopeindex = statestring.IndexOf("::"); auto scopeindex = statestring.IndexOf("::");
if (scopeindex >= 0) if (scopeindex >= 0)
{ {
scopename = FName(statestring, scopeindex, false); scopename = FName(statestring, scopeindex, false);
statestring = statestring.Right(statestring.Len() - scopeindex - 2); statestring = statestring.Right((ptrdiff_t)statestring.Len() - scopeindex - 2);
} }
names = MakeStateNameList(statestring); names = MakeStateNameList(statestring);
names.Insert(0, scopename); names.Insert(0, scopename);