mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-25 18:52:22 -05:00
6fd478b6ce
These instances were detected by searching for files that include AK/Format.h, but don't match the regex: \\b(CheckedFormatString|critical_dmesgln|dbgln|dbgln_if|dmesgln|FormatBu ilder|__FormatIfSupported|FormatIfSupported|FormatParser|FormatString|Fo rmattable|Formatter|__format_value|HasFormatter|max_format_arguments|out |outln|set_debug_enabled|StandardFormatter|TypeErasedFormatParams|TypeEr asedParameter|VariadicFormatParams|v_critical_dmesgln|vdbgln|vdmesgln|vf ormat|vout|warn|warnln|warnln_if)\\b (Without the linebreaks.) This regex is pessimistic, so there might be more files that don't actually use any formatting functions. Observe that this revealed that Userland/Libraries/LibC/signal.cpp is missing an include. In theory, one might use LibCPP to detect things like this automatically, but let's do this one step after another.
64 lines
1.5 KiB
C++
64 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibMarkdown/LineIterator.h>
|
|
|
|
namespace Markdown {
|
|
|
|
void LineIterator::reset_ignore_prefix()
|
|
{
|
|
for (auto& context : m_context_stack) {
|
|
context.ignore_prefix = false;
|
|
}
|
|
}
|
|
|
|
Optional<StringView> LineIterator::match_context(StringView line) const
|
|
{
|
|
bool is_ws = line.is_whitespace();
|
|
size_t offset = 0;
|
|
for (auto& context : m_context_stack) {
|
|
switch (context.type) {
|
|
case Context::Type::ListItem:
|
|
if (is_ws)
|
|
break;
|
|
|
|
if (offset + context.indent > line.length())
|
|
return {};
|
|
|
|
if (!context.ignore_prefix && !line.substring_view(offset, context.indent).is_whitespace())
|
|
return {};
|
|
|
|
offset += context.indent;
|
|
|
|
break;
|
|
case Context::Type::BlockQuote:
|
|
for (; offset < line.length() && line[offset] == ' '; ++offset) { }
|
|
if (offset >= line.length() || line[offset] != '>') {
|
|
return {};
|
|
}
|
|
++offset;
|
|
break;
|
|
}
|
|
|
|
if (offset > line.length())
|
|
return {};
|
|
}
|
|
return line.substring_view(offset);
|
|
}
|
|
|
|
bool LineIterator::is_end() const
|
|
{
|
|
return m_iterator.is_end() || !match_context(*m_iterator).has_value();
|
|
}
|
|
|
|
StringView LineIterator::operator*() const
|
|
{
|
|
auto line = match_context(*m_iterator);
|
|
VERIFY(line.has_value());
|
|
return line.value();
|
|
}
|
|
|
|
}
|