summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authordemostanis <demostanis@protonmail.com>2022-10-22 15:38:21 +0200
committerLinus Groh <mail@linusgroh.de>2022-10-24 23:29:18 +0100
commit3e8b5ac92012e19847e536a20a3f0ec7e5c787d3 (patch)
tree58294f8f5e5eeaa63231876148da783ca81015eb /Userland/Libraries
parentf485db2501c32bd626d58973c8a34a81e09ca5dc (diff)
downloadserenity-3e8b5ac92012e19847e536a20a3f0ec7e5c787d3.zip
AK+Everywhere: Turn bool keep_empty to an enum in split* functions
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibC/getopt.cpp2
-rw-r--r--Userland/Libraries/LibC/grp.cpp2
-rw-r--r--Userland/Libraries/LibC/pwd.cpp2
-rw-r--r--Userland/Libraries/LibC/shadow.cpp2
-rw-r--r--Userland/Libraries/LibCodeComprehension/Shell/ShellComprehensionEngine.cpp2
-rw-r--r--Userland/Libraries/LibCore/ArgsParser.cpp2
-rw-r--r--Userland/Libraries/LibDiff/Format.cpp2
-rw-r--r--Userland/Libraries/LibGUI/EmojiInputDialog.cpp2
-rw-r--r--Userland/Libraries/LibHTTP/HttpRequest.cpp2
-rw-r--r--Userland/Libraries/LibHTTP/Job.cpp2
-rw-r--r--Userland/Libraries/LibJS/Parser.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp2
-rw-r--r--Userland/Libraries/LibMarkdown/Table.cpp6
-rw-r--r--Userland/Libraries/LibTest/JavaScriptTestRunner.h2
14 files changed, 16 insertions, 16 deletions
diff --git a/Userland/Libraries/LibC/getopt.cpp b/Userland/Libraries/LibC/getopt.cpp
index 3c6b346e6c..9819f356d3 100644
--- a/Userland/Libraries/LibC/getopt.cpp
+++ b/Userland/Libraries/LibC/getopt.cpp
@@ -138,7 +138,7 @@ int OptionParser::getopt()
bool OptionParser::lookup_short_option(char option, int& needs_value) const
{
- Vector<StringView> parts = m_short_options.split_view(option, true);
+ Vector<StringView> parts = m_short_options.split_view(option, SplitBehavior::KeepEmpty);
VERIFY(parts.size() <= 2);
if (parts.size() < 2) {
diff --git a/Userland/Libraries/LibC/grp.cpp b/Userland/Libraries/LibC/grp.cpp
index 5bfa1b7277..7d90833e9d 100644
--- a/Userland/Libraries/LibC/grp.cpp
+++ b/Userland/Libraries/LibC/grp.cpp
@@ -73,7 +73,7 @@ struct group* getgrnam(char const* name)
static bool parse_grpdb_entry(String const& line)
{
- auto parts = line.split_view(':', true);
+ auto parts = line.split_view(':', SplitBehavior::KeepEmpty);
if (parts.size() != 4) {
warnln("getgrent(): Malformed entry on line {}: '{}' has {} parts", s_line_number, line, parts.size());
return false;
diff --git a/Userland/Libraries/LibC/pwd.cpp b/Userland/Libraries/LibC/pwd.cpp
index 3d9ffcb156..f3ef1aa505 100644
--- a/Userland/Libraries/LibC/pwd.cpp
+++ b/Userland/Libraries/LibC/pwd.cpp
@@ -73,7 +73,7 @@ struct passwd* getpwnam(char const* name)
static bool parse_pwddb_entry(String const& line)
{
- auto parts = line.split_view(':', true);
+ auto parts = line.split_view(':', SplitBehavior::KeepEmpty);
if (parts.size() != 7) {
dbgln("getpwent(): Malformed entry on line {}", s_line_number);
return false;
diff --git a/Userland/Libraries/LibC/shadow.cpp b/Userland/Libraries/LibC/shadow.cpp
index 099fca4cae..53739944f8 100644
--- a/Userland/Libraries/LibC/shadow.cpp
+++ b/Userland/Libraries/LibC/shadow.cpp
@@ -64,7 +64,7 @@ struct spwd* getspnam(char const* name)
static bool parse_shadow_entry(String const& line)
{
- auto parts = line.split_view(':', true);
+ auto parts = line.split_view(':', SplitBehavior::KeepEmpty);
if (parts.size() != 9) {
dbgln("getspent(): Malformed entry on line {}", s_line_number);
return false;
diff --git a/Userland/Libraries/LibCodeComprehension/Shell/ShellComprehensionEngine.cpp b/Userland/Libraries/LibCodeComprehension/Shell/ShellComprehensionEngine.cpp
index 94a34201eb..aeac3addcd 100644
--- a/Userland/Libraries/LibCodeComprehension/Shell/ShellComprehensionEngine.cpp
+++ b/Userland/Libraries/LibCodeComprehension/Shell/ShellComprehensionEngine.cpp
@@ -117,7 +117,7 @@ size_t ShellComprehensionEngine::resolve(ShellComprehensionEngine::DocumentData
if (position.line() > 0) {
auto first = true;
size_t line = 0;
- for (auto& line_view : document.text.split_limit('\n', position.line() + 1, true)) {
+ for (auto& line_view : document.text.split_limit('\n', position.line() + 1, SplitBehavior::KeepEmpty)) {
if (line == position.line())
break;
if (first)
diff --git a/Userland/Libraries/LibCore/ArgsParser.cpp b/Userland/Libraries/LibCore/ArgsParser.cpp
index 15866d9573..6a450b4161 100644
--- a/Userland/Libraries/LibCore/ArgsParser.cpp
+++ b/Userland/Libraries/LibCore/ArgsParser.cpp
@@ -554,7 +554,7 @@ void ArgsParser::add_option(Vector<size_t>& values, char const* help_string, cha
[&values, separator](char const* s) {
bool parsed_all_values = true;
- StringView { s, strlen(s) }.for_each_split_view(separator, false, [&](auto value) {
+ StringView { s, strlen(s) }.for_each_split_view(separator, SplitBehavior::Nothing, [&](auto value) {
if (auto maybe_value = AK::StringUtils::convert_to_uint<size_t>(value); maybe_value.has_value())
values.append(*maybe_value);
else
diff --git a/Userland/Libraries/LibDiff/Format.cpp b/Userland/Libraries/LibDiff/Format.cpp
index 1e1718ada0..9f109b4c24 100644
--- a/Userland/Libraries/LibDiff/Format.cpp
+++ b/Userland/Libraries/LibDiff/Format.cpp
@@ -12,7 +12,7 @@
namespace Diff {
String generate_only_additions(String const& text)
{
- auto lines = text.split('\n', true); // Keep empty
+ auto lines = text.split('\n', SplitBehavior::KeepEmpty);
StringBuilder builder;
builder.appendff("@@ -0,0 +1,{} @@\n", lines.size());
for (auto const& line : lines) {
diff --git a/Userland/Libraries/LibGUI/EmojiInputDialog.cpp b/Userland/Libraries/LibGUI/EmojiInputDialog.cpp
index 682de4192d..9e89a151fe 100644
--- a/Userland/Libraries/LibGUI/EmojiInputDialog.cpp
+++ b/Userland/Libraries/LibGUI/EmojiInputDialog.cpp
@@ -179,7 +179,7 @@ auto EmojiInputDialog::supported_emoji() -> Vector<Emoji>
StringBuilder builder;
Vector<u32> code_points;
- basename.for_each_split_view('_', false, [&](auto segment) {
+ basename.for_each_split_view('_', SplitBehavior::Nothing, [&](auto segment) {
auto code_point = AK::StringUtils::convert_to_uint_from_hex<u32>(segment.substring_view(2));
VERIFY(code_point.has_value());
diff --git a/Userland/Libraries/LibHTTP/HttpRequest.cpp b/Userland/Libraries/LibHTTP/HttpRequest.cpp
index fa43b6585e..baa26d22d9 100644
--- a/Userland/Libraries/LibHTTP/HttpRequest.cpp
+++ b/Userland/Libraries/LibHTTP/HttpRequest.cpp
@@ -211,7 +211,7 @@ Optional<HttpRequest> HttpRequest::from_raw_request(ReadonlyBytes raw_request)
return {};
request.m_headers = move(headers);
- auto url_parts = resource.split_limit('?', 2, true);
+ auto url_parts = resource.split_limit('?', 2, SplitBehavior::KeepEmpty);
request.m_url.set_cannot_be_a_base_url(true);
if (url_parts.size() == 2) {
diff --git a/Userland/Libraries/LibHTTP/Job.cpp b/Userland/Libraries/LibHTTP/Job.cpp
index c4dcb09285..787eff13c6 100644
--- a/Userland/Libraries/LibHTTP/Job.cpp
+++ b/Userland/Libraries/LibHTTP/Job.cpp
@@ -453,7 +453,7 @@ void Job::on_socket_connected()
finish_up();
break;
} else {
- auto chunk = size_lines[0].split_view(';', true);
+ auto chunk = size_lines[0].split_view(';', SplitBehavior::KeepEmpty);
String size_string = chunk[0];
char* endptr;
auto size = strtoul(size_string.characters(), &endptr, 16);
diff --git a/Userland/Libraries/LibJS/Parser.h b/Userland/Libraries/LibJS/Parser.h
index 867361fbac..4e9b904aaa 100644
--- a/Userland/Libraries/LibJS/Parser.h
+++ b/Userland/Libraries/LibJS/Parser.h
@@ -192,7 +192,7 @@ public:
// line terminators to \n is easier than splitting using all different LT characters.
String source_string = source.replace("\r\n"sv, "\n"sv, ReplaceMode::All).replace("\r"sv, "\n"sv, ReplaceMode::All).replace(LINE_SEPARATOR_STRING, "\n"sv, ReplaceMode::All).replace(PARAGRAPH_SEPARATOR_STRING, "\n"sv, ReplaceMode::All);
StringBuilder builder;
- builder.append(source_string.split_view('\n', true)[position.value().line - 1]);
+ builder.append(source_string.split_view('\n', SplitBehavior::KeepEmpty)[position.value().line - 1]);
builder.append('\n');
for (size_t i = 0; i < position.value().column - 1; ++i)
builder.append(spacer);
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
index 3014fe94e3..3738d38ecb 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
@@ -965,7 +965,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split)
// 19. Repeat, while q < size,
while (next_search_from < string.length_in_code_units()) {
- // a. Perform ? Set(splitter, "lastIndex", 𝔽(q), true).
+ // a. Perform ? Set(splitter, "lastIndex", 𝔽(q), SplitBehavior::KeepEmpty).
TRY(splitter->set(vm.names.lastIndex, Value(next_search_from), Object::ShouldThrowExceptions::Yes));
// b. Let z be ? RegExpExec(splitter, S).
diff --git a/Userland/Libraries/LibMarkdown/Table.cpp b/Userland/Libraries/LibMarkdown/Table.cpp
index 417e604565..d0144e2a01 100644
--- a/Userland/Libraries/LibMarkdown/Table.cpp
+++ b/Userland/Libraries/LibMarkdown/Table.cpp
@@ -138,8 +138,8 @@ OwnPtr<Table> Table::parse(LineIterator& lines)
if (peek_it.is_end())
return {};
- auto header_segments = first_line.split_view('|', true);
- auto header_delimiters = peek_it->split_view('|', true);
+ auto header_segments = first_line.split_view('|', SplitBehavior::KeepEmpty);
+ auto header_delimiters = peek_it->split_view('|', SplitBehavior::KeepEmpty);
if (!header_segments.is_empty())
header_segments.take_first();
@@ -214,7 +214,7 @@ OwnPtr<Table> Table::parse(LineIterator& lines)
++lines;
- auto segments = line.split_view('|', true);
+ auto segments = line.split_view('|', SplitBehavior::KeepEmpty);
segments.take_first();
if (!segments.is_empty() && segments.last().is_empty())
segments.take_last();
diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunner.h b/Userland/Libraries/LibTest/JavaScriptTestRunner.h
index b2d4e01fe8..3971b1a450 100644
--- a/Userland/Libraries/LibTest/JavaScriptTestRunner.h
+++ b/Userland/Libraries/LibTest/JavaScriptTestRunner.h
@@ -522,7 +522,7 @@ inline void TestRunner::print_file_result(JSFileResult const& file_result) const
#endif
outln();
print_modifiers({ FG_GRAY });
- for (auto& message : test_error.hint.split('\n', true)) {
+ for (auto& message : test_error.hint.split('\n', SplitBehavior::KeepEmpty)) {
outln(" {}", message);
}
print_modifiers({ FG_RED });