diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-01-25 00:21:06 +0330 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-01-26 00:53:09 +0330 |
commit | aa2021011989d8d658ad9d9b454b24e48872f4de (patch) | |
tree | d52c192ccda6204bc55ddb9af8b2e96030d6b691 | |
parent | c9d026d7bc580f618d113daf17cb70399e09e11c (diff) | |
download | serenity-aa2021011989d8d658ad9d9b454b24e48872f4de.zip |
LibRegex: Don't return empty vectors from RegexStringView::lines()
Instead, return a vector of one empty string.
-rw-r--r-- | Userland/Libraries/LibRegex/RegexMatch.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibRegex/RegexMatch.h b/Userland/Libraries/LibRegex/RegexMatch.h index ddf402c9f7..7359fcf785 100644 --- a/Userland/Libraries/LibRegex/RegexMatch.h +++ b/Userland/Libraries/LibRegex/RegexMatch.h @@ -172,6 +172,9 @@ public: return new_views; }, [](Utf32View view) { + if (view.is_empty()) + return Vector<RegexStringView> { view }; + Vector<RegexStringView> views; u32 newline = '\n'; while (!view.is_empty()) { @@ -187,6 +190,9 @@ public: return views; }, [](Utf16View view) { + if (view.is_empty()) + return Vector<RegexStringView> { view }; + Vector<RegexStringView> views; u16 newline = '\n'; while (!view.is_empty()) { @@ -202,6 +208,9 @@ public: return views; }, [](Utf8View const& view) { + if (view.is_empty()) + return Vector<RegexStringView> { view }; + Vector<RegexStringView> views; auto it = view.begin(); auto previous_newline_position_it = it; |