overlaytopleft/games-fps/gzdoom/files/0010-Fix-StripLeftRight.patch

46 lines
1.3 KiB
Diff
Raw Normal View History

From f4374179284cc9581c8ec7d629d1e93cfd443b16 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= <ricolvs123@gmail.com>
Date: Sun, 18 Dec 2022 21:19:18 -0300
Subject: [PATCH 10/51] Fix StripLeftRight
---
src/common/utility/zstring.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/common/utility/zstring.cpp b/src/common/utility/zstring.cpp
index 8d4d4d119..2b3c4f1fe 100644
--- a/src/common/utility/zstring.cpp
+++ b/src/common/utility/zstring.cpp
@@ -843,7 +843,7 @@ void FString::StripLeftRight ()
}
for (j = max - 1; j >= i; --j)
{
- if (Chars[i] < 0 || !isspace((unsigned char)Chars[j]))
+ if (Chars[j] < 0 || !isspace((unsigned char)Chars[j]))
break;
}
if (i == 0 && j == max - 1)
@@ -863,7 +863,7 @@ void FString::StripLeftRight ()
{
FStringData *old = Data();
AllocBuffer(j - i + 1);
- StrCopy(Chars, old->Chars(), j - i + 1);
+ StrCopy(Chars, old->Chars() + i, j - i + 1);
old->Release();
}
}
@@ -899,8 +899,8 @@ void FString::StripLeftRight (const char *charset)
else
{
FStringData *old = Data();
- AllocBuffer (j - i);
- StrCopy (Chars, old->Chars(), j - i);
+ AllocBuffer (j - i + 1);
+ StrCopy (Chars, old->Chars() + i, j - i + 1);
old->Release();
}
}
--
2.39.3