Skip to content

Commit 16e62c9

Browse files
monkeydomskystrife
authored andcommitted
Fix find_end_of_date to actually find the end of date (was eating all the whitespace behind a date to comment and failing)
E.g. date = 1990-01-01 # some comment
1 parent 13fb18e commit 16e62c9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

include/cpptoml.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,8 +2874,13 @@ class parser
28742874
std::string::iterator find_end_of_date(std::string::iterator it,
28752875
std::string::iterator end)
28762876
{
2877-
return std::find_if(it, end, [](char c) {
2878-
return !is_number(c) && c != 'T' && c != ' ' && c != 'Z' && c != ':'
2877+
auto end_of_date = std::find_if(it, end, [](char c) {
2878+
return !is_number(c) && c != '-';
2879+
});
2880+
if (*end_of_date == ' ' && is_number(end_of_date[1]))
2881+
end_of_date++;
2882+
return std::find_if(end_of_date, end, [](char c) {
2883+
return !is_number(c) && c != 'T' && c != 'Z' && c != ':'
28792884
&& c != '-' && c != '+' && c != '.';
28802885
});
28812886
}

0 commit comments

Comments
 (0)