Share the comment scanners of the view builder with materialize()

skip_line_comment() and find_block_comment_end() in scan.hpp are used by
the builder's comment() and by position_source::container_end(), which
had its own copy.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-28 07:09:21 +01:00
1 parent eb7d77e448
commit c6708926f6
4 files changed
+75 -62

No files matched your search

+5 -20
View File
@@ -173,31 +173,16 @@ class builder
}
if (p[1] == '/')
{
p += 2;
// (as in parse(), a null byte is the end of the input, so it is
// left for the caller to see)
while (p != m_end && *p != '\n' && *p != '\r' && !(NulIsEnd && *p == 0))
{
++p;
}
return p;
return skip_line_comment<NulIsEnd>(p + 2, m_end);
}
if (p[1] == '*')
{
p += 2;
for (;;)
p = find_block_comment_end<NulIsEnd>(p + 2, m_end);
if (p == m_end || *p != '*')
{
if (p == m_end || (NulIsEnd && *p == 0))
{
return fail_at(error_code::comment_unterminated, p);
}
if (*p == '*' && p + 1 != m_end && p[1] == '/')
{
p += 2;
return p;
}
++p;
return fail_at(error_code::comment_unterminated, p);
}
return p + 2;
}
++p;
return fail_at(error_code::comment_start, p);