mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-12 07:48:16 -05:00
Use escaped strings with simple lexer whenever appropriate
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
#include "StringFileDumper.h"
|
||||
#include <regex>
|
||||
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
StringFileDumper::StringFileDumper(Zone* zone, std::ostream& stream)
|
||||
: AbstractTextDumper(stream),
|
||||
m_zone(zone),
|
||||
@ -44,11 +46,10 @@ void StringFileDumper::WriteLocalizeEntry(const std::string& reference, const st
|
||||
m_stream << "\n";
|
||||
m_stream << "REFERENCE " << reference << "\n";
|
||||
|
||||
auto escapedValue = std::regex_replace(value, std::regex("\n"), "\\n");
|
||||
escapedValue = std::regex_replace(escapedValue, std::regex("\r"), "\\r");
|
||||
|
||||
const auto valueSpacing = std::string(15 - m_language_caps.length(), ' ');
|
||||
m_stream << "LANG_" << m_language_caps << valueSpacing << "\"" << escapedValue << "\"\n";
|
||||
m_stream << "LANG_" << m_language_caps << valueSpacing << "\"";
|
||||
utils::EscapeStringForQuotationMarks(m_stream, value);
|
||||
m_stream << "\"\n";
|
||||
}
|
||||
|
||||
void StringFileDumper::Finalize()
|
||||
|
@ -70,6 +70,7 @@ std::vector<std::string> AbstractMenuDumper::CreateScriptTokenList(const char* s
|
||||
SimpleLexer::Config lexerConfig;
|
||||
lexerConfig.m_emit_new_line_tokens = false;
|
||||
lexerConfig.m_read_strings = true;
|
||||
lexerConfig.m_string_escape_sequences = true;
|
||||
lexerConfig.m_read_integer_numbers = false;
|
||||
lexerConfig.m_read_floating_point_numbers = false;
|
||||
SimpleLexer lexer(&inputStream, std::move(lexerConfig));
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "Utils/Alignment.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
StructuredDataDefDumper::StructuredDataDefDumper(std::ostream& stream)
|
||||
: AbstractTextDumper(stream),
|
||||
@ -37,7 +38,9 @@ void StructuredDataDefDumper::DumpEnum(const CommonStructuredDataEnum& _enum)
|
||||
for (auto i = 0u; i < entryCount; i++)
|
||||
{
|
||||
Indent();
|
||||
m_stream << "\"" << _enum.m_entries[i].m_name << "\"";
|
||||
m_stream << "\"";
|
||||
utils::EscapeStringForQuotationMarks(m_stream, _enum.m_entries[i].m_name);
|
||||
m_stream << "\"";
|
||||
|
||||
if (i + 1 < entryCount)
|
||||
m_stream << ",";
|
||||
|
Reference in New Issue
Block a user