aboutsummaryrefslogtreecommitdiff
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2026-09-09 13:01:40 +0200
committercrueter <crueter@eden-emu.dev>2026-09-09 13:01:40 +0200
commited57836903804f05a0b2c9e84f1eaabb59503bed (patch)
tree80f75ec7423521e5cf363c3c1c83401a83b1fc73 /src/core/file_sys
parent20f9aa4cfecf6b17735e0c8d7faa21e5d9388cfd (diff)
[ips_layer] remove trailing whitespace to fix hex parsing on TLTD mods (#4336)
Signed-off-by: lizzie <lizzie@eden-emu.dev> - [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions). - [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md) - [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability. ------------------- ...another edge case, this time with `00297f24 34008052 // 60FPS` would get parsed as `34008052 ` which isn't quite correct Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4336 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: Maufeat <sahyno1996@gmail.com>
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/ips_layer.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/core/file_sys/ips_layer.cpp b/src/core/file_sys/ips_layer.cpp
index 1df2f9dadd..9d46549bf0 100644
--- a/src/core/file_sys/ips_layer.cpp
+++ b/src/core/file_sys/ips_layer.cpp
@@ -120,7 +120,7 @@ std::array<u8, 32> IPSwitchCompiler::GetBuildID() const {
static IPSwitchRecord EscapeStringSequences(std::string_view sv) {
IPSwitchRecord r{};
- for (auto it = sv.cbegin(); it != sv.cend(); ) {
+ for (auto it = sv.cbegin(); it < sv.cend(); ) {
if (*it == '\\' && it + 1 < sv.cend()) {
switch (it[1]) {
case 'a': r.data[r.count] = '\a'; break;
@@ -198,6 +198,8 @@ void IPSwitchCompiler::Parse(std::span<u8 const> bytes) {
LOG_WARNING(Loader, "Unknown flag {}", line);
break;
}
+ } else if (patches.empty()) {
+ LOG_WARNING(Loader, "Invalid line not in a patch {}", line);
} else {
size_t offset = size_t(std::strtoul(line.data(), nullptr, 16));
offset += size_t(offset_shift);
@@ -253,25 +255,30 @@ void IPSwitchCompiler::Parse(std::span<u8 const> bytes) {
// now make a nominal preprocessed line: remove comments
char quote = '\0';
auto const sline_start = p;
+ auto last_char = p;
for (; p < sline.cend(); ) {
// we dont check for "//", IPS checks for '/' only...
- if ((!quote && p[0] == '/')
+ if (std::isspace(*p)) {
+ ++p;
+ } else if ((!quote && p[0] == '/')
|| (!quote && p[0] == '#')) {
break;
} else if (p[0] == '\"' || p[0] == '\'') {
quote = (p[0] == quote) ? '\0' : p[0];
++p;
+ last_char = p;
} else if (p + 1 < sline.cend() && p[0] == '\\') {
p += 2;
+ last_char = p;
} else {
++p;
+ last_char = p;
}
}
// now we have the preprocessed string ;)
- std::string_view pp_str(sline_start, p);
- if (pp_str.size() > 0 && !parse_line(pp_str)) {
+ std::string_view const pp_str(sline_start, last_char);
+ if (pp_str.size() > 0 && !parse_line(pp_str))
break;
- }
}
}
}