mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
sort: Allow multi-character separators to be given with the -t
option
This commit is contained in:
parent
e6112446db
commit
94b247ec3c
Notes:
sideshowbarker
2024-07-17 02:39:10 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/94b247ec3c Pull-request: https://github.com/SerenityOS/serenity/pull/20800 Reviewed-by: https://github.com/trflynn89
1 changed files with 4 additions and 4 deletions
|
@ -57,7 +57,7 @@ struct Options {
|
|||
bool numeric { false };
|
||||
bool reverse { false };
|
||||
bool zero_terminated { false };
|
||||
StringView separator { "\0", 1 };
|
||||
StringView separator {};
|
||||
Vector<DeprecatedString> files;
|
||||
};
|
||||
|
||||
|
@ -72,9 +72,9 @@ static ErrorOr<void> load_file(Options const& options, StringView filename, Stri
|
|||
DeprecatedString line { TRY(file->read_until(buffer, line_delimiter)) };
|
||||
StringView key = line;
|
||||
if (options.key_field != 0) {
|
||||
auto split = (options.separator[0])
|
||||
? line.split_view(options.separator[0])
|
||||
: line.split_view(is_ascii_space);
|
||||
auto split = (!options.separator.is_empty())
|
||||
? key.split_view(options.separator)
|
||||
: key.split_view_if(is_ascii_space);
|
||||
if (options.key_field - 1 >= split.size()) {
|
||||
key = ""sv;
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue