mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
LibRegex: Add some implied auto qualifiers
This commit is contained in:
parent
1fdd1915c2
commit
b674de6957
4 changed files with 10 additions and 10 deletions
|
@ -52,7 +52,7 @@ int regcomp(regex_t* reg, const char* pattern, int cflags)
|
||||||
// This could've been prevented if libc provided a reginit() or similar, but it does not.
|
// This could've been prevented if libc provided a reginit() or similar, but it does not.
|
||||||
reg->__data = new internal_regex_t { 0, 0, {}, 0, ReError::REG_NOERR, {} };
|
reg->__data = new internal_regex_t { 0, 0, {}, 0, ReError::REG_NOERR, {} };
|
||||||
|
|
||||||
auto preg = impl_from(reg);
|
auto* preg = impl_from(reg);
|
||||||
bool is_extended = cflags & REG_EXTENDED;
|
bool is_extended = cflags & REG_EXTENDED;
|
||||||
|
|
||||||
preg->cflags = cflags;
|
preg->cflags = cflags;
|
||||||
|
@ -82,7 +82,7 @@ int regcomp(regex_t* reg, const char* pattern, int cflags)
|
||||||
|
|
||||||
int regexec(const regex_t* reg, const char* string, size_t nmatch, regmatch_t pmatch[], int eflags)
|
int regexec(const regex_t* reg, const char* string, size_t nmatch, regmatch_t pmatch[], int eflags)
|
||||||
{
|
{
|
||||||
auto preg = impl_from(reg);
|
auto const* preg = impl_from(reg);
|
||||||
|
|
||||||
if (!preg->re.has_value() || preg->re_pat_err) {
|
if (!preg->re.has_value() || preg->re_pat_err) {
|
||||||
if (preg->re_pat_err)
|
if (preg->re_pat_err)
|
||||||
|
@ -213,7 +213,7 @@ inline static String get_error(ReError errcode)
|
||||||
size_t regerror(int errcode, const regex_t* reg, char* errbuf, size_t errbuf_size)
|
size_t regerror(int errcode, const regex_t* reg, char* errbuf, size_t errbuf_size)
|
||||||
{
|
{
|
||||||
String error;
|
String error;
|
||||||
auto preg = impl_from(reg);
|
auto const* preg = impl_from(reg);
|
||||||
|
|
||||||
if (!preg)
|
if (!preg)
|
||||||
error = get_error((ReError)errcode);
|
error = get_error((ReError)errcode);
|
||||||
|
@ -231,7 +231,7 @@ size_t regerror(int errcode, const regex_t* reg, char* errbuf, size_t errbuf_siz
|
||||||
|
|
||||||
void regfree(regex_t* reg)
|
void regfree(regex_t* reg)
|
||||||
{
|
{
|
||||||
auto preg = impl_from(reg);
|
auto* preg = impl_from(reg);
|
||||||
if (preg) {
|
if (preg) {
|
||||||
delete preg;
|
delete preg;
|
||||||
reg->__data = nullptr;
|
reg->__data = nullptr;
|
||||||
|
|
|
@ -502,7 +502,7 @@ ALWAYS_INLINE ExecutionResult OpCode_Compare::execute(MatchInput const& input, M
|
||||||
|
|
||||||
auto ch = input.view.substring_view(state.string_position, 1)[0];
|
auto ch = input.view.substring_view(state.string_position, 1)[0];
|
||||||
|
|
||||||
auto matching_range = binary_search(range_data, ch, nullptr, [insensitive = input.regex_options & AllFlags::Insensitive](auto needle, CharRange range) {
|
auto const* matching_range = binary_search(range_data, ch, nullptr, [insensitive = input.regex_options & AllFlags::Insensitive](auto needle, CharRange range) {
|
||||||
auto from = range.from;
|
auto from = range.from;
|
||||||
auto to = range.to;
|
auto to = range.to;
|
||||||
if (insensitive) {
|
if (insensitive) {
|
||||||
|
|
|
@ -130,13 +130,13 @@ RegexResult Matcher<Parser>::match(Vector<RegexStringView> const& views, Optiona
|
||||||
size_t lines_to_skip = 0;
|
size_t lines_to_skip = 0;
|
||||||
|
|
||||||
bool unicode = input.regex_options.has_flag_set(AllFlags::Unicode);
|
bool unicode = input.regex_options.has_flag_set(AllFlags::Unicode);
|
||||||
for (auto& view : views)
|
for (auto const& view : views)
|
||||||
const_cast<RegexStringView&>(view).set_unicode(unicode);
|
const_cast<RegexStringView&>(view).set_unicode(unicode);
|
||||||
|
|
||||||
if (input.regex_options.has_flag_set(AllFlags::Internal_Stateful)) {
|
if (input.regex_options.has_flag_set(AllFlags::Internal_Stateful)) {
|
||||||
if (views.size() > 1 && input.start_offset > views.first().length()) {
|
if (views.size() > 1 && input.start_offset > views.first().length()) {
|
||||||
dbgln_if(REGEX_DEBUG, "Started with start={}, goff={}, skip={}", input.start_offset, input.global_offset, lines_to_skip);
|
dbgln_if(REGEX_DEBUG, "Started with start={}, goff={}, skip={}", input.start_offset, input.global_offset, lines_to_skip);
|
||||||
for (auto& view : views) {
|
for (auto const& view : views) {
|
||||||
if (input.start_offset < view.length() + 1)
|
if (input.start_offset < view.length() + 1)
|
||||||
break;
|
break;
|
||||||
++lines_to_skip;
|
++lines_to_skip;
|
||||||
|
@ -181,7 +181,7 @@ RegexResult Matcher<Parser>::match(Vector<RegexStringView> const& views, Optiona
|
||||||
if (input.regex_options.has_flag_set(AllFlags::Internal_Stateful))
|
if (input.regex_options.has_flag_set(AllFlags::Internal_Stateful))
|
||||||
continue_search = false;
|
continue_search = false;
|
||||||
|
|
||||||
for (auto& view : views) {
|
for (auto const& view : views) {
|
||||||
if (lines_to_skip != 0) {
|
if (lines_to_skip != 0) {
|
||||||
++input.line;
|
++input.line;
|
||||||
--lines_to_skip;
|
--lines_to_skip;
|
||||||
|
|
|
@ -213,7 +213,7 @@ void Regex<Parser>::attempt_rewrite_loops_as_atomic_groups(BasicBlockList const&
|
||||||
if constexpr (REGEX_DEBUG) {
|
if constexpr (REGEX_DEBUG) {
|
||||||
RegexDebug dbg;
|
RegexDebug dbg;
|
||||||
dbg.print_bytecode(*this);
|
dbg.print_bytecode(*this);
|
||||||
for (auto& block : basic_blocks)
|
for (auto const& block : basic_blocks)
|
||||||
dbgln("block from {} to {}", block.start, block.end);
|
dbgln("block from {} to {}", block.start, block.end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ void Regex<Parser>::attempt_rewrite_loops_as_atomic_groups(BasicBlockList const&
|
||||||
auto is_an_eligible_jump = [](OpCode const& opcode, size_t ip, size_t block_start, AlternateForm alternate_form) {
|
auto is_an_eligible_jump = [](OpCode const& opcode, size_t ip, size_t block_start, AlternateForm alternate_form) {
|
||||||
switch (opcode.opcode_id()) {
|
switch (opcode.opcode_id()) {
|
||||||
case OpCodeId::JumpNonEmpty: {
|
case OpCodeId::JumpNonEmpty: {
|
||||||
auto& op = static_cast<OpCode_JumpNonEmpty const&>(opcode);
|
auto const& op = static_cast<OpCode_JumpNonEmpty const&>(opcode);
|
||||||
auto form = op.form();
|
auto form = op.form();
|
||||||
if (form != OpCodeId::Jump && alternate_form == AlternateForm::DirectLoopWithHeader)
|
if (form != OpCodeId::Jump && alternate_form == AlternateForm::DirectLoopWithHeader)
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue