update main #1

Merged
Sinipelto merged 240 commits from Bananymous/banan-os:main into main 2023-11-20 13:20:51 +02:00
1 changed files with 17 additions and 0 deletions
Showing only changes of commit c84b66d078 - Show all commits

View File

@ -159,6 +159,21 @@ BAN::Optional<BAN::String> parse_dollar(BAN::StringView command, size_t& i)
return "$"sv; return "$"sv;
} }
BAN::StringView strip_whitespace(BAN::StringView sv)
{
size_t leading = 0;
while (leading < sv.size() && isspace(sv[leading]))
leading++;
sv = sv.substring(leading);
size_t trailing = 0;
while (trailing < sv.size() && isspace(sv[sv.size() - trailing - 1]))
trailing++;
sv = sv.substring(0, sv.size() - trailing);
return sv;
}
BAN::Vector<BAN::Vector<BAN::String>> parse_command(BAN::StringView command_view) BAN::Vector<BAN::Vector<BAN::String>> parse_command(BAN::StringView command_view)
{ {
enum class State enum class State
@ -168,6 +183,8 @@ BAN::Vector<BAN::Vector<BAN::String>> parse_command(BAN::StringView command_view
DoubleQuote, DoubleQuote,
}; };
command_view = strip_whitespace(command_view);
BAN::Vector<BAN::Vector<BAN::String>> result; BAN::Vector<BAN::Vector<BAN::String>> result;
BAN::Vector<BAN::String> command_args; BAN::Vector<BAN::String> command_args;