Compare commits
No commits in common. "e378d8ee2f5948475f26a48e80d0365d689262d3" and "257c2ffd0aa877a737276fb16d7e60e24c9eafd4" have entirely different histories.
e378d8ee2f
...
257c2ffd0a
@ -100,12 +100,9 @@ static Result<void> load_service(StringView path)
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
auto line = TRY(file->read_line());
|
auto line = TRY(file->read_line(false));
|
||||||
if (line.is_empty()) break;
|
if (line.is_empty()) break;
|
||||||
|
|
||||||
line.trim("\n");
|
|
||||||
if (line.is_empty()) continue;
|
|
||||||
|
|
||||||
auto parts = TRY(line.split_once('='));
|
auto parts = TRY(line.split_once('='));
|
||||||
if (parts.size() < 2 || parts[0].is_empty() || parts[1].is_empty())
|
if (parts.size() < 2 || parts[0].is_empty() || parts[1].is_empty())
|
||||||
{
|
{
|
||||||
|
@ -32,8 +32,6 @@ class String
|
|||||||
return view().split_once(delim);
|
return view().split_once(delim);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trim(StringView delim);
|
|
||||||
|
|
||||||
static Result<String> format(const String& fmt, ...);
|
static Result<String> format(const String& fmt, ...);
|
||||||
static Result<String> format(StringView fmt, ...);
|
static Result<String> format(StringView fmt, ...);
|
||||||
|
|
||||||
|
@ -80,25 +80,6 @@ Result<Vector<String>> String::split(StringView delim) const
|
|||||||
return view().split(delim);
|
return view().split(delim);
|
||||||
}
|
}
|
||||||
|
|
||||||
void String::trim(StringView delim)
|
|
||||||
{
|
|
||||||
isize i = (isize)m_length;
|
|
||||||
|
|
||||||
while (i--)
|
|
||||||
{
|
|
||||||
char c = chars()[i];
|
|
||||||
if (!strchr(delim.chars(), c)) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
|
||||||
|
|
||||||
if (m_inline) m_inline_storage[i] = '\0';
|
|
||||||
else
|
|
||||||
m_string[i] = '\0';
|
|
||||||
|
|
||||||
m_length = (usize)i;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char& String::operator[](usize index) const
|
const char& String::operator[](usize index) const
|
||||||
{
|
{
|
||||||
expect(index < m_length, "index out of range");
|
expect(index < m_length, "index out of range");
|
||||||
|
@ -33,7 +33,7 @@ namespace os
|
|||||||
Result<void> write(StringView str);
|
Result<void> write(StringView str);
|
||||||
Result<void> write(const Buffer& buf);
|
Result<void> write(const Buffer& buf);
|
||||||
|
|
||||||
Result<String> read_line();
|
Result<String> read_line(bool keep_newline = true);
|
||||||
|
|
||||||
Result<void> read(Buffer& buf, usize size);
|
Result<void> read(Buffer& buf, usize size);
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ namespace os
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<String> File::read_line()
|
Result<String> File::read_line(bool keep_newline)
|
||||||
{
|
{
|
||||||
Vector<char> data;
|
Vector<char> data;
|
||||||
|
|
||||||
@ -121,7 +121,11 @@ namespace os
|
|||||||
|
|
||||||
TRY(data.try_append((char)current));
|
TRY(data.try_append((char)current));
|
||||||
|
|
||||||
if (current == '\n') break;
|
if (current == '\n')
|
||||||
|
{
|
||||||
|
if (!keep_newline) data.try_pop();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.size()) return String {};
|
if (!data.size()) return String {};
|
||||||
|
Loading…
Reference in New Issue
Block a user