mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Fix defines proxy not correctly adding first line to escape line end define
This commit is contained in:
parent
8bf0126e38
commit
782b05a60b
@ -149,7 +149,7 @@ void DefinesStreamProxy::ContinueDefine(const ParserLine& line)
|
||||
const auto lineEndEscapePos = GetLineEndEscapePos(line);
|
||||
if (lineEndEscapePos < 0)
|
||||
{
|
||||
m_current_define_value << line.m_line << " ";
|
||||
m_current_define_value << line.m_line;
|
||||
m_current_define.m_value = m_current_define_value.str();
|
||||
m_current_define.IdentifyParameters(m_current_define_parameters);
|
||||
AddDefine(std::move(m_current_define));
|
||||
@ -162,7 +162,7 @@ void DefinesStreamProxy::ContinueDefine(const ParserLine& line)
|
||||
else
|
||||
{
|
||||
if (line.m_line.size() > static_cast<unsigned>(lineEndEscapePos))
|
||||
m_current_define_value << line.m_line.substr(0, static_cast<unsigned>(lineEndEscapePos)) << " ";
|
||||
m_current_define_value << line.m_line.substr(0, static_cast<unsigned>(lineEndEscapePos));
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,8 +245,8 @@ bool DefinesStreamProxy::MatchDefineDirective(const ParserLine& line, const unsi
|
||||
m_current_define_value.str(std::string());
|
||||
m_current_define_parameters = std::move(parameters);
|
||||
|
||||
if (currentPos < line.m_line.size() && (currentPos + 1) > static_cast<unsigned>(lineEndEscapePos))
|
||||
m_current_define_value << line.m_line.substr(currentPos + 1, static_cast<unsigned>(lineEndEscapePos) - (currentPos + 1)) << " ";
|
||||
if (currentPos < line.m_line.size() && (currentPos + 1) < static_cast<unsigned>(lineEndEscapePos))
|
||||
m_current_define_value << line.m_line.substr(currentPos + 1, static_cast<unsigned>(lineEndEscapePos) - (currentPos + 1));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -687,4 +687,23 @@ namespace test::parsing::impl::defines_stream_proxy
|
||||
|
||||
REQUIRE(proxy.Eof());
|
||||
}
|
||||
|
||||
TEST_CASE("DefinesStreamProxy: Ensure defines can go over multiple lines", "[parsing][parsingstream]")
|
||||
{
|
||||
const std::vector<std::string> lines
|
||||
{
|
||||
"#define someStuff(param1) Hello param1 World \\",
|
||||
"and hello universe",
|
||||
"someStuff(lovely)"
|
||||
};
|
||||
|
||||
MockParserLineStream mockStream(lines);
|
||||
DefinesStreamProxy proxy(&mockStream);
|
||||
|
||||
ExpectLine(&proxy, 1, "");
|
||||
ExpectLine(&proxy, 2, "");
|
||||
ExpectLine(&proxy, 3, "Hello lovely World and hello universe");
|
||||
|
||||
REQUIRE(proxy.Eof());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user