summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2024-11-07 16:52:39 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2024-12-30 20:13:59 -0600
commit0938fca6e360e8635ef3ce95985aaef837b9fb56 (patch)
tree2f05350d0f110417976aec34e4a6b5af90e48cfb /Source/Core
parent05cad38abc1d25f57500e530d63b545fa7b56499 (diff)
Core/VideoCommon: Fix some weird (!eof) logic.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/DSP/DSPAssembler.cpp9
-rw-r--r--Source/Core/VideoCommon/PostProcessing.cpp53
2 files changed, 28 insertions, 34 deletions
diff --git a/Source/Core/Core/DSP/DSPAssembler.cpp b/Source/Core/Core/DSP/DSPAssembler.cpp
index cb42085fb9..01ef9a81e5 100644
--- a/Source/Core/Core/DSP/DSPAssembler.cpp
+++ b/Source/Core/Core/DSP/DSPAssembler.cpp
@@ -776,14 +776,11 @@ bool DSPAssembler::AssemblePass(const std::string& text, int pass)
m_location.line_num = 0;
m_cur_pass = pass;
-#define LINEBUF_SIZE 1024
- char line[LINEBUF_SIZE] = {0};
- while (!m_failed && !fsrc.fail() && !fsrc.eof())
+ constexpr int LINEBUF_SIZE = 1024;
+ char line[LINEBUF_SIZE] = {};
+ while (!m_failed && fsrc.getline(line, LINEBUF_SIZE))
{
int opcode_size = 0;
- fsrc.getline(line, LINEBUF_SIZE);
- if (fsrc.fail())
- break;
m_location.line_text = line;
m_location.line_num++;
diff --git a/Source/Core/VideoCommon/PostProcessing.cpp b/Source/Core/VideoCommon/PostProcessing.cpp
index 7b66269ec7..e7ff694161 100644
--- a/Source/Core/VideoCommon/PostProcessing.cpp
+++ b/Source/Core/VideoCommon/PostProcessing.cpp
@@ -137,43 +137,40 @@ void PostProcessingConfiguration::LoadOptions(const std::string& code)
std::vector<GLSLStringOption> option_strings;
GLSLStringOption* current_strings = nullptr;
- while (!in.eof())
+ std::string line_str;
+ while (std::getline(in, line_str))
{
- std::string line_str;
- if (std::getline(in, line_str))
- {
- std::string_view line = line_str;
+ std::string_view line = line_str;
#ifndef _WIN32
- // Check for CRLF eol and convert it to LF
- if (!line.empty() && line.at(line.size() - 1) == '\r')
- line.remove_suffix(1);
+ // Check for CRLF eol and convert it to LF
+ if (!line.empty() && line.at(line.size() - 1) == '\r')
+ line.remove_suffix(1);
#endif
- if (!line.empty())
+ if (!line.empty())
+ {
+ if (line[0] == '[')
{
- if (line[0] == '[')
+ size_t endpos = line.find("]");
+
+ if (endpos != std::string::npos)
{
- size_t endpos = line.find("]");
-
- if (endpos != std::string::npos)
- {
- // New section!
- std::string_view sub = line.substr(1, endpos - 1);
- option_strings.push_back({std::string(sub)});
- current_strings = &option_strings.back();
- }
+ // New section!
+ std::string_view sub = line.substr(1, endpos - 1);
+ option_strings.push_back({std::string(sub)});
+ current_strings = &option_strings.back();
}
- else
+ }
+ else
+ {
+ if (current_strings)
{
- if (current_strings)
- {
- std::string key, value;
- Common::IniFile::ParseLine(line, &key, &value);
-
- if (!(key.empty() && value.empty()))
- current_strings->m_options.emplace_back(key, value);
- }
+ std::string key, value;
+ Common::IniFile::ParseLine(line, &key, &value);
+
+ if (!(key.empty() && value.empty()))
+ current_strings->m_options.emplace_back(key, value);
}
}
}