Skip to content

Commit

Permalink
updated Bugfix #204 when using CDATA
Browse files Browse the repository at this point in the history
  • Loading branch information
kmfrank committed Nov 13, 2024
1 parent 77c52c6 commit ce49c7d
Showing 1 changed file with 105 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1600,9 +1600,41 @@ namespace NET_ASAM_OPENSCENARIO
const auto kContent = customCommandActionWriter->GetContent();

//Modification: when parsing files with half tabs the format get mixed up
auto modifiedContent = kContent.substr(1, kContent.size());
modifiedContent = "\n\t\t" + modifiedContent;
modifiedContent.append("\t\t");
std::string modifiedContent;

int countNewline = 0;
std::string substringNewLine = "\n";

for (size_t offset = kContent.find(substringNewLine); offset != std::string::npos; offset = kContent.find(substringNewLine, offset + substringNewLine.length()))
{
++countNewline;
}

if (countNewline != 2)
{
//missing \n after CData
int countTabs = 0;
std::string substringTabs = "\t";

for (size_t offset = kContent.find(substringTabs); offset != std::string::npos; offset = kContent.find(substringTabs, offset + substringTabs.length()))
{
++countTabs;
}

modifiedContent = kContent.substr(1, kContent.size());
modifiedContent = "\n\t\t" + modifiedContent;
modifiedContent.append("\n");
for (int i = 0; i < countTabs + 1; i++)
{
modifiedContent.append("\t");
}
}
else
{
modifiedContent = kContent.substr(1, kContent.size());
modifiedContent = "\n\t\t" + modifiedContent;
modifiedContent.append("\t\t");
}

if (!kContent.empty())
{
Expand All @@ -1626,9 +1658,41 @@ namespace NET_ASAM_OPENSCENARIO
const auto kContent = customContentWriter->GetContent();

//Modification: when parsing files with half tabs the format get mixed up
auto modifiedContent = kContent.substr(1, kContent.size());
modifiedContent = "\n\t\t" + modifiedContent;
modifiedContent.append("\t\t");
std::string modifiedContent;

int countNewline = 0;
std::string substringNewLine = "\n";

for (size_t offset = kContent.find(substringNewLine); offset != std::string::npos; offset = kContent.find(substringNewLine, offset + substringNewLine.length()))
{
++countNewline;
}

if (countNewline != 2)
{
//missing \n after CData
int countTabs = 0;
std::string substringTabs = "\t";

for (size_t offset = kContent.find(substringTabs); offset != std::string::npos; offset = kContent.find(substringTabs, offset + substringTabs.length()))
{
++countTabs;
}

modifiedContent = kContent.substr(1, kContent.size());
modifiedContent = "\n\t\t" + modifiedContent;
modifiedContent.append("\n");
for (int i = 0; i < countTabs + 1; i++)
{
modifiedContent.append("\t");
}
}
else
{
modifiedContent = kContent.substr(1, kContent.size());
modifiedContent = "\n\t\t" + modifiedContent;
modifiedContent.append("\t\t");
}

if (!kContent.empty())
{
Expand Down Expand Up @@ -7813,9 +7877,41 @@ namespace NET_ASAM_OPENSCENARIO
const auto kContent = userDefinedDistributionWriter->GetContent();

//Modification: when parsing files with half tabs the format get mixed up
auto modifiedContent = kContent.substr(1, kContent.size());
modifiedContent = "\n\t\t" + modifiedContent;
modifiedContent.append("\t\t");
std::string modifiedContent;

int countNewline = 0;
std::string substringNewLine = "\n";

for (size_t offset = kContent.find(substringNewLine); offset != std::string::npos; offset = kContent.find(substringNewLine, offset + substringNewLine.length()))
{
++countNewline;
}

if (countNewline != 2)
{
//missing \n after CData
int countTabs = 0;
std::string substringTabs = "\t";

for (size_t offset = kContent.find(substringTabs); offset != std::string::npos; offset = kContent.find(substringTabs, offset + substringTabs.length()))
{
++countTabs;
}

modifiedContent = kContent.substr(1, kContent.size());
modifiedContent = "\n\t\t" + modifiedContent;
modifiedContent.append("\n");
for (int i = 0; i < countTabs + 1; i++)
{
modifiedContent.append("\t");
}
}
else
{
modifiedContent = kContent.substr(1, kContent.size());
modifiedContent = "\n\t\t" + modifiedContent;
modifiedContent.append("\t\t");
}

if (!kContent.empty())
{
Expand Down

0 comments on commit ce49c7d

Please sign in to comment.