Skip to content

Commit

Permalink
Upgrade to latest libfyaml (multiline comments work)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Oct 18, 2021
1 parent b7e5cdd commit ee3b6d5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "3rdparty/nanogui"]
path = 3rdparty/nanogui
url = https://github.com/MRPT/nanogui.git
[submodule "3rdparty/libfyaml"]
path = 3rdparty/libfyaml
url = https://github.com/MRPT/libfyaml.git
[submodule "3rdparty/libfreenect"]
path = 3rdparty/libfreenect
url = https://github.com/OpenKinect/libfreenect.git
Expand All @@ -22,3 +19,6 @@
[submodule "3rdparty/nanoflann"]
path = 3rdparty/nanoflann
url = https://github.com/jlblancoc/nanoflann.git
[submodule "3rdparty/libfyaml"]
path = 3rdparty/libfyaml
url = https://github.com/pantoniou/libfyaml.git
2 changes: 1 addition & 1 deletion 3rdparty/libfyaml
27 changes: 3 additions & 24 deletions libs/containers/src/yaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,31 +793,10 @@ static std::optional<std::string> extractComment(
{
std::array<char, 2048> str;
const char* strRet = fy_token_get_comment(t, str.data(), str.size(), cp);
if (!strRet) return {};
if (!strRet || strRet[0] == '\0') return {};

std::string c(str.data());

// Remove trailing "# " in each line:
size_t i = 0;
while (i < c.size())
{
const bool startOfLine =
i == 0 || (c[i - 1] == '\r' || c[i - 1] == '\n');
if (startOfLine && i < c.size() && c[i] == '#')
{
// process comment:
const size_t charsToRemove =
(i + 2 < c.size() && c[i + 1] == ' ' && c[i + 2] == ' ')
? 3
: ((i + 1 < c.size() && c[i + 1] == ' ') ? 2 : 1);
c.erase(i, charsToRemove);
}
else
{
// No comment:
i++;
}
}
// str is already a 0-terminated string:
const std::string c(str.data());

PARSER_DBG_OUT("Comment [" << (int)cp << "]: '" << c << "'\n");

Expand Down

0 comments on commit ee3b6d5

Please sign in to comment.