Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ style_lint_shellcmds:
grep -nrE '[^"]cast\([^)]*?\)[[:alnum:]]' $$(find etc std -name '*.d') ; test $$? -eq 1

@echo "Enforce space between a .. b"
grep -nrE '[[:alnum:]][.][.][[:alnum:]]|[[:alnum:]] [.][.][[:alnum:]]|[[:alnum:]][.][.] [[:alnum:]]' $$(find etc std -name '*.d' | grep -vE 'std/string.d|std/uni/package.d') ; test $$? -eq 1
grep -nrE '[[:alnum:]][.][.][[:alnum:]]|[[:alnum:]] [.][.][[:alnum:]]|[[:alnum:]][.][.] [[:alnum:]]' $$(find etc std -name '*.d' | grep -vE 'std/string.d|std/uni/package.d|std/regex/internal/ir.d') ; test $$? -eq 1

@echo "Enforce space between binary operators"
grep -nrE "[[:alnum:]](==|!=|<=|<<|>>|>>>|^^)[[:alnum:]]|[[:alnum:]] (==|!=|<=|<<|>>|>>>|^^)[[:alnum:]]|[[:alnum:]](==|!=|<=|<<|>>|>>>|^^) [[:alnum:]]" $$(find etc std -name '*.d'); test $$? -eq 1
Expand Down
17 changes: 16 additions & 1 deletion std/regex/internal/ir.d
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ struct Group(DataIndex)

@trusted string toString()() const
{
if (begin < end)
if (begin > end)
return "(unmatched)";
import std.array : appender;
import std.format.write : formattedWrite;
Expand All @@ -402,6 +402,21 @@ struct Group(DataIndex)
}
}

@safe unittest
{
Group!size_t matched = { begin: 2, end: 5 };
assert(cast(bool) matched);
assert(matched.toString == "2..5");

Group!size_t empty = { begin: 3, end: 3 };
assert(cast(bool) empty);
assert(empty.toString == "3..3");

Group!size_t unmatched;
assert(!cast(bool) unmatched);
assert(unmatched.toString == "(unmatched)");
}

//debugging tool, prints out instruction along with opcodes
debug(std_regex_parser) @trusted string disassemble(in Bytecode[] irb, uint pc, in NamedGroup[] dict=[])
{
Expand Down
Loading